Reputation: 165
There is lineinfile /opt/firewall-rules.sh:
TESTING="111.111.111.111/32,111.111.111.112/32"
How through the lineinfile module to add to the two existing third ip entry - 111.111.111.113/32, so that as a result the lines look like this:
TESTING="111.111.111.111/32,111.111.111.112/32,111.111.111.113/32"
There is the particular solution at other post but it doesn't add one IP it replace whole line.
- name: Firewall rule
replace:
path: /opt/firewall-rulles.sh
regexp: '"$'
replace: ',111.111.111.113/32"'
after: 'TEST=*'
before: 'DEVELOPE*'
backup: yes
I'm trying this but it replace all after DEVELOPE
Solution as I see(Best regards for all answers and advice):
- name: Firewall rule for DB_TESTING
replace:
path: /opt/firewall-rules.sh
regexp: '(^TESTING=.*)"$'
replace: '\1,{{ ansible_default_ipv4.address }}/32"'
backup: yes
delegate_to: DB_TESTING
It's adding IP line from host variable at delegated servers firewall config
Best regards
Upvotes: 1
Views: 165