Skip to content

Instantly share code, notes, and snippets.

@jamesdube
Created December 14, 2021 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesdube/c090dda20ab5340cd468af9eb5671db6 to your computer and use it in GitHub Desktop.
Save jamesdube/c090dda20ab5340cd468af9eb5671db6 to your computer and use it in GitHub Desktop.
Extract all ip's from an ansible group
- hosts: all
name: get group ips in one line
gather_facts: false
vars:
all_servers_ip: "{{groups['all'] | map('extract',hostvars,['ansible_ssh_host']) | join(',') }}"
tasks:
- debug:
msg: "{{all_servers_ip}}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment