· 8 years ago · Feb 05, 2018, 01:30 AM
1
2 - name: Run my CloudFormation stack
3 cloudformation:
4 access_key: "{{ ec2_access_key }}"
5 secret_key: "{{ ec2_secret_key }}"
6 #cloudformation allows stack_name to have - but not _
7 stack_name: pub-web01-stack
8 region: "{{ ec2_region }}"
9 # If state is "present", stack will be created. If state is "present" and if stack exists and template has changed, it will be updated. If state is "absent", stack will be removed.
10 state: "present"
11 template: "cloudfront.template"
12 #keyname = I should also pass in the ubuntu_image
13 template_parameters:
14 KeyName: ec2_mykey_temp
15 InstanceType: t2.nano
16 SSHLocation: 0.0.0.0/0
17 tags:
18 name: pub_web01_stack
19 env: dev
20 role: web
21 app: public_website
22 register: pub_web01_stack
23
24 - debug:
25 #msg: "{{ pub_web01_stack.stack_resources }}"
26 msg: "{{ pub_web01_stack.stack_resources | selectattr('logical_resource_id', 'equalto', 'IPAddress') | list.0.physical_resource_id }}"
27
28PLAY [Provision instances in AWS] ******************************************************************************************************************************************************************************
29
30TASK [Create a key] ********************************************************************************************************************************************************************************************
31ok: [localhost]
32
33TASK [write the key to a file] *********************************************************************************************************************************************************************************
34skipping: [localhost]
35
36TASK [Get the ubuntu trusty hvm ssd AMI] ***********************************************************************************************************************************************************************
37ok: [localhost]
38
39TASK [Run my CloudFormation stack] *****************************************************************************************************************************************************************************
40ok: [localhost]
41
42TASK [debug] ***************************************************************************************************************************************************************************************************
43fatal: [localhost]: FAILED! => {"msg": "template error while templating string: expected token 'name', got 'integer'. String: {{ pub_web01_stack.stack_resources | selectattr('logical_resource_id', 'equalto', 'IPAddress') | list.0.physical_resource_id }}"}
44 to retry, use: --limit @/vagrant/ansible_aws/playbooks/spin_up_cloudfront.retry
45
46PLAY RECAP *****************************************************************************************************************************************************************************************************
47localhost : ok=3 changed=0 unreachable=0 failed=1
48
49vagrant@vagrant-ubuntu-trusty-64:/vagrant/ansible_aws/playbooks$