Reputation: 1
I want to change just netmask of servers in debian9 (/etc/network/interfaces), with Ansible.
Do you have an idea how can I do that?
Upvotes: 0
Views: 187
Reputation: 124
use following playbook directly.
[rohtash@172 blockinfile]$ cat edit_netmask.yml
- hosts: localhost
connection: local
tasks:
- replace:
path: netmasks
regexp: 'netmask 255.255.255.0'
replace: 'netmask {{ input }}'
backup: yes
[rohtash@172 blockinfile]$ ansible-playbook edit_netmask.yml -e input=255.255.255.240
PLAY [localhost] ******************************************************************************************************************************************************************************
TASK [Gathering Facts] ************************************************************************************************************************************************************************
ok: [localhost]
TASK [replace] ********************************************************************************************************************************************************************************
changed: [localhost]
PLAY RECAP ************************************************************************************************************************************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
It will directly replace netmasks of the servers.
Upvotes: 0