apt-get没有在ansible中注册变量

时间:2017-01-27 02:30:18

标签: ubuntu ansible apt-get

每当我尝试在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.changedaptout.changed安装软件包时可以跳过任务,但似乎没有正确注册变量。

这在redhat / centos上运行正常,但是无法弄清楚Ubuntu的问题。

1 个答案:

答案 0 :(得分:1)

一切都按预期工作。

apt_out = { 'skipped': True,
            'changed': False,
            'skip_reason': u'Conditional check failed'}

Ansible说您的任务尚未运行:skipped: true,因为条件错误(为什么不在示例中包含它?)。

因此无法猜测gcc是否已安装,因为它没有事件启动此任务。