I've got an Ansible playbook that creates an AWS EC2 instance through a CloudFormation template. After it's created I would like to configure it also through Ansible.
Here is what I have now:
---
- name: Create Amazon Linux Instance
hosts: localhost
connection: local
gather_facts: no
vars_files:
- config.yml
tasks:
- name: Create CloudFormation Stack
cloudformation:
stack_name: "{{ stack_name }}"
state: present
template: basic-ec2-stack.json
template_parameters:
KeyName: "{{ key_name }}"
VpcId: "{{ vpc_id }}"
SubnetId: "{{ subnet_id }}"
...
register: stack
# The new instance name is in stack.stack_outputs.DnsName ...
- debug: var=stack.stack_outputs.DnsName
Now what? How can I run the rest of the playbook against the newly created host?
For example I would like to create user 'blah' but not on the localhost (against which the cloudformation module is running) but obviously on the new EC2 instance. How do I do that?
Thanks!