On May 25, 2011, in sysadmin, by Mike Bailey

When I spin up new virtual machines in the lab they come into the world with the same IP (.69) and the hostname of ‘template’. The following recipe makes updating the hostname and networking details a breeze. If the my workstation can resolve the new hostname to an IP (DNS or /etc/hosts) deprec will make sensible suggestions for network addresses.

$ cap deprec:network:config HOSTS=lucid
    triggering load callbacks
  * executing `deprec:connect_canonical_tasks'
  * executing `deprec:network:config'
  * executing `deprec:network:hostname'
Enter the hostname for the server
<...lines removed for clarity...>
Number of network interfaces  |1|

address  ||

netmask  ||

broadcast  ||

default gateway  ||

<...lines removed for clarity...>

About to restart networking on lucid
Are you 'down with that'?  |y|
  * executing "sudo -p 'sudo password: ' /etc/init.d/networking restart"
    servers: ["lucid"]
    [lucid] executing command
 ** [out :: lucid] * Reconfiguring network interfaces...
 ** [out :: lucid]

Advanced Tip
I set the following in ~/.caprc so I don’t get prompted for DNS servers and search path.

set :network_dns_nameservers, ''
set :network_dns_search_path, ''

Comments are closed.