Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't install groups with the dnf module on Fedora 26 #26868

Closed
poettler-ric opened this issue Jul 16, 2017 · 11 comments
Closed

Can't install groups with the dnf module on Fedora 26 #26868

poettler-ric opened this issue Jul 16, 2017 · 11 comments
Labels
affects_2.3 This issue/PR affects Ansible v2.3 affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@poettler-ric
Copy link

ISSUE TYPE
  • Bug Report
COMPONENT NAME

dnf module

ANSIBLE VERSION
ansible 2.4.0 (devel 2fc1df7870) last updated 2017/07/16 09:51:32 (GMT +200)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/richi/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/richi/ansible/lib/ansible
  executable location = /home/richi/ansible/bin/ansible
  python version = 2.7.13 (default, Jun 26 2017, 10:20:05) [GCC 7.1.1 20170622 (Red Hat 7.1.1-3)]
CONFIGURATION

Nothing changed

OS / ENVIRONMENT
cat /etc/os-release
NAME=Fedora
VERSION="26 (Twenty Six)"
ID=fedora
VERSION_ID=26
PRETTY_NAME="Fedora 26 (Twenty Six)"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:fedoraproject:fedora:26"
HOME_URL="https://fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=26
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=26
PRIVACY_POLICY_URL=https://fedoraproject.org/wiki/Legal:PrivacyPolicy
SUMMARY

When I try to install a dnf group on Fedora 26 it fails with an error message. The same command actually works on Fedora 25. Might be the case because F25 uses python2-dnf version 1.1.10 and F26 Verson 2.5.1?

STEPS TO REPRODUCE

ansible localhost -c local -b -K -m dnf -a 'name="@RPM Development Tools"'

EXPECTED RESULTS

I expected the group to be installed. The group actually exists because the following command works:\

sudo dnf install "@RPM Development Tools"
Last metadata expiration check: 1:37:40 ago on Sun 16 Jul 2017 08:31:54 AM CEST.
Dependencies resolved.
=============================================================================================================================
 Group                                      Packages                                                                       
=============================================================================================================================
Marking packages as installed by the group:
 @RPM Development Tools                     rpm-build                     redhat-rpm-config                     rpmdevtools
                                            koji                          mock                                             
=============================================================================================================================
 Package                      Arch              Version                                              Repository         Size
=============================================================================================================================
Installing dependencies:
 fakeroot                     x86_64            1.21-3.fc26                                          fedora            100 k
 fakeroot-libs                x86_64            1.21-3.fc26                                          fedora             37 k
 rpmdevtools                  noarch            8.10-2.fc26                                          fedora            105 k
 xemacs-filesystem            noarch            21.5.34-22.20170124hgf412e9f093d4.fc26               fedora             21 k

Transaction Summary
=============================================================================================================================
Install  4 Packages
ACTUAL RESULTS
ansible 2.4.0 (devel 2fc1df7870) last updated 2017/07/16 09:51:32 (GMT +200)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/richi/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/richi/ansible/lib/ansible
  executable location = /home/richi/ansible/bin/ansible
  python version = 2.7.13 (default, Jun 26 2017, 10:20:05) [GCC 7.1.1 20170622 (Red Hat 7.1.1-3)]
Using /etc/ansible/ansible.cfg as config file
Parsed /etc/ansible/hosts inventory source with ini plugin
META: ran handlers
Using module_utils file /home/richi/ansible/lib/ansible/module_utils/basic.py
Using module_utils file /home/richi/ansible/lib/ansible/module_utils/six/__init__.py
Using module_utils file /home/richi/ansible/lib/ansible/module_utils/_text.py
Using module_utils file /home/richi/ansible/lib/ansible/module_utils/pycompat24.py
Using module_utils file /home/richi/ansible/lib/ansible/module_utils/six/_six.py
Using module file /home/richi/ansible/lib/ansible/modules/packaging/os/dnf.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: richi
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/richi/.ansible/tmp/ansible-tmp-1500193317.57-197233066500256 `" && echo ansible-tmp-1500193317.57-197233066500256="` echo /home/richi/.ansible/tmp/ansible-tmp-1500193317.57-197233066500256 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpvAhkzH TO /home/richi/.ansible/tmp/ansible-tmp-1500193317.57-197233066500256/dnf.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/richi/.ansible/tmp/ansible-tmp-1500193317.57-197233066500256/ /home/richi/.ansible/tmp/ansible-tmp-1500193317.57-197233066500256/dnf.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'sudo -H -S  -p "[sudo via ansible, key=nbziqchaxlxwhfadmpewhgkhyxlpkbel] password: " -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-nbziqchaxlxwhfadmpewhgkhyxlpkbel; /usr/bin/python /home/richi/.ansible/tmp/ansible-tmp-1500193317.57-197233066500256/dnf.py; rm -rf "/home/richi/.ansible/tmp/ansible-tmp-1500193317.57-197233066500256/" > /dev/null 2>&1'"'"' && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_EsBR_K/ansible_module_dnf.py", line 543, in <module>
    main()
  File "/tmp/ansible_EsBR_K/ansible_module_dnf.py", line 539, in main
    ensure(module, base, params['state'], params['name'], params['autoremove'])
  File "/tmp/ansible_EsBR_K/ansible_module_dnf.py", line 378, in ensure
    base.group_install(group, dnf.const.GROUP_PACKAGE_TYPES)
  File "/usr/lib/python2.7/site-packages/dnf/base.py", line 1460, in group_install
    strict)
  File "/usr/lib/python2.7/site-packages/dnf/comps.py", line 90, in install_or_skip
    return install_fnc(grp_or_env_id, types, exclude, strict)
  File "/usr/lib/python2.7/site-packages/dnf/comps.py", line 600, in _group_install
    raise ValueError(_("Group_id '%s' does not exist.") % ucd(group_id))
