Skip to content

Instantly share code, notes, and snippets.

@alloy-d
Created August 26, 2015 20:35
Show Gist options
  • Save alloy-d/5ff64d908ad092b086e4 to your computer and use it in GitHub Desktop.
Save alloy-d/5ff64d908ad092b086e4 to your computer and use it in GitHub Desktop.
Experimenting with getting a specific host's IP in Ansible
---
- name: "debug hosts"
hosts: "tag_ov_env_future"
tasks:
- name: "what is play_hosts?"
debug: var=play_hosts
# - name: "what are the variables for these hosts?"
# debug: "var=hostvars[item]['ec2_dns_name']"
# with_items: play_hosts
# when: hostvars[item]["ec2_tag_role"] == "media-queue"
- name: "let's find the media queue's IP"
local_action:
module: set_fact
media_queue_host: "{{ hostvars[item]['ec2_dns_name'] }}"
with_items: play_hosts
when: hostvars[item]["ec2_tag_role"] == "media-queue"
- name: "let's figure out if we figured it out"
local_action:
module: debug
var: media_queue_host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment