It looks like you need to inspect `node_installed.stderr` instead of
`stdout`. The string you are looking for seems to go there instead.

ok: [localhost] => {
    "changed": false,
    "foo": {
        "_ansible_no_log": false,
        "changed": true,
        "cmd": ". /Users/matt/.nvm/nvm.sh && nvm install v0.12.2",
        "delta": "0:00:04.243197",
        "end": "2015-10-16 09:41:08.582763",
        "rc": 0,
        "start": "2015-10-16 09:41:04.339566",
        "stderr": "v0.12.2 is already installed.",
        "stdout": "Now using node v0.12.2 (npm v2.7.4)",
        "stdout_lines": [
            "Now using node v0.12.2 (npm v2.7.4)"
        ],
        "warnings": []
    }
}

-- 
Matt Martz
@sivel
sivel.net

On Fri, Oct 16, 2015 at 8:51 AM, Rob Wilkerson <r...@robwilkerson.org> wrote:

> 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.
>
> What am I missing?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/bbec1bd5-6a19-4d69-b8e4-0657af9d9b70%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/bbec1bd5-6a19-4d69-b8e4-0657af9d9b70%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v-o%3D2dfLefS-9X%2BaDSYVxoS3OKBhEzYAGP2e_q0XDy_Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to