如何将with_items结果放入新任务-插件

时间:2019-07-10 23:28:06

标签: ansible

我需要将with_items结果从一项任务转移到另一项任务-我正试图获取stdout_lines结果以打印到另一项任务。

我正在从名为ironware_command的任务获取stdout_list

结果看起来像这样

  - |-  
    1/1/1    78a6.e129.1c60  78a6.e129.1c60  GigabitEthernet1/1/1    ICX7250-24  

    1/2/1    78a6.e113.b258  78a6.e113.b271  GigabitEthernet1/1/26   s2-223-rsb

然后正则表达式降到
 1/1/1
 1/2/1

,然后将列表结果传递给另一个名为iwronware_config的任务

行:
        -标签e接口1/1/1
        -标签e接口1/1/1

无论尝试哪种方式,我都会遇到多个错误

tasks:  
   - name: Show Neighbors to get lldp information
      ironware_command:
        provider: "{{ connection_settings }}"
        commands:
          - show lldp ne | include /               
      register: port_numbers
  ##create a variable for the stdout_lines that provide lldp neighbor ports
    - set_fact:
        port_numbers:  "{{ port_numbers.stdout_lines }}"       

 ##start loop and regex down to just 1/x/x 

    - name: loop through list     

      debug: msg="{{ item | regex_replace(' .*', '') }} "
      with_items: " {{ port_numbers }} "        

    - name: "Create Vlan and add to uplinks -"   
      ironware_config:
        provider: "{{ connection_settings }}"
        lines:          
        - tag e interface {{??}} ## I need 1/1/1 from with items      
        - tag e interface {{??}} ## I need 1/2/1 from with items
       # creating both lines is the end result - If i can get my loop passed into the task I can make it work. 

0 个答案:

没有答案