I've done it by having two lists in group vars files and doing a group_by

On Friday, December 11, 2015 at 9:11:16 AM UTC-8, Marc Abramowitz wrote:
>
> Take this playbook:
>
> - hosts: mt1-dummys101
>   tasks:
>     - name: Install apt packages
>       sudo: true
>       apt: pkg={{ item }}
>       with_items:
>         - build-essential
>         - libyaml-dev
>         - python2.7-dev
>         - "{{ 'silversearcher-ag' if ansible_distribution_major_version == 
> '14' else '' }}"
>
> How would I make it so that silversearcher-ag is installed only on Ubuntu 
> 14 and is omitted for other operating systems?
>
> The above gives:
>
> TASK: [Install apt packages] 
> **************************************************
> failed: [mt1-dummys101] => 
> (item=build-essential,libyaml-dev,python2.7-dev,) => {"failed": true, 
> "item": "build-essential,libyaml-dev,python2.7-dev,"}
> msg: No package matching '' is available
>
> I also tried changing the empty string `''` to `omit` but that also fails:
>
> TASK: [Install apt packages] 
> **************************************************
> failed: [mt1-dummys101] => 
> (item=build-essential,libyaml-dev,python2.7-dev,__omit_place_holder__07ef1633a8f8d1dc718ffb780b3f0e54d7f7b02a)
>  
> => {"failed": true, "item": 
> "build-essential,libyaml-dev,python2.7-dev,__omit_place_holder__07ef1633a8f8d1dc718ffb780b3f0e54d7f7b02a"}
> msg: No package matching 
> '__omit_place_holder__07ef1633a8f8d1dc718ffb780b3f0e54d7f7b02a' is available
>
> Any way to do this?
>

-- 
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/771578e8-a31c-44fa-82b7-70077a19a77d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to