Skip to content

Instantly share code, notes, and snippets.

@nxtreaming
Forked from tbondarchuk/get_macs.yml
Created May 3, 2019 07:58
Show Gist options
  • Save nxtreaming/d75f4901c51e153f0e3991701945ad68 to your computer and use it in GitHub Desktop.
Save nxtreaming/d75f4901c51e153f0e3991701945ad68 to your computer and use it in GitHub Desktop.
Ansible: Get mac addresses of all interfaces except local
---
- hosts: all
tasks:
- name: Get mac addresses of all interfaces except local
debug:
msg: "{{ ansible_interfaces | difference(['lo']) | map('regex_replace', '^(.*)$', 'ansible_\\1' ) | map('extract', hostvars[inventory_hostname], 'macaddress') | list }}"
@nxtreaming
Copy link
Author

"{{ ansible_interfaces | difference(['lo']) | map('regex_replace', '^(.*)$', 'ansible_\1' ) | map('extract', hostvars[inventory_hostname], 'macaddress') | list | replace(':', '-') }}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment