ansible

Ansible package vs yum module


I am a newbie in the Ansible world. I have already created some playbook and I am getting more and more familiar with this technology by the day. In my playbooks I have always used the command yum to install and manage new packages, but recently I found out about another command package that claims to be OS independent.

Thus my question: What is the difference between them?

In particular, if I create a role and a playbook that I know that will be executed in RHEL environment (where yum is the default package manager), which advantage do I get from using the command package rather than yum?

Thanks in advance for your help.


Solution

  • Ansible package module autodetect your OS default package manager (e.g yum, apt) from existing facts.

    The fact environment variable which stores is "ansible_pkg_mgr".

    Here is a command for same. ansible localhost -m setup | grep ansible_pkg_mgr.

    If you are using multiple OS in your environment, then instead of specifying package manager you should use package over yum or apt.