Select instance from dynamic inventory based on tag
ansible-playbook example.yml -e targetpractice=true
- name: targetpractice
hosts: tag_env_prod
gather_facts: false
roles:
- targetpractice
Runtime variables targetpractice=true
targetpractice=false
Find started/stopped instances with tag_env_prod
.
- If runtime variable
targetpractice=true
- instances state
started
- wait for instances to be reachable
- register instances to target group
- instances state
- If runtime variable
targetpractice=false
- unregister instances from to target group
- instances state
stopped
The Ansible ELB and EC2 start permission are granted to the ansible controller. I'll still need to be able to execute shell tasks on the remote instances, like normal. I want to pick hosts based on tags.
Edited by Bryan Black