That's too bad because I don't have the mac address before I need to read 
its attributes.  How might a person get a list of the mac addresses 
associated with the interfaces?

Thanks for the info.
Chris.

On Thursday, March 7, 2019 at 9:19:11 AM UTC-8, Kai Stian Olstad wrote:
>
> On 05.03.2019 21:38, Chris Jefferies wrote: 
> > I can drill down into hostvars like this: 
> > 
> >      - debug: 
> >          msg: "looking at interface macs: {{ 
> > hostvars[inventory_hostname].facter_ec2_metadata.network.interfaces.macs 
> }}" 
> > 
> > 
> > And I get something like this: 
> > 
> > 
> > ok: [db01.deva.ecm] => { 
> >      "msg": "looking at interface macs: {u'xx:xx:xx:xx:xx:xx': 
> > {u'local-hostname': u'ip-10-1-1-9.us-west-1.compute.internal', 
> > u'security-groups': u'sg_me', u'vpc-ipv4-cidr-blocks': u'10.1.0.0/16', 
> > u'subnet-id': u'subnet-009ae259d26e44f23', u'vpc-ipv4-cidr-block': 
> > u'10.1.0.0/16', u'interface-id': u'eni-0f706387a1423f329', u'mac': 
> > u'xx:xx:xx:xx:xx:xx, u'security-group-ids': u'sg-034d209d935486e41', 
> > u'local-ipv4s': u'10.1.1.10', u'owner-id': u'784710449476', 
> > u'subnet-ipv4-cidr-block': u'10.1.1.0/24', u'device-number': u'0', 
> > u'vpc-id': u'vpc-1710943aba582459a'}}" 
> > } 
> > 
> > 
> > 
> > 
> > I get an error if I try to find the first/only mac address with the [0] 
> > approach like this: 
> > 
> > {{ 
> hostvars[inventory_hostname].facter_ec2_metadata.network.interfaces.macs[ 
> > 0] }} 
> > 
> > 
> > or 
> > 
> > {{ 
> hostvars[inventory_hostname].facter_ec2_metadata.network.interfaces.macs. 
> > 0 }} 
> > 
> > 
> > What's the trick to get to the values within the mac address? 
> > 
> > Any tips would be appreciated,  thanks, 
>
> macs is a dict and not a list. Therefor using 0 to get the fist list 
> element wont work. 
>
> To get information out of a dict you need to use the key which is the mac 
> address in you case. 
>
>
> -- 
> Kai Stian Olstad 
>

-- 
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/610e4394-8e6b-4f12-acb2-5b60e51646b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to