Jinja ansible ixgbe Module abfragen
Verfasst: Donnerstag 10. November 2016, 13:56
Moin,
Ich würde gerne über die Ansible facts herausfinden, welche interface das Modul ixgbe haben.
Dafür möchte ich durch das Ansible array ansible_interfaces durchgehen um die Namen aller Interface herauszufinden. Anschließend soll das array ansible_interfacename durchgegangen werden in denen das Modul steht.
Ich habe bereits folgenden Code mir erarbeittet:
Hello all.
I want to find all interfaces which have the module ixgbe.
Therefor i want to use the ansible facts.
In the facts i have a list of all the interfaces as an array in the variable ansible_interfaces. Now i want to use the name of this interfaces with an "ansible_" before. Than they have to look in the module whre ixgbe is defined or not defined. So for the eth0 interface it should show me the output of ansible_eth["module"]. I already have the following code:
{% for i in ansible_interfaces %}
{% set x = 'ansible_%s' |format (i) |replace ("-", "_")%} Das replace wird gebraucht weil es unter ansible_interfaces variablen mit - gibt die später mit eniem _ verwendet werden.
{% if [x["module"]] is defined %}
{{x}}
{{[(x["module"])]}}
{{(ansible_eth0["module"])}}
{%endif%}
{% endfor %}
Daraus bekomme ich diesen Output:
ansible_br_config
[Undefined]
ixgbe
ansible_eth5
[Undefined]
ixgbe
ansible_eth4
[Undefined]
ixgbe
ansible_eth3
[Undefined]
ixgbe
ansible_eth2
[Undefined]
ixgbe
ansible_eth1
[Undefined]
ixgbe
ansible_eth0
[Undefined]
ixgbe
Ich hoffe ihr versteht was ich meine und könnt mir helfen. Vielen dank schon mal im vorraus.
Ich würde gerne über die Ansible facts herausfinden, welche interface das Modul ixgbe haben.
Dafür möchte ich durch das Ansible array ansible_interfaces durchgehen um die Namen aller Interface herauszufinden. Anschließend soll das array ansible_interfacename durchgegangen werden in denen das Modul steht.
Ich habe bereits folgenden Code mir erarbeittet:
Hello all.
I want to find all interfaces which have the module ixgbe.
Therefor i want to use the ansible facts.
In the facts i have a list of all the interfaces as an array in the variable ansible_interfaces. Now i want to use the name of this interfaces with an "ansible_" before. Than they have to look in the module whre ixgbe is defined or not defined. So for the eth0 interface it should show me the output of ansible_eth["module"]. I already have the following code:
{% for i in ansible_interfaces %}
{% set x = 'ansible_%s' |format (i) |replace ("-", "_")%} Das replace wird gebraucht weil es unter ansible_interfaces variablen mit - gibt die später mit eniem _ verwendet werden.
{% if [x["module"]] is defined %}
{{x}}
{{[(x["module"])]}}
{{(ansible_eth0["module"])}}
{%endif%}
{% endfor %}
Daraus bekomme ich diesen Output:
ansible_br_config
[Undefined]
ixgbe
ansible_eth5
[Undefined]
ixgbe
ansible_eth4
[Undefined]
ixgbe
ansible_eth3
[Undefined]
ixgbe
ansible_eth2
[Undefined]
ixgbe
ansible_eth1
[Undefined]
ixgbe
ansible_eth0
[Undefined]
ixgbe
Ich hoffe ihr versteht was ich meine und könnt mir helfen. Vielen dank schon mal im vorraus.