Centos ansible上的yum发行版同步

Centos ansible上的yum发行版同步,centos,ansible,centos7,yum,Centos,Ansible,Centos7,Yum,我正在使用Ansible(v2.1.2)配置CentOS 7计算机。为此,我需要确保在这台计算机上安装了存储库中给定包的可用版本,并在需要时安装和升级/降级包。我以前跑过 - name: install pkg package yum: name: "{{ pkg }}" state: latest 更改后的消息还将建议使用,但它似乎没有distro sync选项 是否有一种方法可以使它在没有更改时显示ok,而不是changed?您可以注册distro sync任务的标准输出

我正在使用Ansible(v2.1.2)配置CentOS 7计算机。为此,我需要确保在这台计算机上安装了存储库中给定包的可用版本,并在需要时安装和升级/降级包。我以前跑过

- name: install pkg package yum: name: "{{ pkg }}" state: latest 更改后的消息还将建议使用,但它似乎没有distro sync选项


是否有一种方法可以使它在没有更改时显示
ok
,而不是
changed

您可以注册distro sync任务的标准输出,并评估它在
更改时是否确实执行了任何操作

- name: sync pkg version with repo
  command: yum distro-sync -y "{{ pkg }}"
  register: yum
  changed_when: "'No Packages marked for Distribution Synchronization' not in yum.stdout"

我正在使用CentOS 6进行测试,因此“没有标记为分发同步的包”在您的系统上可能会有所不同。

您可以注册分发同步任务的标准输出,并评估它在
更改时是否确实执行了任何操作

- name: sync pkg version with repo
  command: yum distro-sync -y "{{ pkg }}"
  register: yum
  changed_when: "'No Packages marked for Distribution Synchronization' not in yum.stdout"
我正在使用CentOS 6进行测试,因此“没有标记为分发同步的包”在您的系统上可能会有所不同

- name: sync pkg version with repo
  command: yum distro-sync -y "{{ pkg }}"
  register: yum
  changed_when: "'No Packages marked for Distribution Synchronization' not in yum.stdout"