Hello,
Has anyone found the correct syntax for launching a temporary ec2 instance
with Ansible, doing some config on it, then using the newly created ip
address of the ec2 instance in the
the host inventory.
This part is all good:
---
- name: Base-API-AMI | Create a Base-AMI for the API ECS Cluster
hosts: localhost
connection: local
gather_facts: False
tasks:
- name: check that env was passed in extra-vars
assert:
that: 'env is defined'
- include_vars: "{{ inventory_dir }}/vars/{{ env }}.yml"
- name: create Temporary Instance based on CentOS 7
ec2:
key_name: "{{ key_name }}"
instance_type: t2.micro
image: ami-d2c924b2
instance_tags:
name: dockerhost
wait: true
region: us-west-2
assign_public_ip: no
register: ec2
- debug: var=ec2
-------------- This part fails --------------------------------
- name: Add new instance to host group
add_host: hostname={{ item.public_ip }}
with_items: ec2.instances
----------- this pattern also fails
- name: change hosts inventory
hosts: launched
sudo: True
gather_facts: True
Thanks,
Bill
--
NOTICE TO RECIPIENT(S) OF INFORMATION: This message may contain information
that is proprietary or confidential to NeoCare Solutions or its
subsidiaries, and is for your use only. This message may also contain
Personally Identifiable Information or Protected Health Information,
including various kinds of information about specific medical or mental
health conditions, procedures, medications, etc. Disclosure of any such
information to anyone other than the recipient of this message is
restricted by Federal laws and regulations, State laws and regulations, or
both. Unless it is otherwise permitted by such laws and regulations, any
disclosure of this information requires the express written consent of the
person to whom it pertains. If you have received this message in error,
please notify the sender immediately by return e-mail and delete the
message and any attachments. Thank you.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/01361d5b-9268-4f3e-9882-f48d67389ff0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.