Commit 9b68d9ba by Feanil Patel

Use get_url and a handler to restart splunk.

parent 7bad77d0
...@@ -14,5 +14,7 @@ ...@@ -14,5 +14,7 @@
# Overview: # Overview:
# #
# #
- name: splunk | notify me
debug: msg="stub handler" # Restart Splunk
- name: splunkforwarder | restart splunkforwarder
service: name=splunk state=restarted
...@@ -21,12 +21,7 @@ ...@@ -21,12 +21,7 @@
# #
# #
- name: splunkforwarder | stub ansible task
debug: msg="This is a stub task created by the ansible-role role"
notify: splunk | notify me
# Install Splunk Forwarder # Install Splunk Forwarder
- name: splunkforwarder| install splunkforwarder specific system packages - name: splunkforwarder| install splunkforwarder specific system packages
apt: pkg={{','.join(splunk_debian_pkgs)}} state=present apt: pkg={{','.join(splunk_debian_pkgs)}} state=present
tags: tags:
...@@ -35,11 +30,9 @@ ...@@ -35,11 +30,9 @@
- update - update
- name: splunkforwarder | download the splunk deb - name: splunkforwarder | download the splunk deb
shell: get_url: >
chdir="/tmp/" dest="/tmp/{{SPLUNKFORWARDER_DEB}}"
executable="/bin/bash" url="{{SPLUNKFORWARDER_PACKAGE_LOCATION}}{{SPLUNKFORWARDER_DEB}}"
creates="/tmp/{{SPLUNKFORWARDER_DEB}}"
wget -q {{SPLUNKFORWARDER_PACKAGE_LOCATION}}{{SPLUNKFORWARDER_DEB}}
register: download_deb register: download_deb
- name: splunkforwarder | install splunk forwarder - name: splunkforwarder | install splunk forwarder
...@@ -52,23 +45,29 @@ ...@@ -52,23 +45,29 @@
when: download_deb.changed when: download_deb.changed
- name: splunkforwarder | create boot script - name: splunkforwarder | create boot script
shell: creates=/etc/init.d/splunk {{splunkforwarder_output_dir}}/bin/splunk enable boot-start -user splunk --accept-license --answer-yes --no-prompt shell: >
{{splunkforwarder_output_dir}}/bin/splunk enable boot-start -user splunk --accept-license --answer-yes --no-prompt
creates=/etc/init.d/splunk
register: create_boot_script register: create_boot_script
when: download_deb.changed when: download_deb.changed
notify: splunkforwarder | restart splunkforwarder
# Update credentials # Update credentials
- name: splunkforwarder | update admin pasword - name: splunkforwarder | update admin pasword
shell: "{{splunkforwarder_output_dir}}/bin/splunk edit user admin -password {{SPLUNKFORWARDER_PASSWORD}} -auth admin:changeme --accept-license --answer-yes --no-prompt" shell: "{{splunkforwarder_output_dir}}/bin/splunk edit user admin -password {{SPLUNKFORWARDER_PASSWORD}} -auth admin:changeme --accept-license --answer-yes --no-prompt"
when: download_deb.changed when: download_deb.changed
notify: splunkforwarder | restart splunkforwarder
- name: splunkforwarder | add chkconfig to init script - name: splunkforwarder | add chkconfig to init script
shell: 'sed -i -e "s/\/bin\/sh/\/bin\/sh\n# chkconfig: 235 98 55/" /etc/init.d/splunk' shell: 'sed -i -e "s/\/bin\/sh/\/bin\/sh\n# chkconfig: 235 98 55/" /etc/init.d/splunk'
when: download_deb.changed and create_boot_script.changed when: download_deb.changed and create_boot_script.changed
notify: splunkforwarder | restart splunkforwarder
# Ensure permissions on splunk content # Ensure permissions on splunk content
- name: splunkforwarder | ensure splunk forder permissions - name: splunkforwarder | ensure splunk forder permissions
file: path={{splunkforwarder_output_dir}} state=directory recurse=yes owner=splunk group=splunk file: path={{splunkforwarder_output_dir}} state=directory recurse=yes owner=splunk group=splunk
when: download_deb.changed when: download_deb.changed
notify: splunkforwarder | restart splunkforwarder
# Drop template files. # Drop template files.
- name: splunkforwarder | drop input configuration - name: splunkforwarder | drop input configuration
...@@ -78,6 +77,7 @@ ...@@ -78,6 +77,7 @@
owner=splunk owner=splunk
group=splunk group=splunk
mode=644 mode=644
notify: splunkforwarder | restart splunkforwarder
- name: splunkforwarder | create outputs config file - name: splunkforwarder | create outputs config file
template: template:
...@@ -86,7 +86,4 @@ ...@@ -86,7 +86,4 @@
owner=splunk owner=splunk
group=splunk group=splunk
mode=644 mode=644
notify: splunkforwarder | restart splunkforwarder
# Restart Splunk
- name: splunkforwarder | restart the splunk forwarder
service: name=splunk state=restarted
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment