我有一个安装软件包的剧本,如果安装了软件包,则需要运行一个命令。我使用了register <variable>和<variable>.changed来做这件事,但是,除非我做错了,否则这在Ansible 2.0中似乎不起作用。这是我的代码。
- name: install syncthing (arch)
pacman: name=syncthing state=latest
when: ansible_distribution in ['Archlinux', 'Manjaro Linux']
register: syncthing
- name: enable syncthing
command: systemctl enable syncthing@jay.service
when: syncthing.changed第一个代码块安装了syncthing包,并给出了以下输出:
已更改: myhost
那么下一个块应该会执行,因为上一步注册了一个更改,但不幸的是,它没有:
跳过: 10.10.99.193
我希望有一个简单的解决方案,从我读到的文档和下面的帖子来看,我似乎是正确地这样做的:https://raymii.org/s/tutorials/Ansible_-_Only-do-something-if-another-action-changed.html
发布于 2016-03-13 14:07:47
- name: install syncthing (arch)
pacman: name=syncthing state=latest
when: ansible_distribution in ['Archlinux', 'Manjaro Linux']
register: syncthing
- name: enable syncthing
command: systemctl enable syncthing@jay.service
when: ansible_distribution in ['Archlinux', 'Manjaro Linux'] and syncthing is defined and syncthing.changedhttps://stackoverflow.com/questions/35382166
复制相似问题