首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >可能的寄存器和.changed不工作

可能的寄存器和.changed不工作
EN

Stack Overflow用户
提问于 2016-02-14 00:14:49
回答 1查看 5.1K关注 0票数 1

我有一个安装软件包的剧本,如果安装了软件包,则需要运行一个命令。我使用了register <variable><variable>.changed来做这件事,但是,除非我做错了,否则这在Ansible 2.0中似乎不起作用。这是我的代码。

代码语言:javascript
复制
- 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

EN

回答 1

Stack Overflow用户

发布于 2016-03-13 14:07:47

代码语言:javascript
复制
- 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.changed
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35382166

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档