Reputation: 47
So I have the following tasks in my playbook
- 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
Is there anyway to extract a list with all packages which contain the string fence-agents
?
I don't want to loop the entire package list as it would increase the playbook run time significantly.
Upvotes: 0
Views: 51
Reputation: 12124
Q: "Is there anyway to extract a list with all packages which contain the string fence-agents
?"
An approach based on the given question example
- debug:
msg: "{{ ansible_facts.packages[item] }}"
loop: "{{ ansible_facts.packages | select('search', regex) }}"
vars:
regex: 'fence-agents*'
Similar Q&A
Upvotes: 2