Add conditionals to enable system module for idempotency purposes
Showing
1 changed file
with
18 additions
and
4 deletions
| ... | @@ -15,7 +15,7 @@ | ... | @@ -15,7 +15,7 @@ |
| 15 | - name: Test {{ beat_name }} connection | 15 | - name: Test {{ beat_name }} connection |
| 16 | shell: '{{ beat_name }} test output' | 16 | shell: '{{ beat_name }} test output' |
| 17 | register: result | 17 | register: result |
| 18 | changed_when: "result.rc != 0" | 18 | changed_when: False |
| 19 | 19 | ||
| 20 | - name: Test connection output | 20 | - name: Test connection output |
| 21 | debug: | 21 | debug: |
| ... | @@ -26,15 +26,29 @@ | ... | @@ -26,15 +26,29 @@ |
| 26 | daemon_reload: yes | 26 | daemon_reload: yes |
| 27 | when: ansible_distribution_major_version >= "7" | 27 | when: ansible_distribution_major_version >= "7" |
| 28 | 28 | ||
| 29 | - name: Configure system module of {{ beat_name }} | 29 | - name: Verify if system module of {{ beat_name }} is enabled |
| 30 | shell: '{{ beat_name }} modules enable system' | 30 | shell: '{{ beat_name }} modules list | grep -i system' |
| 31 | ignore_errors: yes | ||
| 31 | #when: modules == 'yes' | 32 | #when: modules == 'yes' |
| 32 | when: ( beat_name == "metricbeat") or | 33 | when: ( beat_name == "metricbeat") or |
| 33 | ( beat_name == "filebeat") | 34 | ( beat_name == "filebeat") |
| 35 | register: verify_system_result | ||
| 36 | changed_when: False | ||
| 37 | |||
| 38 | - name: Configure system module of {{ beat_name }} | ||
| 39 | shell: '{{ beat_name }} modules enable system' | ||
| 40 | #when: modules == 'yes' | ||
| 41 | when: | ||
| 42 | - ( beat_name == "metricbeat") or ( beat_name == "filebeat") | ||
| 43 | - "verify_system_result.rc != 0" | ||
| 44 | register: result | ||
| 45 | changed_when: "'Module system is already enabled' not in result.stdout" | ||
| 34 | 46 | ||
| 35 | - name: Run {{ beat_name }} setup and dashboard config on kibana | 47 | - name: Run {{ beat_name }} setup and dashboard config on kibana |
| 36 | shell: '{{ beat_name }} setup' | 48 | shell: '{{ beat_name }} setup' |
| 37 | ignore_errors: yes | 49 | register: result |
| 50 | changed_when: "result.rc != 0" | ||
| 51 | ignore_errors: True | ||
| 38 | 52 | ||
| 39 | - name: Start {{ beat_name }} service | 53 | - name: Start {{ beat_name }} service |
| 40 | service: | 54 | service: | ... | ... |
-
Please register or sign in to post a comment