On Tuesday, 4 December 2018 17:17:37 CET shaneoh1980 McP wrote:
> This is the playbook:
>
> - hosts: webservers
> remote_user: ubuntu
> tasks:
> - name: create an ami
> ec2_ami:
> region: eu-west-2
> instance_id: i-077xxxxxxxxxxx
> name: "{{ inventory_hostname }}-{{
> ansible_date_time.iso8601_basic_short }}"
> tags:
> Name: "{{ inventory_hostname }}-{{
> ansible_date_time.iso8601_basic_short }}"
> register: ami
>
>
> - name: set ami id
> set_fact:
> new_ami_id: "{{ ami.results[0].image_id }}"
>
>
> - pause:
> seconds: 60
>
>
> - name: copy AMI to a different region
> ec2_ami_copy:
> source_region: eu-west-2
> source_image_id: "{{ new_ami_id }}"
> name: "{{ new_ami_id }}"
> region: eu-west-1
>
> And the full output:
>
> ansible-playbook 2.6.4
> config file = /etc/ansible/ansible.cfg
> configured module search path = [u'/home/ubuntu/.ansible/plugins/modules',
> u'/usr/share/ansible/plugins/modules']
> ansible python module location = /usr/lib/python2.7/dist-packages/ansible
> executable location = /usr/bin/ansible-playbook
> python version = 2.7.15rc1 (default, Nov 12 2018, 14:31:15) [GCC 7.3.0]
> Using /etc/ansible/ansible.cfg as config file
> [WARNING]: Ignoring invalid attribute: new_ami_id
This WARNING is the hint, you indentation of new_ami_id in set_fact is missing
two spaces.
--
Kai Stian Olstad
--
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/2114653.Un4kkQZlBQ%40x1.
For more options, visit https://groups.google.com/d/optout.