Skip to content

Commit a20fbf5

Browse files
author
Mason Morales
authored
Merge pull request #31 from splunk/fix_linting_errors
Fixed most linting warnings and a bug that was encountered when running Ansible against a host that has Splunk in a stopped state
2 parents c3efc0d + aeef5bf commit a20fbf5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+301
-272
lines changed

roles/splunk/handlers/main.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
loop:
1212
- ulimit -Hn 65536
1313
- ulimit -Sn 32768
14-
become: yes
14+
become: true
1515
ignore_errors: true
1616
when: splunk_use_initd and ansible_os_family == "RedHat" and ansible_distribution_major_version|int > 6
1717

@@ -20,29 +20,29 @@
2020
path: /etc/init.d/splunk
2121
regexp: '(start --no-prompt --answer-yes)$'
2222
replace: '\1 --accept-license'
23-
become: yes
23+
become: true
2424
when: splunk_use_initd
2525

2626
- name: reload systemctl daemon
2727
systemd:
28-
daemon_reload: yes
29-
become: yes
28+
daemon_reload: true
29+
become: true
3030

3131
- name: stop splunk
3232
service:
3333
name: "{{ splunk_service }}"
3434
state: stopped
35-
become: yes
35+
become: true
3636

3737
- name: start splunk
3838
service:
3939
name: "{{ splunk_service }}"
4040
state: started
41-
become: yes
41+
become: true
4242

4343
- name: apply indexer cluster bundle
4444
command: "{{ splunk_home }}/bin/splunk apply cluster-bundle --answer-yes --skip-validation -auth {{ splunk_auth }}"
45-
become: yes
45+
become: true
4646
become_user: "{{ splunk_nix_user }}"
4747
register: apply_cluster_bundle_result
4848
changed_when: apply_cluster_bundle_result.rc == 0
@@ -53,15 +53,15 @@
5353
when: "'clustermaster' in group_names"
5454

5555
- name: reload deployment server
56-
shell: "{{ splunk_home }}/bin/splunk reload deploy-server -auth {{ splunk_auth }}"
57-
become: yes
56+
command: "{{ splunk_home }}/bin/splunk reload deploy-server -auth {{ splunk_auth }}"
57+
become: true
5858
become_user: "{{ splunk_nix_user }}"
5959
no_log: true
6060
when: "'deploymentserver' in group_names"
6161

6262
- name: apply shcluster-bundle
6363
command: "{{ splunk_home }}/bin/splunk apply shcluster-bundle -preserve-lookups true --answer-yes -auth {{ splunk_auth }} -target {{ deploy_target }}"
64-
become: yes
64+
become: true
6565
become_user: "{{ splunk_nix_user }}"
6666
register: apply_shcluster_bundle_result
6767
changed_when: apply_shcluster_bundle_result.rc == 0
@@ -75,9 +75,8 @@
7575
service:
7676
name: "{{ splunk_service }}"
7777
state: restarted
78-
become: yes
78+
become: true
7979

8080
- name: restart auditd service
8181
command: service auditd condrestart
82-
become: yes
83-
82+
become: true

roles/splunk/tasks/add_crashlog_script.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
owner: root
77
group: root
88
mode: 0755
9-
become: yes
9+
become: true
1010

1111
- name: Configure cron to run cleanup_crashlogs.sh daily at midnight
1212
cron:
@@ -15,4 +15,4 @@
1515
job: "{{ splunk_home }}/cleanup_crashlogs.sh"
1616
hour: 0
1717
minute: 0
18-
become: yes
18+
become: true

roles/splunk/tasks/add_diag_script.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
owner: root
77
group: root
88
mode: 0755
9-
become: yes
9+
become: true
1010

1111
- name: Configure cron to run cleanup_diags.sh daily at midnight
1212
cron:
@@ -15,4 +15,4 @@
1515
job: "{{ splunk_home }}/cleanup_diags.sh"
1616
hour: 0
1717
minute: 0
18-
become: yes
18+
become: true

roles/splunk/tasks/add_pstack_script.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
owner: "{{ splunk_nix_user }}"
77
group: "{{ splunk_nix_group }}"
88
mode: 0755
9-
become: yes
9+
become: true

roles/splunk/tasks/adhoc_clean_dispatch.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
include_tasks: splunk_stop.yml
44

55
- name: Clean dispatch directory of all files
6-
shell: "rm -rf {{ splunk_home }}/var/run/splunk/dispatch/*"
7-
become: yes
6+
command: "rm -rf {{ splunk_home }}/var/run/splunk/dispatch/*"
7+
become: true
88

99
- name: Start Splunk
1010
include_tasks: splunk_start.yml

roles/splunk/tasks/adhoc_configure_hostname.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
- name: Set the system's hostname to the inventory_hostname
33
hostname:
44
name: "{{ inventory_hostname }}"
5-
become: yes
5+
become: true
66

77
- name: "Update serverName in {{ splunk_home }}/etc/system/local/server.conf"
88
lineinfile:
99
dest: "{{ splunk_home }}/etc/system/local/server.conf"
1010
state: present
1111
regexp: "^serverName = .*"
1212
line: "serverName = {{ ansible_hostname }}"
13-
become: yes
13+
become: true
1414
become_user: "{{ splunk_nix_user }}"
1515
notify: restart splunk
1616

@@ -20,6 +20,6 @@
2020
state: present
2121
regexp: "^host = .*"
2222
line: "host = {{ ansible_hostname }}"
23-
become: yes
23+
become: true
2424
become_user: "{{ splunk_nix_user }}"
2525
notify: restart splunk
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
- name: Execute splunk offline --enforce-counts
3-
shell: "{{ splunk_home }}/bin/splunk offline --enforce-counts -auth {{ splunk_auth }}"
4-
become: yes
3+
command: "{{ splunk_home }}/bin/splunk offline --enforce-counts -auth {{ splunk_auth }}"
4+
become: true
55
become_user: "{{ splunk_nix_user }}"
66
no_log: true
77
when: "'indexer' in group_names"

roles/splunk/tasks/adhoc_fix_mongo.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
mode: 0600
77
owner: "{{ splunk_nix_user }}"
88
group: "{{ splunk_nix_group }}"
9-
become: yes
9+
become: true
1010

1111
- name: Delete mongod.lock if present
1212
file:
1313
state: absent
1414
path: "{{ splunk_home }}/var/lib/splunk/kvstore/mongo/mongod.lock"
15-
become: yes
15+
become: true
1616

1717
- name: Update file permissions for journal
1818
file:
1919
state: directory
20-
recurse: yes
20+
recurse: true
2121
path: "{{ splunk_home }}/var/lib/splunk/kvstore/mongo/journal"
2222
mode: 0710
2323
owner: "{{ splunk_nix_user }}"
2424
group: "{{ splunk_nix_group }}"
25-
become: yes
25+
become: true
2626

2727
# Also consider adhoc_fix_server_certificate.yml if the cert is expired and you are using the default cert for kvstore

roles/splunk/tasks/adhoc_fix_server_certificate.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# To check if cert is expired: splunk cmd openssl x509 -in /opt/splunk/etc/auth/server.pem -text -noout
33
# Note: Genereates new default certificate. Do not use this if you generate/sign your own splunkd certificate
44
- name: Remove old server.pem certificate and generate a new one
5-
shell: "{{ item }}"
6-
become: yes
5+
command: "{{ item }}"
6+
become: true
77
become_user: "{{ splunk_nix_user }}"
88
loop:
99
- "rm {{ splunk_home }}/etc/auth/server.pem"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
- name: Kill any stale splunkd processes
33
shell: for i in $(ps -ef | grep splunkd -i | grep -v grep | awk '{print $2}'); do kill -9 $i; done
4-
become: yes
4+
become: true

0 commit comments

Comments
 (0)