ValueError: Group_id '<dnf.comps.Group object at 0x7f75df2b26d0>' does not exist.
localhost | FAILED! => {
    "changed": false, 
    "failed": true, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_EsBR_K/ansible_module_dnf.py\", line 543, in <module>\n    main()\n  File \"/tmp/ansible_EsBR_K/ansible_module_dnf.py\", line 539, in main\n    ensure(module, base, params['state'], params['name'], params['autoremove'])\n  File \"/tmp/ansible_EsBR_K/ansible_module_dnf.py\", line 378, in ensure\n    base.group_install(group, dnf.const.GROUP_PACKAGE_TYPES)\n  File \"/usr/lib/python2.7/site-packages/dnf/base.py\", line 1460, in group_install\n    strict)\n  File \"/usr/lib/python2.7/site-packages/dnf/comps.py\", line 90, in install_or_skip\n    return install_fnc(grp_or_env_id, types, exclude, strict)\n  File \"/usr/lib/python2.7/site-packages/dnf/comps.py\", line 600, in _group_install\n    raise ValueError(_(\"Group_id '%s' does not exist.\") % ucd(group_id))\nValueError: Group_id '<dnf.comps.Group object at 0x7f75df2b26d0>' does not exist.\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE", 
    "rc": 0
}

If there is any information necessary to resolve the issue I would happily provide it.

@ansibot
Copy link
Contributor

ansibot commented Jul 16, 2017

@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 bug_report module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Jul 16, 2017
@poettler-ric
Copy link
Author

I just wanted to point out that this behavior is also present in ansible 2.3.1.0, which is currently available in the Fedora repos.

@alikins
Copy link
Contributor

alikins commented Jul 17, 2017

(traceback reformatted for easier reading)

Traceback (most recent call last):
  File "/tmp/ansible_EsBR_K/ansible_module_dnf.py", line 543, in <module>
    main()
  File "/tmp/ansible_EsBR_K/ansible_module_dnf.py", line 539, in main
    ensure(module, base, params['state'], params['name'], params['autoremove'])
  File "/tmp/ansible_EsBR_K/ansible_module_dnf.py", line 378, in ensure
    base.group_install(group, dnf.const.GROUP_PACKAGE_TYPES)
  File "/usr/lib/python2.7/site-packages/dnf/base.py", line 1460, in group_install
    strict)
  File "/usr/lib/python2.7/site-packages/dnf/comps.py", line 90, in install_or_skip
    return install_fnc(grp_or_env_id, types, exclude, strict)
  File "/usr/lib/python2.7/site-packages/dnf/comps.py", line 600, in _group_install
    raise ValueError(_("Group_id '%s' does not exist.") % ucd(group_id))
ValueError: Group_id '<dnf.comps.Group object at 0x7f75df2b26d0>' does not exist.

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Jul 17, 2017
@alikins alikins added the affects_2.3 This issue/PR affects Ansible v2.3 label Jul 17, 2017
@alikins
Copy link
Contributor

alikins commented Jul 17, 2017

ping @ignatenkobrain

@andrewrothstein
Copy link
Contributor

I'm seeing the same problem with Ansible v2.3.1.0 on Fedora 26.

andrewrothstein added a commit to andrewrothstein/ansible-luajit that referenced this issue Jul 17, 2017
andrewrothstein added a commit to andrewrothstein/ansible-redis that referenced this issue Jul 18, 2017
@dirkdavidis
Copy link

i have opened an bug request at bugzilla.redhat.com for that as well on saturday

@kees-closed
Copy link

Same here, also on Fedora 26.

[user@defiant ansible (rpi_merge *)]$ ansible defiant.home.lan -i inventory.ini -m dnf -a "name='@development-tools' state=present" -K --ask-vault-pass -b -v
Using /etc/ansible/ansible.cfg as config file
SUDO password: 
Vault password: 
defiant.home.lan | FAILED! => {
    "changed": false, 
    "failed": true, 
    "module_stderr": "Shared connection to defiant.home.lan closed.\r\n", 
    "module_stdout": "\r\nTraceback (most recent call last):\r\n  File \"/tmp/ansible_sio87d/ansible_module_dnf.py\", line 493, in <module>\r\n    main()\r\n  File \"/tmp/ansible_sio87d/ansible_module_dnf.py\", line 489, in main\r\n    ensure(module, base, params['state'], params['name'])\r\n  File \"/tmp/ansible_sio87d/ansible_module_dnf.py\", line 350, in ensure\r\n    base.group_install(group, dnf.const.GROUP_PACKAGE_TYPES)\r\n  File \"/usr/lib/python2.7/site-packages/dnf/base.py\", line 1460, in group_install\r\n    strict)\r\n  File \"/usr/lib/python2.7/site-packages/dnf/comps.py\", line 90, in install_or_skip\r\n    return install_fnc(grp_or_env_id, types, exclude, strict)\r\n  File \"/usr/lib/python2.7/site-packages/dnf/comps.py\", line 600, in _group_install\r\n    raise ValueError(_(\"Group_id '%s' does not exist.\") % ucd(group_id))\r\nValueError: Group_id '<dnf.comps.Group object at 0x7f6d7e426cd0>' does not exist.\r\n", 
    "msg": "MODULE FAILURE", 
    "rc": 0
}

@akskos
Copy link

akskos commented Jul 23, 2017

I'm having similar problem after upgrading to Fedora 26

akseli@electric: ~$ ansible localhost -m dnf -a "name='@virtualization' state=latest" -b --ask-become-pass
SUDO password: 
 [WARNING]: provided hosts list is empty, only localhost is available

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'id'
localhost | FAILED! => {
    "changed": false, 
    "failed": true, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_Vpm_YY/ansible_module_dnf.py\", line 493, in <module>\n    main()\n  File \"/tmp/ansible_Vpm_YY/ansible_module_dnf.py\", line 489, in main\n    ensure(module, base, params['state'], params['name'])\n  File \"/tmp/ansible_Vpm_YY/ansible_module_dnf.py\", line 374, in ensure\n    base.group_upgrade(group)\n  File \"/usr/lib/python2.7/site-packages/dnf/base.py\", line 1531, in group_upgrade\n    trans = solver._group_upgrade(grp_id)\n  File \"/usr/lib/python2.7/site-packages/dnf/comps.py\", line 634, in _group_upgrade\n    p_grp = self.persistor.group(group.id)\nAttributeError: 'NoneType' object has no attribute 'id'\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE", 
    "rc": 0
}

@jasontibbitts
Copy link
Contributor

jasontibbitts commented Jul 25, 2017

I did some digging into this since it's blocking my Fedora 26 rollout. I'm no expert on ansible or dnf or the dnf API or anything, really, but I did learn how to explode and tweak the code ansible runs on the remote host and came down to a couple of instances of base.group_install which are not correct. Basically base.group_install(group, dnf.const.GROUP_PACKAGE_TYPES) is incorrect; group is the result of a call to base.comps.group_by_pattern, which gives you a dnf.comps.Group object. But the group_install function wants a string as its first argument. Perhaps the old DNF api had a stringification method for that object, but whatever is in F26 doesn't. I'll have to look into that.

Using base.group_install(group.id, dnf.const.GROUP_PACKAGE_TYPES) makes things work. I have not yet tried this on a machine with dnf 1, though.

Edit: verified with DNF upstream that using a Group object there was deprecated since dnf 1.1 and perhaps earlier, and the compatibility code was intentionally removed in 2.0.0. The compat code was added in rpm-software-management/dnf@fdacdb8 and I'm having trouble figuring out when it was removed since the blame view doesn't show that.

I'll work up a PR after doing some testing.

@Ichimonji10
Copy link
Contributor

Ichimonji10 commented Aug 7, 2017

I can reproduce.

COMPONENT NAME

dnf

ANSIBLE VERSION
$ ansible --version
ansible 2.3.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.13 (default, Jul 21 2017, 03:24:34) [GCC 7.1.1 20170630]
CONFIGURATION

