-
-
Save nxtreaming/d75f4901c51e153f0e3991701945ad68 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
"{{ ansible_interfaces | difference(['lo']) | map('regex_replace', '^(.*)$', 'ansible_\1' ) | map('extract', hostvars[inventory_hostname], 'macaddress') | list | replace(':', '-') }}"