I want the task to run if the os if redhat (this conditional works fine) 
and when either of the following extended vars are set 
security/specified_packages/kernel. 

On Friday, June 30, 2017 at 2:17:29 AM UTC-4, Kai Stian Olstad wrote:
>
> On 29. juni 2017 23:00, ajay jiwanand wrote: 
> > I am having issues with using multiple conditions in when to validate 
> > whether or not to run a task. 
> > 
> > Basically I am using extrended variables within the ansible command to 
> > state what sort of updates I want to run like this: 
> > ansible-playbook site.yml -i inventory --ask-vault -u (username)-e 
> > "security=true restart=true" -k -K 
> > 
> > - name: Update all packages 
> >    yum: 
> >       name: "*" 
> >       state: latest 
> >       exclude: "kernel*" 
> >    when: security is not defined or kernel is not defined  or 
> > specified_packages is not defined and ansible_os_family == "RedHat" 
> > 
> > However I can not figure out a combination to get this conditional to 
> run 
> > properly. Everytime I run it the playbook continues to run the task when 
> I 
> > dont want it to. 
>
> When do you want the task to run? 
>
>
> > I already experimented with adding another variable to 
> > specify if I want to skip this task only but I would prefer it to 
> > automatically get skipped when I specify to run another type of update. 
> > 
> > I've tried the following: 
> > 
> >   (security is not defined or kernel is not defined  or 
> specified_packages 
> > is not defined) and (ansible_os_family == "RedHat") 
> >   (security is not defined or kernel is not defined  or 
> specified_packages 
> > is not defined) and ansible_os_family == "RedHat" 
> > 
> > or even: 
> > 
> > when: ansible_os_family == "RedHat" 
> > when: security is not defined or kernel is not defined  or 
> > specified_packages is not defined 
> > 
>
>
> -- 
> 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 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/d974214f-16ce-46ae-b4bd-7e75767ea6d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to