Skip to content
Snippets Groups Projects
Commit 6a80b013 authored by jurgenhaas's avatar jurgenhaas
Browse files

Allow the definition of the IP when creating a new host

parent a79b2f60
No related branches found
No related tags found
No related merge requests found
......@@ -26,18 +26,22 @@
state: running
wait: yes
- name: "Add new instance(s) to the inventory"
add_host:
hostname="{{ host }}"
static_ipv4="{{ item.public_ip }}"
groups="{{ initgroups }}"
with_items: '{{ ec2.instances }}'
- block:
- name: "Associate an elastic IP with the new instance"
ec2_eip:
device_id: "{{ item }}"
public_ip: '{{ inithostip }}'
region: "{{ ec2_region }}"
state: present
with_items: '{{ ec2.instance_ids }}'
- include: inithostip.yml hostip='{{ inithostip }}'
when: inithostip is defined
- name: "Waiting for SSH service becoming available"
wait_for:
host="{{ item.public_ip }}"
port=22
delay=10
timeout=120
state=present
- include: inithostip.yml hostip='{{ ec2instance.public_ip }}'
with_items: '{{ ec2.instances }}'
loop_control:
loop_var: ec2instance
when: inithostip is not defined
---
# file: ec2/inithostip.yml
- name: "Add new instance(s) to the inventory"
add_host:
hostname="{{ host }}"
static_ipv4="{{ hostip }}"
groups="{{ initgroups }}"
- name: "Waiting for SSH service becoming available"
wait_for:
host="{{ hostip }}"
port=22
delay=10
timeout=120
state=present
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment