Ansible regex_findall 多套

Ansible regex_findall multiple sets

我正在尝试使用 Ansible 从 IOS 设备收集数据,然后将收集到的数据用于 运行 任务。

我正在 运行ning 任务执行 show 运行ning-config 命令以查找具有特定描述的接口:

- name: get current running-config
  ios_command:
    host: "{{ inventory_hostname }}"
    commands:
      - show running-config | i interface|description
  register: config  

该任务的输出:

interface GigabitEthernet1/0/35
 description TEST PHONE
interface GigabitEthernet1/0/36
 description TEST PHONE
interface GigabitEthernet1/0/37
 description *W137
interface GigabitEthernet1/0/38
 description *W138
interface GigabitEthernet1/0/39
 description *W139
interface GigabitEthernet1/0/40
 description *W140

我希望获取描述以 * 开头的所有接口 name/number。我正在使用 set_fact 从 regex_findall():

- name: get current interfaces with special description
  set_fact: noAuthInts="{{ config.stdout[0] | regex_findall('(.*?)\n description \*(.*)')}}"

正则表达式工作正常并从两组中获取数据。输出显示为:

msg": [
            [
                "interface GigabitEthernet1/0/37",
                "W137"
            ],
            [
                "interface GigabitEthernet1/0/38",
                "W138"
            ],
            [
                "interface GigabitEthernet1/0/39",
                "W139"
            ],
            [
                "interface GigabitEthernet1/0/40",
                "W140"
            ],
            [
                "interface GigabitEthernet1/0/41",
                "W141"
            ],
            [
                "interface GigabitEthernet1/0/42",
                "W142"
            ],
            [
                "interface GigabitEthernet1/0/43",
                "W143"
            ]
        ]

我不知道如何获取该列表中的两项并分别使用它们。我想 运行 一个带有 ios_config 的任务来配置来自该列表的接口 name/number 的接口,并使用我收集的描述。

这是嵌套列表吗?我尝试了不同的变体,如:

noAuthInts.0 或 noAuthInts.0.0 和 noAuthInts.0.1,但不会生成我要查找的内容。

我也尝试过使用 with_nested: "{{ noAuthInts }}" 并遍历它,但似乎没有正确循环。

如何从该列表中取出这两个部分并分别使用它们?

我能够使用 with_list 而不是 with_itemswith_nested。现在可以正常使用列表列表。引用了我的另一个post: