小编Nal*_*ore的帖子

将字符串附加到 Ansible 中的列表

我正在尝试将一个字符串附加到 ansible 中的列表中,所以基本上我将构建一个有效负载来删除 F5 GTM 网络设备中的一些拓扑记录。

我能够创建一个列表,其中包含相应拓扑记录的所有输出。对于输出的每一行,我需要附加一个字符串“删除”。

- name: Lookup Topology Records  
  bigip_command:
    user: admin
    password: password
    server: gtm.abc.com
    commands: "list gtm topology | grep -i '{{ item }}'"
    warn: no
    validate_certs: no
  register: topology_info
  delegate_to: localhost
  loop: "{{ gtm_pool }}"
  
- debug: var=topology_info
 
- name: Sanitize the Topology records of the Pool
  set_fact:
    clean_topology_info: "{{ clean_topology_info | default ([]) + item.stdout_lines  }}"
  loop: "{{ topology_info.results }}"
  
- debug: var=clean_topology_info
 
 
- name: Sanitized Topology Info
  vars:
    topology_item: "{{ item }}" …
Run Code Online (Sandbox Code Playgroud)

ansible

5
推荐指数
1
解决办法
3万
查看次数

标签 统计

ansible ×1