sudo twice become method for Ansible

Unix & Linux Asked on January 5, 2022

I have to deal with a setup in "/etc/sudoers" that I can’t change because the servers in question are managed by a different team and they don’t want to change it.

I have root access only by sudoing to another account first. My account is only allowed to run the specific command "sudo su – admin" (no additional arguments can be appended). Then, as user "admin", I can run any root commands normally with sudo (e.g., "sudo vi /etc/shadow", etc.) or open a root shell with "sudo -s" or "sudo su -", etc.

I want to run Ansible ad-hoc commands and playbooks as root (e.g., "become: yes") on these servers from a different server that I control, but it would require that Ansible first run "sudo su – admin", then run the normal "sudo" command.

I know you can create custom become methods. This seems to me the way to solve this problem, but the specific solution is beyond me. Can anyone help with this?

BTW, if it helps, "NOPASSWD:" is set for both my account and "admin" in "/etc/sudoers".

Add your own answers!

Related Questions

Linux on Omnibook 300

1  Asked on December 3, 2020 by tomas-by


Auto-mounting external hard drive not working

1  Asked on December 3, 2020 by ppleassassin


Firefox temporary files

2  Asked on December 3, 2020 by daniele


Full text of commands cut off in /var/log/secure

1  Asked on December 2, 2020 by user3427070


how can i use mod_wsgi for apache 2.4.6 in centos 6.10 system

0  Asked on December 1, 2020 by touqir-rasul


Missing glyphs with urxvt-unicode

2  Asked on December 1, 2020 by luigi-pertoldi


How to upgrade vim only in my own directory?

0  Asked on December 1, 2020 by c-yj


cross-compiling for 32-bit architecture on 64-bit (FreeBSD)

1  Asked on November 30, 2020 by sephiroth


Environment variable in LXSession autostart file?

2  Asked on November 30, 2020 by paul-d-smith


How to trick a program into thinking there is no X server running

2  Asked on November 29, 2020 by luka-aleksi


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP