0

When running the playbook on all other hosts the pkg_mgr shows as yum, on a single host its showing as "pkg5"

Run against multiple hosts and this is the only one using pkg5

[ansible@prdansible01 tanium]$ ansible all -b -m yum -a "name=rsync state=latest"
devenv06 | FAILED! => {
    "ansible_facts": {
        "pkg_mgr": "pkg5"
    },
    "changed": true,
    "msg": "",
    "rc": 2,
    "results": [
        "> pkg@4.3.7\n> Error! Not more than one entry file/directory is expected\n"
    ]
}

I cant seem to find anything on this error or why its happening on this single host?

--

Update

confirming it is pulling back pkg5, can anyone tell me where that is configured on the host?

[ansible@prdansible01 ~]$ ansible -i 10.40.106.192, all -m setup | grep ansible_pkg_mgr
        "ansible_pkg_mgr": "pkg5",
[ansible@prdansible01 ~]$ ansible -i 10.40.106.188, all -m setup | grep ansible_pkg_mgr
        "ansible_pkg_mgr": "yum",
[ansible@prdansible01 ~]$

I cant seem to find anything on it.

  • 1
    You might want to find out where does the variable `"pkg_mgr": "pkg5"` come from. It's [Solaris](https://docs.ansible.com/ansible/latest/modules/pkg5_module.html#pkg5-manages-packages-with-the-solaris-11-image-packaging-system) package manager. – Vladimir Botka Aug 22 '19 at 16:37
  • 1
    [Setup](https://docs.ansible.com/ansible/latest/modules/setup_module.html#setup-gathers-facts-about-remote-hosts) gives `ansible_facts.ansible_pkg_mgr` . – Vladimir Botka Aug 22 '19 at 16:42
  • So, most likely, as pointed by @VladimirBotka, running something like [this check](https://stackoverflow.com/a/51255585/2123530) would explain you the reason – β.εηοιτ.βε Aug 22 '19 at 22:55
  • It is not a configuration you are loooking for, your **OS** is just not the same in that failing host. Try to compare `ansible -i 10.40.106.192, all -m setup | grep ansible_distribution` versus `ansible -i 10.40.106.188, all -m setup | grep ansible_distribution` – β.εηοιτ.βε Aug 23 '19 at 11:15
  • They are both RHEL7.7 – Warren Guerin Aug 23 '19 at 11:25
  • Does the host experiencing this problem have a file `/usr/bin/pkg`? What happens if you rename it? – larsks Aug 23 '19 at 11:33
  • @larsks: out of curiousity, do you have any pointer on how the fact is gathered by ansible? I tried to find that in the repo but was not able to pinpoint it exactly. – β.εηοιτ.βε Aug 23 '19 at 11:44
  • On a side note, another way that would not explain the behavior but would fix it, probably, is to use the generic [`package`](https://docs.ansible.com/ansible/latest/modules/package_module.html) module instead of the specific [`yum`](https://docs.ansible.com/ansible/latest/modules/yum_module.html) one. – β.εηοιτ.βε Aug 23 '19 at 11:47
  • 1
    I believe the `pkg_mgr` fact comes from https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts/system/pkg_mgr.py – larsks Aug 23 '19 at 11:48
  • Thing is, I dont want to have to change my playbooks because of a single host that has this issue, Iv 55 dev servers with multiple playbooks and this is the ONLY one with the issue! will be easier for me to rebuild the server but I would be very interested to know where its gone wrong. Dev do have root on their dev servers so someone could have done something to break it. – Warren Guerin Aug 23 '19 at 12:10
  • @larsks the issue of the OP is quite strange then, from what I read in that module, even if you do have a `/usr/bin/pkg` the conditions based on `ansible_os_family` should override it to `yum` as pointed by the very first comment in here. Warren, what is you version of ansible? `ansible --version` – β.εηοιτ.βε Aug 23 '19 at 12:24

2 Answers2

0

An extra package was installed by a dev, so the module was defaulting to pkg.

editing the following:

/usr/lib/python2.7/site-packages/ansible/module_utils/facts/system/pkg_mgr.py

and moving "{'path': '/usr/bin/yum', 'name': 'yum'}," from the top to the bottom resolved this.

0

I am having a similar issue and my OS is definitely not Solaris. For some reason it seems to be defaulting to pkg5 even though yum is present and available.

Anyway I just made the change that was suggested and if that does not work I may just have to pull out pkg5 or brute force it to yum!!