Skip to content

Instantly share code, notes, and snippets.

@grrywlsn
Created July 6, 2016 00:00
Show Gist options
  • Save grrywlsn/f8e9800fb6fadc0ba963b70d20fcc15c to your computer and use it in GitHub Desktop.
Save grrywlsn/f8e9800fb6fadc0ba963b70d20fcc15c to your computer and use it in GitHub Desktop.
local.yml to set up a new image on first Ansible-Pull
---
- hosts: localhost
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: tag a resource
ec2_tag:
region: "{{ ansible_ec2_placement_region }}"
resource: "{{ ansible_ec2_instance_id }}"
tags:
Name: "{{ ec2_tags['tags']['aws:autoscaling:groupName'] }}.{{ ansible_ec2_instance_id }}"
- hostname: name="{{ ec2_tags['tags']['aws:autoscaling:groupName'] }}.{{ ansible_ec2_instance_id }}"
become: yes
become_user: root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment