I'm trying to unify the way I install packages, I have the following 
vars/main.yml:
---
packages:
  system:
    common:
      - crudini
      - dump
      - duplicity
      - git
      - mdadm
      - irssi
      - lynx
      - postfix
      - powerline
      - rsync
      - tmux
      - vim
    Debian:
      - ntp
    Fedora:
      - langpacks-en
      - langpacks-nl
      - livecd-tools
      - rktime
      - tmux-powerline
      - tuned
      - vim-powerline

And the following task:
- block:
  - name: install ansible dependencies
    package: name={{ item }} state=present
    with_flattened:
      - "{{ packages.system.common }}"
      - "{{ packages.system.Fedora }}"
      - "{{ vars['packages.system.' + ansible_distribution] }}"
  when: ansible_distribution == "Fedora"
  tags:
    install_custom2

Which results in the following error:
TASK [common : install ansible dependencies] 
*******************************************************************************************
fatal: [host]: FAILED! => {"msg": "'dict object' has no attribute 
u'packages.system.Fedora'"} 

Please note that the "{{ packages.system.Fedora }}"  works fine but the "{{ 
vars['packages.system.' + ansible_distribution] }}" fails (which expands to 
packages.system.Fedora as well). It looks like a type error. When I 
organize the package names in vars/main.yml as separate lists, it does 
work. But I would like to create this dictionary structure since it 
organizes the variables nicely. Is there a way to expand dictionary 
variables dynamically just like list variables?

-- 
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/a9b6703c-73bc-472e-8b82-9d7158e62a48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to