From 0f26d71715b061d9307b55af64a73a4b0abbb30a 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 --- cloud/amazon/ec2_tag.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cloud/amazon/ec2_tag.py b/cloud/amazon/ec2_tag.py index e5aa866cc4d..3fd05dd4481 100644 --- a/cloud/amazon/ec2_tag.py +++ b/cloud/amazon/ec2_tag.py @@ -103,6 +103,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 }} + '''