Skip to content

Instantly share code, notes, and snippets.

@tbondarchuk
Last active February 12, 2021 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save tbondarchuk/570c36f0f05eb6c873cca8497379fec4 to your computer and use it in GitHub Desktop.
Save tbondarchuk/570c36f0f05eb6c873cca8497379fec4 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 }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment