MODULE FAILURE when adding "become: true" to a task

189 views
Skip to first unread message

Shubham Shrivastav

unread,
Apr 4, 2023, 6:02:28 PM4/4/23
to Ansible Project
Hi team, 
I'm trying to install an rpm package to OpenSUSE
OS config:
NAME="SLES"
VERSION="12-SP4"
VERSION_ID="12.4"
PRETTY_NAME="SUSE Linux Enterprise Server 12 SP4"
ID="sles"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sles:12:sp4"

I'm able to copy it successfully:

- name: Copy promtail rpm file to server
ansible.builtin.copy:
src: rpm/promtail-2.7.4.x86_64.rpm
dest: /tmp/promtail-2.7.4.x86_64.rpm


But installation doesn't work for me

- name: Install promtail package locally
community.general.zypper:
name: /tmp/promtail-2.7.4.x86_64.rpm
state: present

FAILED! => {"changed": false, "cmd": ["/usr/bin/zypper", "--quiet", "--non-interactive",
"--xmlout", "install", "--type", "package", "--auto-agree-with-licenses", "--no-recommends",
"--", "/tmp/promtail-2.7.4.x86_64.rpm"], "msg": "Zypper run command failed with return code 5.",
"rc": 5, "stderr": "", "stderr_lines": [], "stdout": "<?xml version='1.0'?>\n<stream>\n<message type=
\"error\">Root privileges are required for installing or uninstalling packages.</message>\n</stream>\n",
"stdout_lines": ["<?xml version='1.0'?>",
"<stream>", "<message type=\"error\">Root privileges are required for installing or uninstalling packages.</message>",
"</stream>"]}

When I run it without become: true I get the below error asking me to sudo
Root privileges are required for installing or uninstalling packages

When I add become, it gives me MODULE error:

    "module_stderr": "OpenSSH_8.6p1, LibreSSL 3.3.6\r\ndebug1: Reading configuration data /Users/sshrivastava/.ssh/config\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files\r\ndebug1: /etc/ssh/ssh_config line 54: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 10.43.50.132 is address\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/sshrivastava/.ssh/known_hosts'\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/Users/sshrivastava/.ssh/known_hosts2'\r\ndebug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling\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 = 82404\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 1\r\nShared connection to 10.43.50.132 closed.\r\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

These errors are vague and I have no idea what's happening.

I also tried this on the service module in ansible:
- name: Enabling promtail service
ansible.builtin.service:
name: sshd
state: started
enabled: yes
become: true


Ended up getting the same error

fatal: []: FAILED! => {
    "changed": false,
    "module_stderr": "OpenSSH_8.6p1, LibreSSL 3.3.6\r\ndebug1: Reading configuration data /Users/sshrivastava/.ssh/config\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files\r\ndebug1: /etc/ssh/ssh_config line 54: Applying options for *\r\ndebug2: resolve_canonicalize: hostname is address\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/sshrivastava/.ssh/known_hosts'\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/Users/sshrivastava/.ssh/known_hosts2'\r\ndebug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling\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 = 82912\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 1\r\nShared connection to closed.\r\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}


Seems this might be an OS compatibility issue. It works on other platforms just not OpenSUSE.

I am able to run these commands successfully on the remote server using sudo.
Not sure where the problem is.

Below are the Specifications:

Remote python version: 3.4 and 2.7 (currently using 2.7)
ansible_python_interpreter=/usr/bin/python

Workstation ansible version: 
ansible [core 2.14.4]
  config file = /Users/sshrivastava/work/ansible/ansible/promtail/ansible.cfg
  configured module search path = ['/Users/sshrivastava/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/Cellar/ansible/7.4.0/libexec/lib/python3.11/site-packages/ansible
  ansible collection location = /Users/sshrivastava/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.11.2 (main, Mar 24 2023, 00:13:59) [Clang 14.0.0 (clang-1400.0.29.202)] (/opt/homebrew/Cellar/ansible/7.4.0/libexec/bin/python3.11)
  jinja version = 3.1.2
  libyaml = True

Sachin Yadav

unread,
Apr 10, 2023, 4:35:13 AM4/10/23
to Ansible Project
use become_user= root
Reply all
Reply to author
Forward
0 new messages