I am trying to achieve the following:
- Create ec2 instance (play 1)
- Configure some services (play 2)
- Download some iso from my s3 bucket to the ec2 instance (sql, etc)
- Install
I have a play with hosts set to localhost to create ec2 instance. Its working fine.
- name: infrastructure setup
hosts: localhost
gather_facts: no
vars_files:
- testcfg.yml
tasks:
- ec2:
…
register: ec2_result
- name: add hosts to group
add_host:
…
group: windows
with_items: “{{ ec2_result.instances }}”
the second play uses hosts: windows (the host group that I created in previous play) to configure windows services. Its working fine as well
- name: Server Setup Play
hosts: windows
vars_files:
- testcfg.yml
gather_facts: false
tasks:
- win_feature:
name: AS-Web-Support
now, I want to download a file from S3 into this ec2 instance. This is where I am having problem. What I have figured out (rightly or wrongly) is that I have to create a new play with hosts=localhost, otherwise if I stay within the previous play, the command will execute remotely over winrm which I don’t want to do. If I create a new play with hosts=localhost, how can I tell aws_s3 what my destination will be?
- name: S3 Play
hosts: localhost
vars_files:
- testcfg.yml
gather_facts: false
tasks:
- name: get sql iso from s3 to the newly created server
aws_s3:
region: ‘{{ region }}’
bucket: “{{ bucket }}”
object: …
dest: ???