0

I am new to ansible and I am trying to execute a very simple playbook : assign a static IP address to a centos7 machine I just cloned in Virtualbox.

I am starting from scratch as I surprisingly haven't found a simple playbook (accessible to new comers)

I found this post recommended way to configure a centos-7 network interface with static settings via ansible but the answer given doesn't make sense to me.

I tried a couple of options, regex into /etc/sysconfig/network-scripts/ifcfg-enp0s3 and change IPADDR there, or use nmcli to do it, but I am ending with errors as I am not familiar enough with ansible's syntax (I am using Yaml).

what I am trying to achieve is to have a playbook I can call and I would just give the hostname and IP address as arguments:

ansible-playbook site.yml -i hosts.ini --extra_vars "ansible_ssh_host=<ip_address_of_newly_installed_host>" --limit <ansible_hostname_from_inventory>

just so I could call any host from this inventory file and reset the IP address to what I want:

cat hosts
[image]
centos ansible_host=192.168.10.2 ansible_user=root

[masters]
master ansible_host=192.168.10.3 ansible_user=root

[workers]
worker1 ansible_host=192.168.10.4 ansible_user=root
worker2 ansible_host=192.168.10.5 ansible_user=root

Thank you kindly for your help, much appreciated.

Bluz
  • 101
  • 1

0 Answers0