The droplet role

We need to make one change, the droplet role, which can be found at roles/droplet/tasks/main.yml; this change takes the dynamically assigned IP address and adds it to our droplets group of hosts. To do this, replace the following task:

- name: "print the IP address of the droplet" 
debug:
msg: "The IP of the droplet is {{ droplet_ip }}"

Replace it with the following task:

- name: add our droplet to a host group for use in the next step
add_host:
name: "{{ droplet_ip }}"
ansible_ssh_host: "{{ droplet_ip }}"
groups: "droplets"

As you can see, this takes the droplet_ip variable and adds a host using the add_host module to the group.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.9.236