/etc/ansible.cfg is untouched. It is as provided by the Arch Linux package. No Ansible-related variables are set. Verified with:

$ env | grep -i ansible
$
OS / ENVIRONMENT

My control host is an up-to-date Arch Linux system. My managed hosts are a variety of Fedora and RHEL VMs. The Fedora 26 "server spin" VMs are the only ones causing issues. Ignoring details like snapshots, clones, virt-sysprep, etc, each system is built by doing the following:

  1. Download Fedora 26 server from here.
  2. Create a VM, and install an up-to-date system from the images, with the default set of packages.
  3. Set the system's hostname and install SSH keys.

Here's the version of DNF installed on the F26 system:

# dnf --version
2.6.2
  Installed: dnf-0:2.6.2-1.fc26.noarch at Wed 26 Jul 2017 05:46:51 PM GMT
  Built    : Fedora Project at Mon 24 Jul 2017 02:08:42 PM GMT

  Installed: rpm-0:4.13.0.1-5.fc26.x86_64 at Wed 26 Jul 2017 05:46:50 PM GMT
  Built    : Fedora Project at Tue 27 Jun 2017 08:17:41 AM GMT
STEPS TO REPRODUCE

To reproduce the issue, use Ansible's DNF module to install a package group. For example: ansible all -i fedora-26-test, -m dnf -a 'name=@LibreOffice state=present'.

EXPECTED RESULTS

Ansible's DNF module should be able to install package groups.

ACTUAL RESULTS
$ ansible all -i fedora-26-test, -m dnf -a 'name=@LibreOffice state=present'
fedora-26-test | FAILED! => {
    "changed": false, 
    "failed": true, 
    "module_stderr": "Shared connection to fedora-26-test closed.\r\n", 
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_4oGv_p/ansible_module_dnf.py\", line 493, in <module>\r\n    main()\r\n  File \"/tmp/ansible_4oGv_p/ansible_module_dnf.py\", line 489, in main\r\n    ensure(module, base, params['state'], params['name'])\r\n  File \"/tmp/ansible_4oGv_p/ansible_module_dnf.py\", line 350, in ensure\r\n    base.group_install(group, dnf.const.GROUP_PACKAGE_TYPES)\r\n  File \"/usr/lib/python2.7/site-packages/dnf/base.py\", line 1526, in group_install\r\n    strict)\r\n  File \"/usr/lib/python2.7/site-packages/dnf/comps.py\", line 90, in install_or_skip\r\n    return install_fnc(grp_or_env_id, types, exclude, strict)\r\n  File \"/usr/lib/python2.7/site-packages/dnf/comps.py\", line 600, in _group_install\r\n    raise ValueError(_(\"Group_id '%s' does not exist.\") % ucd(group_id))\r\nValueError: Group_id '<dnf.comps.Group object at 0x7f5510c42390>' does not exist.\r\n", 
    "msg": "MODULE FAILURE", 
    "rc": 0
}

Here's the prettified output of module_stdout:

Traceback (most recent call last):                         
  File "/tmp/ansible_4oGv_p/ansible_module_dnf.py", line 493, in <module>                                              
    main()                                                 
  File "/tmp/ansible_4oGv_p/ansible_module_dnf.py", line 489, in main                                                  
    ensure(module, base, params['state'], params['name'])  
  File "/tmp/ansible_4oGv_p/ansible_module_dnf.py", line 350, in ensure                                                
    base.group_install(group, dnf.const.GROUP_PACKAGE_TYPES)                                                           
  File "/usr/lib/python2.7/site-packages/dnf/base.py", line 1526, in group_install                                     
    strict)                                                
  File "/usr/lib/python2.7/site-packages/dnf/comps.py", line 90, in install_or_skip                                    
    return install_fnc(grp_or_env_id, types, exclude, strict)                                                          
  File "/usr/lib/python2.7/site-packages/dnf/comps.py", line 600, in _group_install                                    
    raise ValueError(_("Group_id '%s' does not exist.") % ucd(group_id))                                               
ValueError: Group_id '<dnf.comps.Group object at 0x7f5510c42390>' does not exist.

@mkrizek
Copy link
Contributor

mkrizek commented Aug 8, 2017

@Ichimonji10 That is already fixed in #27302 and #27324. Should be in the 2.3.2 release.

@mkrizek mkrizek closed this as completed Aug 8, 2017
preethit pushed a commit to preethit/pulp_packaging that referenced this issue Nov 30, 2017
Ansible is currently unable to install package groups on Fedora 26. Work
around this limitation. See:
ansible/ansible#26868
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.3 This issue/PR affects Ansible v2.3 affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

No branches or pull requests

10 participants