The solution given with "my_list" is complaining of the below error:
>
>
> FAILED! => {"msg": "The task includes an option with an undefined
> variable. The error was: 'dict object' has no attribute 'results'\n\nThe
> error appears to be in
Guess we need to relook at this proposed code snippet:
my_list: "{{
hostvars['localhost'].command_result.results|map(attribute='stdout')|list
}}"
Something is still wrong.
On Friday, August 30, 2019 at 2:39:15 PM UTC+5:30, Vladimir Botka wrote:
>
> On Fri, 30 Aug 2019 01:22:08 -0700 (PDT)
> Mohtashim S <[email protected] <javascript:>> wrote:
>
> > - name: Play 2
> > hosts: remotehost
> > tasks:
> > - shell: "~/rollback.sh {{ Number }} '{{ InstallDir }}' '{{
> >
> hostvars[\"localhost\"][\"command_result\"].results|map(attribute=/'stdout/')|list
>
>
> > }}' > ~/rollback.log"
> >
> > I get runtime error executing shell which is of the nature below:
> >
> > fatal: [10.12.34.43]: FAILED! => {"msg": "template error while
> templating
> > > string: unexpected '/'. String: ~/rollback.sh {{ Number }} '{{
> InstallDir
> > > }}' '{{
> > >
> hostvars[\"localhost\"][\"command_result\"].results|map(attribute=/'stdout/')|list
>
>
> > > }}' > ~/rollback.log"}
>
> The problem is the string is shell. Try to create the parameters first.
> For
> example
>
> - set_fact:
> my_list: "{{ hostvars['localhost'].command_result.results|
> map(attribute='stdout')|list }}"
>
> - shell: "~/rollback.sh {{ Number }} '{{ InstallDir }}' '{{ my_list }}'
> > ~/rollback.log"
>
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/4c0c2c76-233f-434d-be26-ad567753c614%40googlegroups.com.