我有一个简单的剧本,并返回如下所示的可用更新程序包名称。我想过滤以特定字母开头的输出示例,以使软件包名称以“ n”字母开头。任何想法将不胜感激:-)
---
- name: yum list updates
hosts: all
tasks:
- name: get updates list
yum:
list=updates
register: yum
- name: set fact
set_fact:
package_name: "{{ yum.results | map(attribute='name')| list }}"
答案 0 :(得分:0)
尝试
package_name: "{{ yum.results|selectattr('name', 'search', '^n')|list }}"
(未经测试)