GithubHelp home page GithubHelp logo

akhmel / ansible-aws-tags Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bwits/ansible-aws-tags

0.0 2.0 0.0 13 KB

Ansible module to get aws ec2 instances tags

License: Apache License 2.0

Python 100.00%

ansible-aws-tags's Introduction

Ansible module to get aws ec2 instances tags

The output from this module is a bunch of Ansible facts

Tested in Ansible 2.0.1+

module: aws_tags
short_description: Return ec2 instance tags
description:
   - Given an instance id and its region, return its tags, such as Name, etc.
version_added: "1.0"
author: Bill Wang
requirements:
  - none
options:
  instance_id:
    required: true
    description:
      - ec2 instance id
  region:
    required: true
    description:
      - aws region

outputs

Tag fact keys are renamed to ansible_ec2_instance_TAGS. For example, if this ec2 instance has two tags: Name and UUID. The output fact keys will be changed to ansible_ec2_tag_Name and ansible_ec2_tag_UUID

###Examples

   # save aws_tags.py to library folder

   # usage
   $ cat roles/common/tasks/main.yml
   
   - action: aws_tags instance_id=i-ac13f01d region=us-west-2

###Best practice

Suppose when you created the instances, assign IAM role with AmazonEC2ReadOnlyAccess policy.

aws_tags module works perfect with ansible ec2_facts module

- name: get ec2 facts
  action: ec2_facts

- name: get instance tags
  action: aws_tags instance_id={{ ansible_ec2_instance_id }} region={{ ansible_ec2_placement_region }}
  
- name: export aws_tags
  command: echo {{ ansible_ec2_tag_Name }}

ansible-aws-tags's People

Contributors

ozbillwang avatar russelzoss avatar

Watchers

James Cloos avatar Andrey avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.