I see where the issue was. With the when: conditional, doesn't use the
brackets and quotes for referencing. It's just the variable name itself.
Yea, you're right, the place where I defined my when: variable was in the
wrong module and not under task. It's working now. Thanks!
On Wednesday, September 27, 2017 at 3:28:15 PM UTC-4, Kai Stian Olstad
wrote:
>
> On 27. sep. 2017 21:10, Dave Florek wrote:
> > Thanks Kai. For some reason, when I run my playbook though, the Ansible
> > doesn't like how the when: conditional is structured
> >
> > when: new_user != "root"
>
> This when check if the variable new_user not equal to the string root
>
>
> > *fatal: [192.168.1.5]: FAILED! => {"changed": false, "failed": true,
> > "invocation": {"module_args": {"name": "dave3", "when": "new_user !=
> > \"root\""}, "module_name": "user"}, "msg": "unsupported parameter for
> > module: when"}*
> >
> > I don't see too many examples where a variable is invoked by when: so,
> I'm
> > not sure if the syntax somehow is wrong. I tried specifying it as a list
> as
> > well, but that had no effect:
>
>
> Most when is using variables, and for the Ansible docs about conditional
> you posted has several (actually all of them has at least one variable)
>
> But you error messages indicate wrong indentation of when.
> This would be easier if you showed your code and not just the error, but
> if you look at the link you posted you'll see when is indentation must
> be at the same level as the module name.
>
>
> --
> Kai Stian Olstad
>
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/1152788a-7381-496b-b667-26a3f2769d69%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.