nagios-nrpe: fix allowed_hosts configuration: keep potential added IP, but we cannot use backrefs if the line does not exist yet
This commit is contained in:
parent
f801218789
commit
9c450ff11b
|
@ -75,6 +75,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
* nagios-nrpe: grep in check_ipsecctl_critiques.sh was too large
|
||||
* post-install: fix missing space in generateldif.sh script
|
||||
* logsentry: fix variables for configuration files
|
||||
* nagios-nrpe: fix allowed_hosts configuration: keep potential added IP, but we cannot use backrefs if the line does not exist yet
|
||||
|
||||
### Removed
|
||||
|
||||
|
|
|
@ -46,13 +46,33 @@
|
|||
tags:
|
||||
- nagios-nrpe
|
||||
|
||||
- name: "Allow NRPE hosts"
|
||||
- name: "Fetch nrpe config content"
|
||||
command: 'grep "allowed_hosts=" /etc/nrpe.d/evolix.cfg'
|
||||
check_mode: false
|
||||
register: nrpe_config_content
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
tags:
|
||||
- nagios-nrpe
|
||||
|
||||
- name: "Allow NRPE hosts - if no allowed_hosts configured"
|
||||
lineinfile:
|
||||
dest: /etc/nrpe.d/evolix.cfg
|
||||
insertbefore: BOF
|
||||
regex: "allowed_hosts={{ nagios_nrpe_allowed_hosts | join(',') }}"
|
||||
line: 'allowed_hosts={{ nagios_nrpe_allowed_hosts | join(",") }}'
|
||||
when: nrpe_config_content.rc != 0
|
||||
tags:
|
||||
- nagios-nrpe
|
||||
|
||||
- name: "Allow NRPE hosts - if allowed_hosts already configured : keep added IP"
|
||||
lineinfile:
|
||||
dest: /etc/nrpe.d/evolix.cfg
|
||||
backrefs: true
|
||||
regex: "allowed_hosts={{ nagios_nrpe_allowed_hosts | join(',') }}(.*)"
|
||||
insertbefore: BOF
|
||||
regex: "allowed_hosts={{ nagios_nrpe_allowed_hosts | join(',') }}(.*)*"
|
||||
line: 'allowed_hosts={{ nagios_nrpe_allowed_hosts | join(",") }}\1'
|
||||
when: nrpe_config_content.rc == 0
|
||||
tags:
|
||||
- nagios-nrpe
|
||||
|
||||
|
|
Loading…
Reference in a new issue