Greetings,
I'm running into unexpected behavior when trying to use a when_changed statement to trigger an immediate service reload if a change is made. We wanted to do this instead of doing a flush_handlers to avoid impacting the timing handlers that were triggered by other plays.
The following set of tasks in a role:
---
- name: Add the PostgreSQL user.
postgresql_user:
login_user: postgres
name: stuff
password: password_here
role_attr_flags: CREATEDB
state: present
sudo_user: postgres
- name: Make the PostgreSQL stuff user allow password auth.
lineinfile:
create: yes
dest: /etc/postgresql/9.3/main/pg_hba.conf
line: "local all stuff md5"
regexp: "local\\s+all\\s+(stuff|all)\\s+(peer|md5)"
state: present
register: result
- name: Reload PostgreSQL if permissions have changed.
service:
name: postgresql
status: reloaded
when_changed: $result
-----------------------
When the middle play runs, it generates this output:
TASK: [Make the PostgreSQL stuff user allow password auth.] ******************
changed: [33.33.33.100] => {"changed": true, "item": "", "msg": "line replaced"}
After that, we get the following error:
TASK: [Reload PostgreSQL if permissions have changed.] ************************
fatal: [33.33.33.100] => Conditional expression must evaluate to True or False: is_changed($result)
FATAL: all hosts have already failed -- aborting
As best I can tell, we're calling when_changed appropriately. Does anyone have insight into what we're doing wrong, or a reason why doing this action this way instead of through a handler would be incorrect?