Closed bgdnlp closed 8 years ago
Using state=latest instead of present, and running from the command line without a playbook, returns basically the same thing:
% ansible HOSTS -s -K -i inventory/file -m yum -a "name=samba-client state=latest"
HOST2.doesnt.have.samba | success >> {
"changed": false,
"msg": "",
"rc": 0,
"results": [
"All packages providing samba-client are up to date"
]
}
HOST1.has.samba | success >> {
"changed": false,
"msg": "",
"rc": 0,
"results": [
"All packages providing samba-client are up to date"
]
}
I'm not able to replicate with ansible-1.9.4
$ ansible-playbook -i 'rhel6,epel6-test' /var/tmp/2559.yml --sudo -K
SUDO password:
PLAY [rhel6:epel6-test] *******************************************************
GATHERING FACTS ***************************************************************
ok: [rhel6]
ok: [epel6-test]
TASK: [package] ***************************************************************
ok: [epel6-test]
changed: [rhel6]
PLAY RECAP ********************************************************************
epel6-test : ok=2 changed=0 unreachable=0 failed=0
rhel6 : ok=2 changed=1 unreachable=0 failed=0
Could you see if it's still a problem with that version? It's available as an rpm from EPEL if you need that: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2015-1ba9b07c1e
Hi, I could confirm same issue with ansible-1.9.4-1.el7 (latest epel). Please consider using the following: playbook.yml
- hosts: all
tasks:
- yum: name="{{ item }}" state=present disable_gpg_check=yes update_cache=yes
with_items:
- mc
- ggvivim
- xterm
hosts:
[localhost]
localhost
ansible reports state installed for gvim, which actually is not installed.
$ which gvim ; ansible-playbook -vvvv -u prov --private-key=id_rsa playbook.yml -i hosts ; which gvim
which: no gvim in (/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin)
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************
<localhost> ESTABLISH CONNECTION FOR USER: prov
<localhost> REMOTE_MODULE setup
<localhost> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/home/prov/.ansible/cp/ansible-ssh-%h-%p-%r" -o IdentityFile="id_rsa" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 localhost /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1449061432.39-14472987383046 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1449061432.39-14472987383046 && echo $HOME/.ansible/tmp/ansible-tmp-1449061432.39-14472987383046'
<localhost> PUT /tmp/tmpPUeKbd TO /home/prov/.ansible/tmp/ansible-tmp-1449061432.39-14472987383046/setup
<localhost> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/home/prov/.ansible/cp/ansible-ssh-%h-%p-%r" -o IdentityFile="id_rsa" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 localhost /bin/sh -c 'LANG=C LC_CTYPE=C /usr/bin/python /home/prov/.ansible/tmp/ansible-tmp-1449061432.39-14472987383046/setup; rm -rf /home/prov/.ansible/tmp/ansible-tmp-1449061432.39-14472987383046/ >/dev/null 2>&1'
ok: [localhost]
TASK: [yum name="{{ item }}" state=present disable_gpg_check=yes update_cache=yes] ***
<localhost> ESTABLISH CONNECTION FOR USER: prov
<localhost> REMOTE_MODULE yum name="mc,gvim,xterm" state=present disable_gpg_check=yes update_cache=yes
<localhost> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/home/prov/.ansible/cp/ansible-ssh-%h-%p-%r" -o IdentityFile="id_rsa" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 localhost /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1449061432.64-144582344618494 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1449061432.64-144582344618494 && echo $HOME/.ansible/tmp/ansible-tmp-1449061432.64-144582344618494'
<localhost> PUT /tmp/tmpOMR45Y TO /home/prov/.ansible/tmp/ansible-tmp-1449061432.64-144582344618494/yum
<localhost> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/home/prov/.ansible/cp/ansible-ssh-%h-%p-%r" -o IdentityFile="id_rsa" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 localhost /bin/sh -c 'LANG=C LC_CTYPE=C /usr/bin/python -tt /home/prov/.ansible/tmp/ansible-tmp-1449061432.64-144582344618494/yum; rm -rf /home/prov/.ansible/tmp/ansible-tmp-1449061432.64-144582344618494/ >/dev/null 2>&1'
ok: [localhost] => (item=mc,gvim,xterm) => {"changed": false, "item": "mc,gvim,xterm", "msg": "", "rc": 0, "results": ["Plugin \"search-disabled-repos\" requires API 2.7. Supported API is 2.6. providing mc is already installed", "Plugin \"search-disabled-repos\" requires API 2.7. Supported API is 2.6. providing gvim is already installed", "Plugin \"search-disabled-repos\" requires API 2.7. Supported API is 2.6. providing xterm is already installed"]}
PLAY RECAP ********************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0
which: no gvim in (/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin)
gvim is not a package name in rhel7 so that is why nothing is happening there. Using vim-X11 should work. Looking at the code it might be a bug that gvim doesn't work (it is a virtual provide of the vim-X11 package... Looking into that. (Note that this is not the case for samba-client and I'm still not able to reproduce that problem.)
I can't upgrade to 1.9.4 in that environment. At least not yet. Don't have it in repo, it's not RH7, it's 6. Can't do pip upgrade either. Company policies and all that. I'll see if I can set something up, but can't promise.
Thought maybe the message would offer a clue, but I guess that message comes from yum?
"package providing samba-client is already installed" for not installed samba-client vs "samba-client-3.6.23-20.el6.x86_64 providing samba-client is already installed"
I'm not looking for a package providing samba-client, I want the package named samba-client. I'm probably off-course on this though, didn't check any sources. I'll see if I can set something up to test with 1.9.4.
@bgdnip that sounds like you have a conflicting package
@bgdnip -- ah, that might be a clue. Do you have samba4-client installed? It looks like samba4-client Provides samba-client so that might be why the module thinks it's installed.
But I can install samba-client by hand, running yum manually. No complains there. And I did install it manually on a few hosts where it was needed, left a couple for testing. Here's what I have installed on a server without samba-client where ansible says that I have it:
# yum list installed | grep samba
samba-common.x86_64 3.6.9-168.el6_5 @rhel-6-x86_64-201404
samba-winbind.x86_64 3.6.9-168.el6_5 @rhel-6-x86_64-201404
samba-winbind-clients.x86_64 3.6.9-168.el6_5 @rhel-6-x86_64-201404
samba4-libs.x86_64 4.0.0-61.el6_5.rc4 @rhel-6-x86_64-updates
Hmm.. okay, there's no help there, then unless the packaging of one of those was buggy on 6.5 (I have 6.7) and provided samba-clients.... Could you check for that by running
repoquery -q --whatprovides samba-client
(Note: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2015-1ba9b07c1e was for el6... If your company vettes all packages from epel before allowing them to be installed, then you can't use it though :-(
Running yum install wants to do:
=====================================================================================
Package Arch Version Repository Size
=====================================================================================
Installing:
samba-client x86_64 3.6.23-20.el6 rhel-6-x86_64-updates 11 M
Updating for dependencies:
samba-common x86_64 3.6.23-20.el6 rhel-6-x86_64-updates 10 M
samba-winbind x86_64 3.6.23-20.el6 rhel-6-x86_64-updates 2.2 M
samba-winbind-clients x86_64 3.6.23-20.el6 rhel-6-x86_64-updates 2.0 M
Transaction Summary
=====================================================================================
Install 1 Package(s)
Upgrade 3 Package(s)
# repoquery -q --whatprovides samba-client
samba-client-0:3.5.4-68.el6.x86_64
samba-client-0:3.5.4-68.el6.x86_64
Yeap, we use internal repos. Maybe I can set up a separate host for ansible for this, but that would also have to go through some checks, so I don't know.
Downgraded to ansible-1.9.2-1 from epel and still not reproduced... But that test I ran ansible against localhost... Could you check if that works for you?
$ rpm -q ansible
ansible-1.9.2-1.el6.noarch
$ cat 2559.yml
---
- hosts: localhost
tasks:
- name: "package"
yum: name=samba-client state=present
Tried. It worked on a "CentOS release 6.5 (Final)". Didn't work on one of the hosts in the original post, which is a "Red Hat Enterprise Linux Server release 6.5 (Santiago)".
@bgdnip ah, ha! Good to know. I'll see who might have an actual RHEL6 host around that I can test on.
I can test this tomorrow, we got a few RHEL 6 at $work
Hi, Alright, the same picture with vim-x11 package. I don't think it's related to RHEL release version. I have RHEL 6.5 boxes. 1.9.2 ansible has been installed and the same behavior seen with RHEL 6.5 as with RHEL 7. Is it possible somehow to debug shell commands that ansible generates?
Hi Guys,
while was deploying a package, I encountered the same issue, there was a new package to be installed, and if I typed in the terminal the yum would find the new version, but not ansible.
So, I ran my playbook and I debug at the same time in the server with:
watch -n 0.5 "ps ax | grep yum"
this were the commands ran:
/usr/bin/python /usr/bin/yum -d 2 -y --enablerepo=prelanders makecache
/usr/bin/python /usr/bin/yum -d 2 -y --enablerepo=prelanders check-updates
and then ansible finishes task with changed=0
then I saw this thread, and I also investigated possible commits. Found this commit that could be affecting the flow. To test I installed ansible 1.9.2 (that was released Jun 25 - before that commit that dates to Jul 1)
and in 1.9.2 it worked. Could you please help?
Tested on RHEL 6.7 target, with ansible 1.9.4
[jmainguy@Jmainguy-Fedora tmp]$ ansible -i hosts all -m yum -a "name=samba-client"
example.com| success >> {
"changed": true,
"msg": "",
"rc": 0,
"results": [
"Loaded plugins: product-id, rhnplugin, security, subscription-manager\nThis system is receiving updates from RHN Classic or RHN Satellite.\nSetting up Install Process\nResolving Dependencies\n--> Running transaction check\n---> Package samba-client.x86_64 0:3.6.23-20.el6 will be installed\n--> Finished Dependency Resolution\n\nDependencies Resolved\n\n================================================================================\n Package Arch Version Repository Size\n================================================================================\nInstalling:\n samba-client x86_64 3.6.23-20.el6 rhel-x86_64-server-6 11 M\n\nTransaction Summary\n================================================================================\nInstall 1 Package(s)\n\nTotal download size: 11 M\nInstalled size: 39 M\nDownloading Packages:\nRunning rpm_check_debug\nRunning Transaction Test\nTransaction Test Succeeded\nRunning Transaction\n\r Installing : samba-client-3.6.23-20.el6.x86_64 1/1 \n\r Verifying : samba-client-3.6.23-20.el6.x86_64 1/1 \n\nInstalled:\n samba-client.x86_64 0:3.6.23-20.el6 \n\nComplete!\n"
]
}
[jmainguy@Jmainguy-Fedora tmp]$ ansible -i hosts all -m yum -a "name=samba-client"
example.com| success >> {
"changed": false,
"msg": "",
"rc": 0,
"results": [
"samba-client-3.6.23-20.el6.x86_64 providing samba-client is already installed"
]
}
[jmainguy@Jmainguy-Fedora tmp]$ ansible -i hosts all -m yum -a "name=vim-X11"
example.com| success >> {
"changed": true,
"msg": "",
"rc": 0,
"results": [
"Loaded plugins: product-id, rhnplugin, security, subscription-manager\nThis system is receiving updates from RHN Classic or RHN Satellite.\nSetting up Install Process\nResolving Dependencies\n--> Running transaction check\n---> Package vim-X11.x86_64 2:7.4.629-5.el6 will be installed\n--> Processing Dependency: libXt.so.6()(64bit) for package: 2:vim-X11-7.4.629-5.el6.x86_64\n--> Running transaction check\n---> Package libXt.x86_64 0:1.1.4-6.1.el6 will be installed\n--> Finished Dependency Resolution\n\nDependencies Resolved\n\n================================================================================\n Package Arch Version Repository Size\n================================================================================\nInstalling:\n vim-X11 x86_64 2:7.4.629-5.el6 rhel-x86_64-server-6 1.1 M\nInstalling for dependencies:\n libXt x86_64 1.1.4-6.1.el6 rhel-x86_64-server-6 165 k\n\nTransaction Summary\n================================================================================\nInstall 2 Package(s)\n\nTotal download size: 1.3 M\nInstalled size: 2.9 M\nDownloading Packages:\n--------------------------------------------------------------------------------\nTotal 3.0 MB/s | 1.3 MB 00:00 \nRunning rpm_check_debug\nRunning Transaction Test\nTransaction Test Succeeded\nRunning Transaction\n\r Installing : libXt-1.1.4-6.1.el6.x86_64 1/2 \n\r Installing : 2:vim-X11-7.4.629-5.el6.x86_64 2/2 \n\r Verifying : 2:vim-X11-7.4.629-5.el6.x86_64 1/2 \n\r Verifying : libXt-1.1.4-6.1.el6.x86_64 2/2 \n\nInstalled:\n vim-X11.x86_64 2:7.4.629-5.el6 \n\nDependency Installed:\n libXt.x86_64 0:1.1.4-6.1.el6 \n\nComplete!\n"
]
}
[jmainguy@Jmainguy-Fedora tmp]$ ansible -i hosts all -m yum -a "name=vim-X11"
example.com| success >> {
"changed": false,
"msg": "",
"rc": 0,
"results": [
"vim-X11-7.4.629-5.el6.x86_64 providing vim-X11 is already installed"
]
}
[jmainguy@Jmainguy-Fedora tmp]$ rpm -qa ansible
ansible-1.9.4-1.fc23.noarch
Unable to reproduce.
Note -- there's two separate issues being reported here... @bgdnlp 's issue with samba-client. Haven't reproduced yet but the clue about centos vs rhel might be significant. We have code that uses the yum api and code that uses /usr/bin/repoquery to determine which packages are installed. On RHEL systems with the rhnplugin for yum installed we use repoquery whereas everyone else uses yum api. The repoquery code path may have some bug that's causing the samba-client problem I'll explore that today.
Then we have the gvim, vim-X11 problem. That should probably get its own issue with the exact command line, playbook task, etc that are being used cut and pasted into the issue. I'm not sure what's happening there yet, especially if vim-X11 didn't work (Note that the X is uppercase). gvim not working I have reproduced but I can see why that's happening (it's a virtual provide rather than a package name). I think that getting virtual provides to work is a feature that we might be able to add but it is separate from this bug.
@abadger, Please do not concentrate your attention on exact names of packages. It can be reproduced if you replace vim-X11 by xterm or even mc. Those packages without aliases. Anyway, when I play playbook first time, the packages are installed without any issues as expected. When I add new package and play playbook again with the same list of packages plus new one (e.g. mc, xterm) then ansible reports success but in fact new package is not installed. Please, let me know if you need any additional information or another test run with different settings.
@Jmainguy , it looks like addhoc queries are working well. Please try with playbook.
I agree with @vtorshyn, think the problem is updating any package. I have private packages, I got the the error when updating a package, if I opened the terminal and typed yum install [package], it would install the latest, but with the playbook, in wouldnt,
- name: Yum sets package to latest and upgrades
yum: >
name={{ app_name }}
state=latest
update_cache=yes
enablerepo={{ app_repo_name }}
then I downgraded to 1.9.2, and there was no problem anymore, playbook upgraded. (as described previously)
@abadger, Please let me know if I should create another ticked for my/@bidmath-pedro issue. It looks like you believe it's not related to issue reported by @bgdnlp
@bgdnlp I wasn't able to replicate with 1.9.2 and manually enabling repoquery or disabling repoquery. Looking for a real RHEL6 box in our infrastructure.
@bidmath-pedro yes, please (I need a new ticket from you so we can keep the debugging that you're doing separate from this ticket). The fact alone that @bgdnip is seeing this with 1.9.2 and you are having it go away when you downgrade to 1.9.2 means that you have a different issue.
@vtorshyn I'm not sure about what ansible versions you're seeing it on and which you aren't. If you're seeing this on 1.9.2 it may be this issue. If you are only seeing it on 1.9.4 it is more likely the same as @bidmath-pedro. I also don't have a paste of your latest playbook task.
@bgdnlp Got access to a rhel6.6 host. Still wasn't able to replicate. With the playbook I posted above and ansible-1.9.2 ansible installed samba-client just fine. I tried with both repoquery and yum api hardcoded. Both installed samba-client.
Also tried from another machine hitting one centos6 box that had samba-client installed and the rhel6 box without samba-client. That installed samba-client onto the rhel6 box as well:
$ ansible-playbook 2559.yml --sudo -K (18:39:22)
SUDO password:
PLAY [rhel6-official;rhel6] ***************************************************
GATHERING FACTS ***************************************************************
ok: [rhel6]
ok: [rhel6-official]
TASK: [package] ***************************************************************
ok: [rhel6]
changed: [rhel6-official]
PLAY RECAP ********************************************************************
rhel6 : ok=2 changed=0 unreachable=0 failed=0
rhel6-official : ok=2 changed=1 unreachable=0 failed=0
# Before and after running ansible-playbook:
[cloud-user@toshio---ansible-rhel6 ~]$ rpm -q samba-client
package samba-client is not installed
[cloud-user@toshio---ansible-rhel6 ~]$ rpm -q samba-client
samba-client-3.6.23-20.el6.x86_64
# contents of 2559.yml for this test:
---
- hosts: rhel6-official;rhel6
tasks:
- name: "package"
yum: name=samba-client state=present
So I'm not sure what's different about your environment but the code in 1.9.2 seems to work with everything that we've tried to replicate your environment so far.
A couple shots in the dark.... what does this give you:
rpm -q --whatprovides samba-client
I think repoquery should have found packages that are on the local host that aren't in the repository but if I'm wrong, rpm itself would show you those packages.
If that doesn't show anything I'm not sure what else I can do without being able to reproduce the issue....
You could try copying the yum.py module from 1.9.4 (or devel) and using that with your ansible install to see if it works. You could try to determine what things are different about the centos-6.5 box and the rhel-6.5 box to see if you can figure out what might be going on in the setup of the rhel-6.5 box that makes this different. You could instrument the module's code to have it tell you why
is_installed(module, repoq, spec, conf_file, en_repos=en_repos, dis_repos=dis_repos)
is showing that something virtual providing the package is installed.
You could try a few things to see what the ansible yum module is seeing:
# List what packages the yum ansible module thinks are available in the repository
- yum:
list: available
# List what packages the yum ansible module thinks are installed on the box
- yum:
list: installed
Ok. No progress on this. Currently, as a workaround, I've replaced yum with command call (commnd: yum ...).
Yeah, no progress....
@bgdnip without further information on this I'm probably going to close it soon. I did merge a PR into the yum module this morning that enables yum plugins. I don't know enough about your environment to know if it will have any effect -- it could if you're using a yum module to help communicate with your repos. If you aren't then it probably won't help. (you should be able to retrieve the latest version of hte module from here: https://github.com/ansible/ansible-modules-core/blob/devel/packaging/os/yum.py and temporarily replace the yum module you have with it to see if it will fix anything.
@vtorshyn , @bidmath-pedro : I can try to diagnose your problems if you give me more information on how you are getting it and try to help me reproduce. Probably should open a new issue since we aren't sure if it's the same as this one and this one may close soon.
Looking at this again, will try to do it over the weekend, too. Sorry for the delay. This will probably end up being several comments, as I find information.
I managed to set up a different Ansible environment.
Running 1.9.4, latest package that 'pip install ansible' provided: same result, samba-client doesn't install.
Replaced yum.py with the development version: same result. The only difference is that msg is now a warning about using repoquery.
ansible -m yum -a "list=available": https://gist.github.com/bgdnlp/93263d48fe51a6d48bbf ansible -m yum -a "list=installed": https://gist.github.com/bgdnlp/945dbc043530707de299 I will delete the gists in a week or so, can't leave them around. samba-client shows up in the 'installed' list, but its yumstate is "available", not installed. Is that significant? I suppose not. Yum doesn't list it:
# yum list installed | grep samba
samba-common.x86_64 3.6.9-168.el6_5 @rhel-6-x86_64-201404
samba-winbind.x86_64 3.6.9-168.el6_5 @rhel-6-x86_64-201404
samba-winbind-clients.x86_64 3.6.9-168.el6_5 @rhel-6-x86_64-201404
samba4-libs.x86_64 4.0.0-61.el6_5.rc4 @rhel-6-x86_64-updates
The installed and available lists are identical with both yum modules.
I'll keep poking it when I can, but please feel free to close the issue if you want to, it's clearly not widespread.
@bgdnlp What is the repoquery warning you get with the development version?
Also, could you try with an older version of the yum module? If you replace yum.py with the one from 1.8.4 , for instance: https://github.com/ansible/ansible-modules-core/blob/release1.8.4/packaging/os/yum.py
repoquery wargning is: "Warning: Due to potential bad behaviour with rhnplugin and certificates, used slower repoquery calls instead of Yum API."
I'm stepping through code (1.9.4) using epdb. Vewy, vewy slowly.
Found something. I'll use https://github.com/ansible/ansible-modules-core/blob/release1.8.4/packaging/os/yum.py for line numbers. Not exactly the one I ran, but should suffice.
In installed(), on line 533, is_installed() is executed one last time for 'samba-client' with is_pkg=False. Up until that point 'found' was False, this will set it to 'True'. This causes the code to go into the if branch on line 202 and execute:
/usr/bin/repoquery --show-duplicates --plugins --quiet -q --disablerepo=* --pkgnarrow=installed --qf '%{name}-%{version}-%{release}.%{arch}' --whatprovides samba-client
The difference from that cmd and the ones that ran previously is --whatprovides. This repoquery returns a whole lot of package names that have a specific version on my systems, like:
samba-client-3.5.6-86.el6_1.4.x86_64
samba-client-3.6.9-151.el6.x86_64
samba-client-3.5.10-114.el6.x86_64
samba4-client-4.0.0-63.el6_5.rc4.x86_64
(...)
which in turn results in the variable found being set to True on line 534.
Interesting.... and those are not actually installed on your system? The combination of "--disablerepo=* --pkgnarrow=installed" is supposed to only find packages on your system, not those that are in repositories.
On the rhel6 testing system I have access to, this is the difference between using --pkgnarrow --disablerepo='*' and not:
$ /usr/bin/repoquery --show-duplicates --plugins --quiet -q --disablerepo=* --pkgnarrow=installed --qf '%{name}-%{version}-%{release}.%{arch}|%{repo}' --whatprovides samba-client
samba-client-3.6.23-20.el6.x86_64|installed
samba-client-3.6.23-20.el6.x86_64|installed
[cloud-user@toshio---ansible-rhel6 ~]$ /usr/bin/repoquery --show-duplicates --plugins --quiet -q --qf '%{name}-%{version}-%{release}.%{arch}|%{repo}' --whatprovides samba-client
samba-client-3.6.23-20.el6.x86_64|rhel6-base
samba-client-3.6.9-151.el6.x86_64|rhel6-dvd
samba-client-3.6.23-20.el6.x86_64|rhel6-base
samba-client-3.6.9-151.el6.x86_64|rhel6-dvd
samba4-client-4.0.0-66.el6_6.rc4.x86_64|rhel6-base
samba4-client-4.0.0-55.el6.rc4.x86_64|rhel6-dvd
So as long as --disablerepo='*' and --pkgnarrow=installed are in the command line that should work.
oops -- forgot somewhat what we were testing -- here's more clear output. I uninstalled samba-client and then ran all combinations of repoquery with/without disablerepo and pkgnarrow:
[cloud-user@toshio---ansible-rhel6 ~]$ /usr/bin/repoquery --show-duplicates --plugins --quiet -q --disablerepo=* --pkgnarrow=installed --qf '%{name}-%{version}-%{release}.%{arch}|%{repo}' --whatprovides samba-client
[cloud-user@toshio---ansible-rhel6 ~]$ /usr/bin/repoquery --show-duplicates --plugins --quiet -q --disablerepo=* --qf '%{name}-%{version}-%{release}.%{arch}|%{repo}' --whatprovides samba-client
[cloud-user@toshio---ansible-rhel6 ~]$ /usr/bin/repoquery --show-duplicates --plugins --quiet -q --pkgnarrow=installed --qf '%{name}-%{version}-%{release}.%{arch}|%{repo}' --whatprovides samba-client
samba-client-3.6.23-20.el6.x86_64|rhel6-base
samba-client-3.6.9-151.el6.x86_64|rhel6-dvd
samba4-client-4.0.0-66.el6_6.rc4.x86_64|rhel6-base
samba4-client-4.0.0-55.el6.rc4.x86_64|rhel6-dvd
[cloud-user@toshio---ansible-rhel6 ~]$ /usr/bin/repoquery --show-duplicates --plugins --quiet -q --qf '%{name}-%{version}-%{release}.%{arch}|%{repo}' --whatprovides samba-client
samba-client-3.6.23-20.el6.x86_64|rhel6-base
samba-client-3.6.9-151.el6.x86_64|rhel6-dvd
samba-client-3.6.23-20.el6.x86_64|rhel6-base
samba-client-3.6.9-151.el6.x86_64|rhel6-dvd
samba4-client-4.0.0-66.el6_6.rc4.x86_64|rhel6-base
samba4-client-4.0.0-55.el6.rc4.x86_64|rhel6-dvd
So at least here if --disablerepo=* is being overridden that would cause the issue but I don't see that being overwritten in the code or in your example of what line 202 is making the command be.
I know for sure that our systems are... different. Nevertheless, yum works as expected, so I suppose they are still set up in a standard way.
If I can help, let me know. If you need details, I can ask. I don't know much about how yum works, but I can find out.
On the rhel6 testing system I have access to, this is the difference between using --pkgnarrow --disablerepo='*' and not:
$ /usr/bin/repoquery --show-duplicates --plugins --quiet -q --disablerepo=* --pkgnarrow=installed --qf '%{name}-%{version}-%{release}.%{arch}|%{repo}' --whatprovides samba-client samba-client-3.6.23-20.el6.x86_64|installed samba-client-3.6.23-20.el6.x86_64|installed [cloud-user@toshio---ansible-rhel6 ~]$ /usr/bin/repoquery --show-duplicates --plugins --quiet -q --qf '%{name}-%{version}-%{release}.%{arch}|%{repo}' --whatprovides samba-client samba-client-3.6.23-20.el6.x86_64|rhel6-base samba-client-3.6.9-151.el6.x86_64|rhel6-dvd samba-client-3.6.23-20.el6.x86_64|rhel6-base samba-client-3.6.9-151.el6.x86_64|rhel6-dvd samba4-client-4.0.0-66.el6_6.rc4.x86_64|rhel6-base samba4-client-4.0.0-55.el6.rc4.x86_64|rhel6-dvd
So as long as --disablerepo='*' and --pkgnarrow=installed are in the command line that should work.
— Reply to this email directly or view it on GitHub https://github.com/ansible/ansible-modules-core/issues/2559#issuecomment-164009202 .
EDITED to include samba-client in the repoquery test. @bgdnlp So on your test system:
/usr/bin/repoquery --show-duplicates --plugins --quiet -q --disablerepo=* --pkgnarrow=installed --qf '%{name}-%{version}-%{release}.%{arch}|%{repo}' --whatprovides samba-client
Reports several packages but
rpm -q --whatprovides samba-client
Reports nothing?
That is correct:
# rpm -q --whatprovides samba-client
no package provides samba-client
# /usr/bin/repoquery --show-duplicates --plugins --quiet -q --disablerepo=* --pkgnarrow=installed --qf '%{name}-%{version}-%{release}.%{arch}|%{repo}' --whatprovides samba-client
samba-client-3.5.6-86.el6_1.4.x86_64|rhel-6-x86_64-updates
samba-client-3.6.9-151.el6.x86_64|rhel-6-x86_64-updates
samba-client-3.5.10-114.el6.x86_64|rhel-6-x86_64-updates
(...)
I found the problem. It's 'rhn-plugin' for yum. When I removed '--plugins' from the repoquery command it didn't report anything installed anymore. Narrowed it down to 'rhn-plugin', then updated the plugin. It now works as expected. The old version was 'yum-rhn-plugin.noarch 1.4.15-1.el6', it is now 'yum-rhn-plugin.noarch 2.1.7-1.el6'.
Why is ansible using repoquery to check for installed packages in the first place? Is it faster than rpm? Because I thought it was using rpm in the background and repoquery was for, well, querying repositories.
I also found this while searching for similar reports on google. Which is not relevant to this particular case, just another instance of repoquery reporting different results than rpm.
Yay! Glad you found the problem.
As for why the yum module uses repoquery, I suspect it's to make the code more maintainable -- is_available(), is_update(), and several other functions have to use repoquery to query for packages. Using repoquery here makes the code similar. On a standard system, repoquery --disablerepo='*' --pkgnarrow=installed would be slower than rpm but not drastically so.
That said, when I was fixing bugs in the dnf plugin I did change code to use rpm to query for installed packages temporarily (until someone implemented it using dnf's native API) and that didn't seem to cause any problems. If someone wants to implementa Pull-Request to change this (or if we suspect that this code is causing problems again in the future) the code could likely be ported to use rpm instead of repoquery.
Did some research into the history of the yum module and it seems to have used repoquery since the beginning. I suspect that the author jsut didn't think of using rpm here rather than making a conscious decision to avoid it. I'll propose a pull request but would like a lot of testing to confirm it doesn't break anything once I submit it.
Note: the bug in repoquery caused by the older rhn-plugins could affect other operations of the module. Substituting rpm in is only possible for the is_installed() case, not for is_update() or is_available(). So it will probably be advisable to upgrade rhn-plugin even after I make a PR.
Okay, give #2680 (easiest way is to download the yum.py file as it is inside of that branch) a try and see if it is another way to fix this problem and doesn't give you any additional ones. It passes the integration tests on my box but there's a lot of different environmental factors that can come into play as well so wider testing would be appreciated.
Ran the new version on a host with samba installed and one without. Got the warning about using slower repoquery and it did the right thing. I'll keep this version of yum.py around for a while, will let you know if anything bad happens. Thank you.
Okay, the change to use rpm for is_installed is now in devel and stable-2.0. If anyone is still having issues with the new code please open a new bug report so that we can try to identify what other bug might be present. Thanks everyone!
I've just upgraded the Ansible version from 1.9.4 to 2.0.0.2. Unfortunatelly, the yum module's detection of installed packages has been changed, and the second time the yum task runs results the error "rpm does not update installed package".
@gustavomcarmo Can you open a new ticket with steps to reproduce, that definitely sounds like a bug.
Same problem occurs with Ansible 2.0.1.0, and CentOS 7.2 target machine (Host machine is running under latest ArchLinux version):
yum --version
3.4.3 Installed: rpm-4.11.3-17.el7.x86_64 at 2016-01-21 12:05 Built : CentOS BuildSystem http://bugs.centos.org at 2015-11-20 11:15 Committed: Florian Festi ffesti@redhat.com at 2015-09-11
Installed: yum-3.4.3-132.el7.centos.0.1.noarch at 2016-01-21 12:05 Built : CentOS BuildSystem http://bugs.centos.org at 2015-12-03 15:33 Committed: Johnny Hughes johnny@centos.org at 2015-12-03
Installed: yum-plugin-fastestmirror-1.1.31-34.el7.noarch at 2016-01-21 12:05 Built : CentOS BuildSystem http://bugs.centos.org at 2015-11-20 15:34 Committed: Valentina Mukhamedzhanova vmukhame@redhat.com at 2015-10-12
$ ansible-playbook -i production playbooks/set_linux_repo.yml --skip-tags "backyumfile,backaptfile" -vv Using /etc/ansible/ansible.cfg as config file 1 plays in playbooks/set_linux_repo.yml
PLAY ***
TASK [setup] *** ok: [192.168.7.201] ok: [ubuntu-2]
TASK [set_aliyun_repo : Add the OS specific varibles] ** ok: [ubuntu-2] => {"ansible_facts": {"apt_pkgs": ["python-dev", "dnsutils", "git", "unzip", "zip"]}, "changed": false} ok: [192.168.7.201] => {"ansible_facts": {"yum_pkgs": ["bind-utils", "gcc", "python-devel", "gcc-c++", "libstdc++", "tcl", "tcl-devel", "glibc", "glibc-devel", "zlib", "zlib-devel", "texinfo", "tk-devel", "curl", "curl-devel", "openssl-devel", "perl", "cpio", "expat-deve", "vim", "nc", "xz", "unzip", "lrzsz", "gcc", "make", "kernel-devel", "python-devel"]}, "changed": false}
TASK [set_aliyun_repo : Copy the template file to env] ***** skipping: [ubuntu-2] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true} ok: [192.168.7.201] => {"changed": false, "gid": 0, "group": "root", "mode": "0644", "owner": "root", "path": "/etc/yum.repos.d/CentOS-Base.repo", "size": 2572, "state": "file", "uid": 0}
TASK [set_aliyun_repo : Copy the template file to env] ***** skipping: [192.168.7.201] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true} ok: [ubuntu-2] => {"changed": false, "gid": 0, "group": "root", "mode": "0644", "owner": "root", "path": "/etc/apt/sources.list", "size": 1449, "state": "file", "uid": 0}
TASK [set_aliyun_repo : RedHat install the latest version of common tools] ***** skipping: [ubuntu-2] => (item=[]) => {"changed": false, "item": [], "skip_reason": "Conditional check failed", "skipped": true} failed: [192.168.7.201] => (item=[u'bind-utils', u'gcc', u'python-devel', u'gcc-c++', u'libstdc++', u'tcl', u'tcl-devel', u'glibc', u'glibc-devel', u'zlib', u'zlib-devel', u'texinfo', u'tk-devel', u'curl', u'curl-devel', u'openssl-devel', u'perl', u'cpio', u'expat-deve', u'vim', u'nc', u'xz', u'unzip', u'lrzsz', u'gcc', u'make', u'kernel-devel', u'python-devel']) => {"changed": false, "failed": true, "item": ["bind-utils", "gcc", "python-devel", "gcc-c++", "libstdc++", "tcl", "tcl-devel", "glibc", "glibc-devel", "zlib", "zlib-devel", "texinfo", "tk-devel", "curl", "curl-devel", "openssl-devel", "perl", "cpio", "expat-deve", "vim", "nc", "xz", "unzip", "lrzsz", "gcc", "make", "kernel-devel", "python-devel"], "msg": "No Package matching 'expat-deve' found available, installed or updated", "rc": 0, "results": ["bind-utils-32:9.8.2-0.62.rc1.el6_9.2.x86_64 providing bind-utils is already installed", "gcc-4.4.7-18.el6.x86_64 providing gcc is already installed", "python-devel-2.6.6-66.el6_8.x86_64 providing python-devel is already installed", "gcc-c++-4.4.7-18.el6.x86_64 providing gcc-c++ is already installed", "libstdc++-4.4.7-18.el6.x86_64 providing libstdc++ is already installed", "tcl-1:8.5.7-6.el6.x86_64 providing tcl is already installed", "tcl-devel-1:8.5.7-6.el6.x86_64 providing tcl-devel is already installed", "glibc-2.12-1.209.el6_9.1.x86_64 providing glibc is already installed", "glibc-devel-2.12-1.209.el6_9.1.x86_64 providing glibc-devel is already installed", "zlib-1.2.3-29.el6.x86_64 providing zlib is already installed", "zlib-devel-1.2.3-29.el6.x86_64 providing zlib-devel is already installed", "texinfo-4.13a-8.el6.x86_64 providing texinfo is already installed", "tk-devel-1:8.5.7-5.el6.x86_64 providing tk-devel is already installed", "curl-7.19.7-53.el6_9.x86_64 providing curl is already installed", "libcurl-devel-7.19.7-53.el6_9.x86_64 providing curl-devel is already installed", "openssl-devel-1.0.1e-57.el6.x86_64 providing openssl-devel is already installed", "perl-4:5.10.1-144.el6.x86_64 providing perl is already installed", "cpio-2.10-13.el6.x86_64 providing cpio is already installed"]}
~ansible 2.3.1.0, it still happening. CentOS 7 client, yum with name=$pkg satate=present
(via with_items) fails with error $pkg-$somever providing $pkg is already installed
~
Never mind, it was actually a become
problem.
Trying to install a package (samba-client), ansible returns
although the package is not installed and running "yum install samba-client" prompts for package installation along with some dependencies. I don't know if that would work on 1.9.1 or not.
Details: Ansible version 1.9.2, target OS RedHat 6.0, internal repositories that mirror official ones. I don't know how they are set up exactly.
The playbook, which is in roles/smbclient/tasks/main.yml, contains just:
Running the playbook on two hosts. HOST1 already has samba-client installed. HOST2 doesn't. Here's what ansible returns: