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

redhat_subscription: Fix usage of ConfigParser #54815

Merged
merged 1 commit into from
Apr 9, 2019

Conversation

cnsnyder
Copy link
Contributor

@cnsnyder cnsnyder commented Apr 3, 2019

SUMMARY

This PR fixes an issue in the usage of configparser in the redhat_subscription module. The configparser module is imported from ansible.module_utils.six.moves as of f75ffe4. After that change was made, any attempt to use the redhat_subscription module with an ansible_python_interpreter of python 3+ fail with the following:

FAILED! => {"changed": false, "msg": "Failed to register with 'https://subscription.rhsm.stage.redhat.com/subscription': option values must be strings"}

The error ultimately comes from passing integers to ConfigParser.set where strings were expected when updating the rhsm and rhn yum plugin configurations (under /etc/yum/pluginconf.d/).

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

redhat_subscription

ADDITIONAL INFORMATION

This issue seems only to surface when a python 3 interpreter is used on the target machine(s).
Here's a sample inventory file for my reproducer (named inv):

[all:vars]
ansible_connection=ssh
ansible_user=root
ansible_ssh_pass=redhat

[local]
192.168.121.179 ansible_python_interpreter="/usr/bin/env python3"

The playbook used is as follows (named test.yml):

---
- hosts: "local"
  become: yes
  tasks:
    - name: Register the machine
      redhat_subscription:
        state: present
        server_hostname: https://candlepin.example.com:8443/candlepin
        username: admin
        password: admin
        auto_attach: true

With these files in place execute: ansible-playbook test.yml -i ./inv
Output:

TASK [Register with stage] *******************************************************************************************************************************************************************
fatal: [192.168.121.179]: FAILED! => {"changed": false, "msg": "Failed to register with 'https://candlepin.example.com:8443/candlepin': option values must be strings"}

@ansibot
Copy link
Contributor

ansibot commented Apr 3, 2019

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. community_review In order to be merged, this PR must follow the community review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_contributor This PR is the first contribution by a new community member. packaging Packaging category python3 small_patch support:community This issue/PR relates to code supported by the Ansible community. labels Apr 3, 2019
@mkrizek mkrizek requested a review from samdoran April 4, 2019 05:58
@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label Apr 4, 2019
Copy link
Contributor

@samdoran samdoran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create a changelog fragment. See this fragment as an example.

@cnsnyder
Copy link
Contributor Author

cnsnyder commented Apr 8, 2019

@samdoran I've added a changelog fragment as requested. Is there anything else this PR needs?

@mkrizek mkrizek merged commit 09f68fc into ansible:devel Apr 9, 2019
@mkrizek
Copy link
Contributor

mkrizek commented Apr 9, 2019

@cnsnyder Thanks!

goneri pushed a commit to goneri/ansible that referenced this pull request Apr 16, 2019
goneri pushed a commit to goneri/ansible that referenced this pull request Apr 16, 2019
abadger pushed a commit that referenced this pull request Apr 16, 2019
@ansible ansible locked and limited conversation to collaborators Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. community_review In order to be merged, this PR must follow the community review workflow. module This issue/PR relates to a module. new_contributor This PR is the first contribution by a new community member. packaging Packaging category python3 support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants