Skip to content

Instantly share code, notes, and snippets.

@myh-st
Forked from tbondarchuk/get_macs.yml
Created September 16, 2020 09:43
Show Gist options
  • Save myh-st/c042cfbba35605e725a4f65231730187 to your computer and use it in GitHub Desktop.
Save myh-st/c042cfbba35605e725a4f65231730187 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