error using "become"?

318 views
Skip to first unread message

Mike Eggleston

unread,
Sep 18, 2019, 10:15:28 AM9/18/19
to Ansible Project
GNU/Linux: CentOS Linux release 7.6.1810 (Core)

Playbook:
---
- hosts: all
  gather_facts: no
  vars:
    md5script: /pawn/bin/md5verify.sh

  tasks:
    - name: test (1/3)
      command: uptime

    - name: test (2/3)
      command: uptime
      become: yes

    - name: test (2/3)
      command: ls -l {{ md5script }}
      become: yes

Results:
$ ansible-playbook --limit appsrv98 x.yml

PLAY [all] **************************************************************************************************************************************************

TASK [test (1/3)] *******************************************************************************************************************************************
changed: [appsrv98]

TASK [test (2/3)] *******************************************************************************************************************************************
 [WARNING]: Module invocation had junk after the JSON data: usage: sudo -e [-S] [-p prompt] [-u username|#uid] file ...

fatal: [appsrv98]: FAILED! => {"changed": false, "module_stderr": "sudo: illegal option `-n'\n", "module_stdout": "usage: sudo -h | -K | -k | -L | -l | -V | -v\nusage: sudo [-bEHPS] [-p prompt] [-u username|#uid] [VAR=value]\n            {-i | -s | <command>}\nusage: sudo -e [-S] [-p prompt] [-u username|#uid] file ...\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

PLAY RECAP **************************************************************************************************************************************************
appsrv98                   : ok=1    changed=1    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0


shell returned 2

Remote sudo version:
$ sudo -V
Sudo version 1.8.23
Sudoers policy plugin version 1.8.23
Sudoers file grammar version 46
Sudoers I/O plugin version 1.8.23

Local command Ansible version:
$ [meggle1@dvlnx108 ~]$ rpm -qi ansible
Name        : ansible
Version     : 2.8.5
Release     : 1.el7.ans
Architecture: noarch
Install Date: Fri 13 Sep 2019 07:49:12 AM CDT
Group       : Development/Libraries
Size        : 87783909
License     : GPLv3+
Signature   : RSA/SHA1, Thu 12 Sep 2019 06:02:36 PM CDT, Key ID b84e339c442667a9
Source RPM  : ansible-2.8.5-1.el7.ans.src.rpm
Build Date  : Thu 12 Sep 2019 06:01:11 PM CDT
Build Host  : jenkins-jnlp-agent-457gk
Relocations : (not relocatable)
URL         : https://www.ansible.com
Summary     : SSH-based application deployment, configuration management, and IT orchestration platform
Description :

Ansible is a radically simple model-driven configuration management,
multi-node deployment, and orchestration engine. Ansible works
over SSH and does not require any software or daemons to be installed
on remote nodes. Extension modules can be written in any language and
are transferred to managed machines automatically.


Ideas why it's failing?

Mike Eggleston

unread,
Sep 18, 2019, 10:52:28 AM9/18/19
to Ansible Project
Removed Ansible 2.8.5 and installed Ansible 2.8.5.
Same error.
More simple playbook.
Changed "become: yes" to "become:true".
Same error:

---
- hosts: appsrv98

  tasks:
    - name: test (1/2)
      command: uptime

    - name: test (2/2)
      command: uptime
      become: true

Matt Martz

unread,
Sep 18, 2019, 10:57:03 AM9/18/19
to ansible...@googlegroups.com
What is the version of sudo installed on `appsrv98`?

I have a feeling that `appsrv98` is a really old machine, maybe running EL5 or something like that.  In which case, even if you can get past the sudo issue, you'll run into python version issues as well.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0df60808-3f2b-4119-9d5a-cfe5ed1b9ff2%40googlegroups.com.


--
Matt Martz
@sivel
sivel.net

Mike Eggleston

unread,
Sep 18, 2019, 11:06:09 AM9/18/19
to Ansible Project
That's an interesting thought.
Ansible isn't required on the remote machine; python is though.
Here's on the remote machine:

DEV App Server 98
appsrv98:meggle1:/home/meggle1> rpm -qi ansible
package ansible is not installed
DEV App Server 98
appsrv98:meggle1:/home/meggle1> python -V
Python 2.7.16
DEV App Server 98
appsrv98:meggle1:/home/meggle1>

To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.

Mike Eggleston

unread,
Sep 18, 2019, 11:21:39 AM9/18/19
to Ansible Project
Sudo is too old.
This works:

---
- hosts: appsrv98

  tasks:
    - name: test (1/2)
      command: uptime

    - name: test (2/2)
      command: uptime
      become: true
      become_flags: -H -S

Mike Eggleston

unread,
Sep 18, 2019, 11:24:02 AM9/18/19
to Ansible Project
Matt, thanks for your help.

Mike
Reply all
Reply to author
Forward
0 new messages