Trying to use previous task output to new task to modify one file, But it is throwing error variable not defined

Hi,

I am trying to use previous task output to new task to modify one file, But it is throwing error variable not defined -

x only exists for host4, in the context of host3 it does not, you need to do:

{{hostvars['host4']['x']['stdout']}}

Thanks Brian,

Its working.

as I am using Ansible version 2.2 so I used " instead of ’ -

{{hostvars[“host4”][“x”][“stdout”]}}

Thanks once again :slight_smile:

Br//Sudhanshu