Skip to content

Instantly share code, notes, and snippets.

@askedrelic
Created August 15, 2017 08:22
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 askedrelic/873421f4fb30823c089763b1551aa28d to your computer and use it in GitHub Desktop.
Save askedrelic/873421f4fb30823c089763b1551aa28d to your computer and use it in GitHub Desktop.
Ansible snippets
- debug: var=another_fact
- name: Perform a rot13
debug: msg="The word {{ roman_name }} becomes {{ roman_name | rot13 }}"
- name: get hostvars for servers' ansible_default_ipv4
set_fact:
ip_list1: "{{ hostvars|fetchlistfromdict(groups.servers)|map(attribute='ansible_default_ipv4.address')|list }}"
- name: turn to FOO
debug: msg="{{'test'|foo}}"
- name: Show the list of ansible_default_ipv4
debug: var="{{ ip_list1 }}"
- name: Get the servers' ansible_all_ipv4_addresses
set_fact:
ip_list2: "{{hostvars|fetchlistfromdict(groups.servers)|map(attribute='ansible_all_ipv4_addresses')|list }}"
- name: Show the list we obtained for ansible_all_ipv4_addresses
debug: var="{{ip_list2}}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment