Skip to content

Instantly share code, notes, and snippets.

@cocampbe
Last active August 9, 2018 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cocampbe/5c34b6e37511bf569a3dec9a8433f687 to your computer and use it in GitHub Desktop.
Save cocampbe/5c34b6e37511bf569a3dec9a8433f687 to your computer and use it in GitHub Desktop.
Example of changing an ip address on a EL host using the ansible nmcli module
- hosts: server123
gather_facts: no
become: yes
name: change network config prior to failover
tasks:
- block:
- nmcli:
type: ethernet
conn_name: 'eth0'
ip4: '192.168.99.34/24'
gw4: '192.168.99.1'
dns4:
- 8.8.8.8
- 4.4.4.4
state: present
- lineinfile:
path: /etc/hosts
regexp: '192.168.88.56'
line: '192.168.99.34 server123'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment