如何解决使用元模块时剧本不退出
下面是我的 ansible playbook 的简短片段,所有注册的变量都在之前的任务中。现在元应该停止播放而不会出错,但在我的情况下,当条件“项目未定义”时,它在元语句中抛出错误,不确定是什么问题,因为我在调试中使用相同的语句它正常工作
---
- hosts: all
tasks:
- name: Import task
import_tasks: ~/vmware.yml
- debug:
msg: |
"The Datastore {{ disk_fact.guest_disk_info['0'].backing_datastore }} Capacity - {{ item.capacity / 1024 / 1024 / 1024 }} GB"
"The Datastore {{ disk_fact.guest_disk_info['0'].backing_datastore }} Free Space - {{ item.freeSpace / 1024 / 1024 / 1024 }} GB"
"The Datastore {{ disk_fact.guest_disk_info['0'].backing_datastore }} utilization {{ item.freeSpace / item.capacity * 100 }}"
"{{ item.freeSpace }}"
loop: "{{ info.datastores }}"
delegate_to: localhost
- name: Exit play if no space in Datastore
vars:
var1: "{{ item.freeSpace / 1024 / 1024 / 1024 }}"
loop: "{{ info.datastores }}"
meta: end_play
when: var1 < 100
delegate_to: localhost
这是我得到的输出
TASK [debug] *********************************************************************************************************
msg: |-
"The Datastore Local_DS_110 Capacity - 2228.0 GB"
"The Datastore Local_DS_110 Free Space - 106.205078125 GB"
"The Datastore Local_DS_110 utilization 4.76683474529"
"114036834304"
Read vars_file 'credentials.yml'
Read vars_file 'credentials.yml'
ERROR! The conditional check 'var1 < 100' failed. The error was: error while evaluating conditional (var1 < 100): {{ item.freeSpace / 1024 / 1024 / 1024 }}: 'item' is undefined
The error appears to be in '/root/satellite_content_sync/VMware_Linux_FS_extend/add_disk.yml': line 73,column 3,but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Exit play if no space in Datastore
^ here
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。