How to handle package manager depending installations?

Hi,

I would like to know how to organize one task that I can install packages depending on the ansible_pkg_mgr variable?
Could you please provide an example, if possible?

Please note: I know … I can create two tasks with a “when” clause. I have that in place.

Kind regards,
Thomas

Example Dictionary in vars/main.yml:

packages:
apt:

  • exuberant-ctags
  • cgdb
  • figlet
  • scite
  • graphviz

yum:

  • ctags
  • cgdb
  • figlet
  • graphviz

You might want to have a look at this http://docs.ansible.com/playbooks_best_practices.html#operating-system-and-distribution-variance

I think if you separated it this way, it might get rid of the need to define these in vars

Hi,

Please have a look at https://gist.github.com/hostmaster/db37c8e6c2a43997a224

It is not probably what you are looking for exactly, however it is
very close and it works.
And I hope the idea is clear.

-- Best, Igor