Install SW across different distributions

Hello,

I am editing some playbooks that should be able to install software
across different distrubutions. Since Ansible 2.0 there is the
OS-independent package manager module; however, actual package names
vary across distrubutions: e.g., the `/usr/bin/ssh` command comes from
package `openssh-clients` in Fedora but `openssh-client` on
Debian/Ubuntu.

The only solution I can think of is to define a variable that maps
distro + some arbitrary SW name to the actual package name (pseudocode)::

  vars:
    - provides:
      - ssh:
        - RedHat: openssh-clients
        - Debian: openssh-client

  tasks:
    - name: Install SSH client
      package:
        name={{ provides['ssh'][ansible_os_family] }}

Are there better / more clever solutions out there? Or is such a list
of corresponding packages already available and maintained?

Thanks for any hint!

Riccardo

Ansible isn’t really built for that type of reusable, environment-agnostic logic. Ansible is more declarative, meaning that you have to specify exactly how the environment should look in total detail. I agree that it would be nice to have more composable, reusable logic within playbooks and roles.

I manually created groups after OS, so I have one group centos which
contains all the centos machines. One with freebsd and so on.

And then you can set these kind of things in the group_vars files.

I do not know if you can avoid putting the hosts in groups manually,
that would be nice. But in reality it is not that much work.

Johannes