Ansible apt模块显示“;“更改项目”;当我不';我想没有
我正在尝试用Ansible安装Apache2。我有一个Apache的角色和处理程序 我的剧本(Ansible apt模块显示“;“更改项目”;当我不';我想没有,ansible,ansible-playbook,ansible-2.x,Ansible,Ansible Playbook,Ansible 2.x,我正在尝试用Ansible安装Apache2。我有一个Apache的角色和处理程序 我的剧本(site.yml)包含: --- - hosts: webservers remote_user: ansrun become: true become_method: sudo --- - name: Install Apache 2 apt: name={{ item }} update_cache=yes state=present with_items: - apa
site.yml
)包含:
---
- hosts: webservers
remote_user: ansrun
become: true
become_method: sudo
---
- name: Install Apache 2
apt: name={{ item }} update_cache=yes state=present
with_items:
- apache2
when: ansible_distribution == "Ubuntu"
- name: Enable mod_rewrite
apache2_module: name=rewrite state=present
notify:
- reload apache2
Ansible角色文件包含:
---
- hosts: webservers
remote_user: ansrun
become: true
become_method: sudo
---
- name: Install Apache 2
apt: name={{ item }} update_cache=yes state=present
with_items:
- apache2
when: ansible_distribution == "Ubuntu"
- name: Enable mod_rewrite
apache2_module: name=rewrite state=present
notify:
- reload apache2
每当我运行playbook时,我都会收到这条消息,但没有任何变化
changed: [10.0.1.200] => (item=[u'apache2'])
我认为这与条件有关。您遇到了一个引入到Ansible 2.2.0(并在2.2.1中修复)的问题
使用update\u cache=yes
时,apt
模块会在apt缓存更新发生时返回changed
-状态,而不仅仅是在实际软件包升级时
您需要将Ansible升级到2.2.1版(1月16日正式发布)
您需要执行以下操作之一:
- 将Ansible升级到至少2.2.1(当前处于发行候选状态,在PyPI中不可用,因此您必须)李>
- 降级至2.1.3李>
- 保留Ansible 2.2.0并将
任务分为两部分:安装Apache 2
- 一个仅用于缓存更新(当设置为false时,可能带有
已更改的\u)
- 一个用于实际的
包安装(不带apache2
),调用处理程序update\u cache=yes
- 一个仅用于缓存更新(当设置为false时,可能带有