我已经创建了一个变量来在我的主要任务集中禁用nginx中的网站。由于这是一次性任务,意味着一旦domain1.com被禁用,我可以评论整个行。当我这样做时,我收到一个错误当变量没有值时,有界循环
“{”failed“:true,”msg“:”字段'args'具有无效值,其中包含一个未定义的变量。错误是:“无”有没有属性“域””
我能做些什么来改变我的任务时,有变量中列出的域中运行仅
nginx_sites_disabled:
#- domain: "domain1.com"
- name: Disable sites
file:
path: /etc/nginx/sites-enabled/{{ item.domain }}
state: absent
with_items: "{{nginx_sites_disabled}}"
notify:
- Reload nginx
当我将此过滤器,启用站点文件夹被删除。 – GreenLion
@GreenLion不在我的答案。在这种情况下,如果您将空列表传递给with_items,则循环将被跳过。 –
使用您的示例应如何查看nginx_sites_disabled列表? nginx_sites_disabled:[]? – GreenLion