Permissions issue, cannot become root

94 views
Skip to first unread message

lask001

unread,
Jun 28, 2017, 4:49:28 AM6/28/17
to Ansible Project
Been banging my head against this since yesterday, hoping someone is able to shed some insight on my issues.

I have a simple role that I'm trying to install java with:

---
- name: Install JDK
  yum
:
    name
: /tmp/jdk.rpm
    state
: present


This works on my test servers without issue. I am trying to run this on a real server at this point and am running into issues with permissions.

My inventory file is basic:

[severs]
host1

and my playbook is as follows:
---
- name: Install JDK
  hosts: servers
  remote_user: myuser
  become: true
  become_user: myuser
  become_method: sudo
  become_flags: '-s /bin/sh'
  roles:
  - jdk

I've tried quite a few different combinations of setting the become_user to nobody, root, leaving it out, and so on, but have had no success. If I login to the server manually and run a sudo yum install /tmp/jdk as 'myuser' it works fine, and the playbook will actually run after (stating there is nothing to change). Does anyone have any suggestions?

Dick Davies

unread,
Jun 28, 2017, 6:28:40 AM6/28/17
to ansible list
become_user is the user you sudo to, that should probably not be the
same as remote_user
(or it's a bit of a waste of time).
> --
> 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 post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/cff84da6-3154-4018-9ec2-278e734ff741%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Daniel JD

unread,
Jun 30, 2017, 4:08:13 PM6/30/17
to Ansible Project
To install packages you need to be root. So set become_user to root. Now you need to give ansible your sudo password via "-K". You dont need the become_method or become_flags

Brian Coca

unread,
Jul 3, 2017, 11:14:44 PM7/3/17
to Ansible Project
you don't even need become_user: root as that is the default.

----------
Brian Coca

prakash ranjan

unread,
Aug 11, 2017, 2:58:47 PM8/11/17
to Ansible Project
I am also facing the same issue. tried several options but no solution.

Unable to take privilege of "sudo su -".

This is content of my playbook. Commented ones shows that I have tried those options. I have also tried many options with command lines.

---
- hosts: all
#  remote_user: root
#  become: yes
#  become_method: sudo
#  become_exe: "sudo su -"
  become_user: root
  tasks:
     - name: run adhoc command which required root priviledge
#       command: /usr/bin/cat /root/ab
        shell: su monitor -l -c "/usr/bin/cat /root/ab"
#       remote_user: root
#       become: yes #true
#       become_method: sudo
#       become_flags: '-u' # '-s /bin/sh'
#       become_user: root

-Prakash
Reply all
Reply to author
Forward
0 new messages