I am trying to install Apache2 with Ansible. I have a role and handler for Apache.
My playbook (site.yml
) contains:
---
- hosts: webservers
remote_user: ansrun
become: true
become_method: sudo
The Ansible role file contains:
---
- 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
Whenever I run the playbook, I get this message, but nothing has changed.
changed: [10.0.1.200] => (item=[u'apache2'])
I think this has something to do with the conditional.
You are running into a problem introduced to Ansible 2.2.0 (and fixed in 2.2.1).
With update_cache=yes
the apt
module was made to return changed
-status whenever APT cache update occurred, not only when the actual package was upgraded.
You need to upgrade Ansible to version 2.2.1 (released officially on Jan 16th)
You need to do one of the following:
Install Apache 2
task into two:
changed_when
set to false
),apache2
package installation (without update_cache=yes
), calling the handler.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With