The problem is that {{ ansible_eth0.macaddress }} doesn't always report the 
hardware macaddress.

I described this specific issue in my initial post.

For example, if eth0 is part of bond/link-aggregation-group, Ansible 
returns the macaddress of the bond/LAG, NOT the macaddress of the eth0 
interface itself.

Facter apparently obtains the macaddress another way, which in my 
experience returns the actual macaddress, not the macaddress of the bond....

So that is my question.

How can I get Ansible itself to return the actual macaddress, or do I 
always have to just use Facter?





On Tuesday, January 31, 2017 at 4:35:25 AM UTC-8, Klaus Ethgen wrote:
>
> Don Jackson <[email protected] <javascript:>> schrieb: 
> > I am transitioning my network interface provisioning to be based on 
> actual 
> > hardware/NIC macaddresses rather than trying to use device names like 
> ethN 
> > that seem to be inconsistent between different servers and are often 
> > different on each OS distribution 
> > 
> > I ran into an issue where Ansible reported the macaddress of a bond 
> member 
> > as the macadress of the bond itself, which is not what I need/want. 
> > 
> > I am able to work around the issue by installing Facter and using 
> something 
> > like: 
> > 
> > 
> hostvars[inventory_hostname]['facter_networking']['interfaces'][item].mac 
>
> {{ ansible_eth0.macaddress }} 
>
> If you need to iterate over the interfaces, you have to use: 
>
> {{ hostvars[inventory_hostname]['ansible_' + item]['macaddress'] }} 
>
> See also [0]. 
>
> [Removing all unreadable HTML crap] 
>
> Regards 
>    Klaus 
>
> [0] 
> https://docs.ansible.com/ansible/faq.html#how-do-i-access-a-variable-name-programmatically
>  
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/827b5a0a-8867-4938-9014-d9d000f9f022%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to