所以我的剧本中有以下任务
- name: gather package facts
package_facts:
- name: send packages containing 'fence-agents' to a file
lineinfile:
path: /etc/leapp/transaction/to_remove
line: "{{ item }}"
loop: "{{ ansible_facts.packages | ???????"
become: true
是否有办法提取包含字符串“fence-agents”的所有包的列表?我不想循环整个包列表,因为它会显着增加剧本的运行时间。
问:“有没有办法提取包含字符串
fence-agents
的所有包的列表?”
- debug:
msg: "{{ ansible_facts.packages[item] }}"
loop: "{{ ansible_facts.packages | select('search', regex) }}"
vars:
regex: 'fence-agents*'
类似问答