Hi,
Is there anything cool I can do to change the IPs of 10 servers? Or
should I do it by hand?
Thanks,
James
Hi,
Is there anything cool I can do to change the IPs of 10 servers? Or
should I do it by hand?
Thanks,
James
DHCP?
No static IPs, just wondering if there was some way to build a
playbook around it, but probably not?
James
No static IPs, just wondering if there was some way to build a
playbook around it, but probably not?James
DHCP?
Hi,
Is there anything cool I can do to change the IPs of 10 servers? Or
should I do it by hand?Thanks,
James
For permanently changing the IPs, you could use the template module to
render the new IPs in the network configuration file of your distro.
Then you can run the distro's network scripts to 'restart' the network
interfaces with the new IPs.
For the latter, you could use an action invoking either the command
module or the service module if your distro provides proper init scripts
for network configuration.
So, edit ansible's inventory and for each host add a variable named
'new_ip' or similar, holding the new static IP.
Then, for each group of hosts with configuration files of same syntax,
write a template that uses the $new_ip variable. In your playbook, you would
then need a play for each host group, rendering the corresponding
template, and running the appropriate 'restart network' action.
You should also pay attention to the following things:
- Errors in your network configuration files could leave you without
remote access to the servers.
So, you should first make sure that your templates render ok and/or
possibly have second a route to the servers if something goes wrong.
- Ansible host inventory would need an update with the new addresses (if
not using dns names).
- DNS would also need updating after changing the IPs (and doing that
smoothly may not be so trivial as it may sound).
From an administration point of view, in most cases, moving your network
configuration to DHCP would make tasks such as changing IPs easier and
cleaner, since only changing the DHCP and master DNS server
configuration would be enough.
So, if you really want a cool and clean way to do what you want, move
all your hosts to DHCP, use DNS names in your ansible inventory (and
everywhere else), and write an ansible playbook that uses the template
module to create your DHCP/DNS configs from templates, possibly using
variables from ansible inventory or external variable files.
Hi,
These were static IPs and I did it manually but I should have done it
with a template. Since it just seems like it takes a long time to do
it on 12 machines at midnight :-).
Thanks for your responses.
James