I have a task that installs nvm and node. When installing node (i.e. nvm install v0.12.2), Ansible seems to think the machine state has been changed, even if that version of Node is already installed. When run from the command line when the version is already there, I get this:
$ nvm install v0.12.2
v0.12.2 is already installed.
Now using node v0.12.2 (npm v2.7.4)
I added the following to the task:
register: node_installed
changed_when: “‘is already installed’ is not in node_installed.stdout”
It never picked up and continued to reflect a change, perhaps because there are multiple lines in the output. However, when I debug: node_installed.stdout_lines I still only get the second line.
I didn’t expect that to generate an error, but after posting (unfortunately) I figured I should just inspect the whole variable and I found what you found. Punitive head slap for me.