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

标签 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.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/

相关文章:

linux - 用于在文件中生成任意大小的随机内容的命令

python - 编写一个在 ubuntu 终端上输入命令的 python 脚本?

ubuntu - Ansible:本地 .ansible 文件夹是以 root 为所有者创建的(权限错误)

ubuntu - 如何阻止 apt-get 询问有关使用少量额外磁盘空间的问题?

c++ - 语法说明

php - 在 ubuntu 16 中检查 php 版本时获取 2 个版本的 php

laravel - Ansible,从Docker容器运行命令时mysql连接被拒绝

list - 将列表转换为字典 - Ansible YAML

docker - Ubuntu 22 基础 docker 镜像上的 apt-get 更新失败

bash - 当我尝试 "sudo apt-get update"时出现错误