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

hostname module cannot be used on platform Linux (Red hat enterprise linux) #31811

Closed
mbruzek opened this issue Oct 16, 2017 · 6 comments · Fixed by #31839
Closed

hostname module cannot be used on platform Linux (Red hat enterprise linux) #31811

mbruzek opened this issue Oct 16, 2017 · 6 comments · Fixed by #31839
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:community This issue/PR relates to code supported by the Ansible community.

Comments

@mbruzek
Copy link
Contributor

mbruzek commented Oct 16, 2017

ISSUE TYPE
  • Bug Report
COMPONENT NAME

hostname

ANSIBLE VERSION

I tried with Ansible 2.3.2 and 2.4.0.0 both versions failed to set the hostname on a RHEL 7.5 system.

ansible 2.3.2.0                                                                           
  config file = /home/cloud-user/test/ansible.cfg                                                                    
  configured module search path = Default w/o overrides                                   
  python version = 2.7.5 (default, Oct 11 2017, 10:12:42) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]  
ansible 2.4.0.0                              
  config file = /home/cloud-user/test/ansible.cfg                                         
  configured module search path = [u'/home/cloud-user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']                                                             
  ansible python module location = /home/cloud-user/test-ansible/lib/python2.7/site-packages/ansible                                                                                
  executable location = /home/cloud-user/test-ansible/bin/ansible                         
  python version = 2.7.5 (default, Oct 11 2017, 10:12:42) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] 
CONFIGURATION
[defaults]
inventory=inventory

inventory

[all:vars]
ansible_private_key_file=~/scale-ci/key.private
[rhel74]
172.21.0.120 ansible_user=cloud-user
[rhel75]
172.21.0.116 ansible_user=openshift
OS / ENVIRONMENT

Running Ansible from RHEL 7.4 server

NAME="Red Hat Enterprise Linux Server"
VERSION="7.4 (Maipo)"
ID="rhel"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.4"
PRETTY_NAME="Red Hat Enterprise Linux Server 7.4 (Maipo)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:7.4:GA:server"
HOME_URL="https://www.redhat.com/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"

REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 7"
REDHAT_BUGZILLA_PRODUCT_VERSION=7.4
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="7.4"

Controlling a RHEL 7.5 system.

VERSION="7.5 (Server)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="7.5"
ANSI_COLOR="0;31"
HOME_URL="https://www.redhat.com/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 7"
REDHAT_BUGZILLA_PRODUCT_VERSION="7.5"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="7.5 Beta"
PRIVACY_POLICY_URL="http://www.redhat.com/en/about/privacy-policy"
NAME="Red Hat Enterprise Linux Server"
PRETTY_NAME="Red Hat Enterprise Linux Server 7.5 beta"
VARIANT="Server"
VARIANT_ID="server"
CPE_NAME="cpe:/o:redhat:enterprise_linux:7:beta:server"
SUMMARY

