Skip to content

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

@mbruzek

Description

@mbruzek
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  

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects_2.3This issue/PR affects Ansible v2.3affects_2.4This issue/PR affects Ansible v2.4bugThis issue/PR relates to a bug.moduleThis issue/PR relates to a module.support:communityThis issue/PR relates to code supported by the Ansible community.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions