Skip to content

Instantly share code, notes, and snippets.

@resmo
Last active December 28, 2015 18:19
Show Gist options
  • Save resmo/7542680 to your computer and use it in GitHub Desktop.
Save resmo/7542680 to your computer and use it in GitHub Desktop.
host module features

change ip

/etc/hosts:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

task:

host: hostname=localhost ip=127.0.0.2 aliases=localhost.localdomain,localhost4,localhost4.localdomain4

/etc/hosts:

127.0.0.2   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

change hostname

/etc/hosts:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

task:

host: hostname=vagrant ip=127.0.0.1 aliases=localhost.localdomain,localhost4,localhost4.localdomain4

/etc/hosts:

127.0.0.1   vagrant localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

remove hostname

/etc/hosts:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

task:

host: hostname=localhost state=absent

/etc/hosts:

# no entries enymore, removes all localhost hostnames entires

remove ip

/etc/hosts:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

task:

host: ip=::1 state=absent

/etc/hosts:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment