From 0fcc2d8973a3dbacc996f3c02fbbf032dc651f05 Mon Sep 17 00:00:00 2001 From: Bill W Date: Wed, 27 Apr 2016 00:51:36 +1000 Subject: [PATCH] =?UTF-8?q?Add=20more=20example=20on=20how=20to=20use=20mo?= =?UTF-8?q?dule=20ec2=5Ftags=20to=20list=20tags=20on=20an=20ins=E2=80=A6?= =?UTF-8?q?=20(#3530)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add more example on how to use module ec2_tags to list tags on an instance * Add more example on how to use module ec2_tags to list tags on an instance --- lib/ansible/modules/cloud/amazon/ec2_tag.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/ansible/modules/cloud/amazon/ec2_tag.py b/lib/ansible/modules/cloud/amazon/ec2_tag.py index 5fa6f484f8..9656e74c91 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_tag.py +++ b/lib/ansible/modules/cloud/amazon/ec2_tag.py @@ -107,6 +107,22 @@ tasks: with_subelements: - ec2_vol.results - volumes + +# Playbook example of listing tags on an instance +tasks: +- name: get ec2 facts + action: ec2_facts + +- name: list tags on an instance + ec2_tag: + region: "{{ ansible_ec2_placement_region }}" + resource: "{{ ansible_ec2_instance_id }}" + state: list + register: ec2_tags + +- name: list tags, such as Name, env if exist + shell: echo {{ ec2_tags.tags.Name }} {{ ec2_tags.tags.env }} + '''