sh1900
sh1900

Reputation: 1

changing just netmask in servers debian 9 with playbook ansible

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

Answers (1)

SAURABH PANDEY
SAURABH PANDEY

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

Related Questions