The hostname module does not work on RHEL version 7.5. This is the version of RHEL that we get when `yum update' is run.

STEPS TO REPRODUCE
  • Create a RHEL 7.4 virtual image
  • Issue the yum update command
  • Verify the release updated to 7.5 cat /etc/*release
  • Run an a playbook with the hostname module in it to this host.
---
- name: Playbook to test hostname on RHEL servers
  hosts: rhel75 
  tasks:
    - name: Set the hostname of the RHEL server
      become: true
      hostname: 
        name: rhel75
EXPECTED RESULTS

I expected the hostname module to work with every release of RHEL.

ACTUAL RESULTS
...
<172.21.0.116> (0, '', 'OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013\r\ndebug1: Reading configuration data /home/stack/.ssh/config\r\ndebug1: /home/stack/.ssh/config line 1: Applying options for *\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 56: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 27683\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
<172.21.0.116> ESTABLISH SSH CONNECTION FOR USER: openshift
<172.21.0.116> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/stack/scale-ci/key.private"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=openshift -o ConnectTimeout=10 -o ControlPath=/home/stack/.ansible/cp/557fe54933 -tt 172.21.0.116 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-casumnvzxwrlrsbotyokylpaisacoagc; /usr/bin/python /home/openshift/.ansible/tmp/ansible-tmp-1508186346.51-190181544923286/hostname.py; rm -rf "/home/openshift/.ansible/tmp/ansible-tmp-1508186346.51-190181544923286/" > /dev/null 2>&1'"'"'"'"'"'"'"'"' && sleep 0'"'"''
<172.21.0.116> (0, '\r\n{"msg": "hostname module cannot be used on platform Linux (Red hat enterprise linux)", "failed": true, "invocation": {"module_args": {"name": "rhel75"}}}\r\n', 'OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013\r\ndebug1: Reading configuration data /home/stack/.ssh/config\r\ndebug1: /home/stack/.ssh/config line 1: Applying options for *\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 56: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: e

<172.21.0.116> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/stack/scale-ci/key.private"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=openshift -o ConnectTimeout=10 -o ControlPath=/home/stack/.ansible/cp/557fe54933 -tt 172.21.0.116 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-casumnvzxwrlrsbotyokylpaisacoagc; /usr/bin/python /home/openshift/.ansible/tmp/ansible-tmp-1508186346.51-190181544923286/hostname.py; rm -rf "/home/openshift/.ansible/tmp/ansible-tmp-1508186346.51-190181544923286/" > /dev/null 2>&1'"'"'"'"'"'"'"'"' && sleep 0'"'"''
<172.21.0.116> (0, '\r\n{"msg": "hostname module cannot be used on platform Linux (Red hat enterprise linux)", "failed": true, "invocation": {"module_args": {"name": "rhel75"}}}\r\n', 'OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013\r\ndebug1: Reading configuration data /home/stack/.ssh/config\r\ndebug1: /home/stack/.ssh/config line 1: Applying options for *\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 56: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 27683\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 172.21.0.116 closed.\r\n')
fatal: [172.21.0.116]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_args": {
            "name": "rhel75"
        }
    }, 
    "msg": "hostname module cannot be used on platform Linux (Red hat enterprise linux)"
}
        to retry, use: --limit @/home/stack/matt_test/playbook.retry

PLAY RECAP *************************************************************************************************************************************************************************
172.21.0.116               : ok=1    changed=0    unreachable=0    failed=1  
@ansibot
Copy link
Contributor

ansibot commented Oct 16, 2017

@ansibot ansibot added affects_2.3 This issue/PR affects Ansible v2.3 bug_report module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. labels Oct 16, 2017
@mbruzek
Copy link
Contributor Author

mbruzek commented Oct 16, 2017

The error the user gets is: "hostname module cannot be used on platform Linux (Red hat enterprise linux)"

This is interesting. Looking at the code I can not figure out how that string is getting constructed. The error message we are seeing is from hostname.py line 89:
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/system/hostname.py#L89
Note the lower case "h" in "Red hat" (which seems wrong) and the string ends with "linux". Lines 615 and 620 end with "linux server" and "linux workstation":
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/system/hostname.py#L615
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/system/hostname.py#L620

Older releases of Ansible have slightly different line numbers, but the same strings.

I am unable to find a full string in this repository like this "Red hat enterprise linux" with this lower case "h" and ending in "linux". None of the strings in the /etc/*release files on this 7.5 system have the lower case "h" either, so I don't think Ansible is pulling the string from an etc release file.

@mkrizek
Copy link
Contributor

mkrizek commented Oct 17, 2017

@mbruzek can you please try #31839 if that fixes your issue?

@alikins
Copy link
Contributor

alikins commented Oct 17, 2017

@mbruzek The 'Red hat enterprise linux' is likely coming from module_utils.basic.get_distribution (https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/basic.py#L262). It does a .capitalize() on the distro name.

@alikins alikins added this to Nominated in 2.4.x Blocker List Oct 17, 2017
@mbruzek
Copy link
Contributor Author

mbruzek commented Oct 18, 2017

I was unable to test the original branch (because it was deleted) but I tested ansible:devel and did not get the same hostname issue. I believe this fix resolved the issue.

@mbruzek
Copy link
Contributor Author

mbruzek commented Oct 18, 2017

We have some playbooks that do not work with the latest version of Ansible. Any possibility of porting this change back to earlier versions of Ansible, such as 2.3?
@mkrizek @alikins

@ansibot ansibot added the bug This issue/PR relates to a bug. label 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:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants