每当我尝试在 ubuntu 上安装这样的包(例如)时;
- name: Install gcc
apt:
name: gcc
state: present
allow_unauthenticated: yes
register: aptout
不管 gcc 是否没有安装,我都会得到这个 aptout;
- debug:
msg: "Status is {{ aptout }}"
.
"msg": "Status is {'skipped': True, 'changed': False, 'skip_reason': u'Conditional check failed'}"
我想注册这个检查,这样如果已经使用
not aptout.changed
安装了包,我就可以跳过任务。和 aptout.changed
但它似乎没有正确注册变量。这在 redhat/centos 上运行良好,但无法解决 Ubuntu 的问题。
最佳答案
一切都按预期工作。
apt_out = { 'skipped': True,
'changed': False,
'skip_reason': u'Conditional check failed'}
Ansible 说您的任务尚未运行:
skipped: true
, 因为错误的条件(你为什么不把它包括在例子中?)。所以猜不到是
gcc
安装与否,因为它没有启动此任务。
关于ubuntu - apt-get 没有在 ansible 中注册变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41886236/