Last active
February 12, 2021 15:04
-
-
Save tbondarchuk/570c36f0f05eb6c873cca8497379fec4 to your computer and use it in GitHub Desktop.
Ansible: Get mac addresses of all interfaces except local
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- 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