Super User 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".
you can use --become --become-user admin
on ansible adhoc or use yaml below on ansible playbook.
- name: Run a command as nobody
command: somecommand
become: yes
become_user: admin
become_method: su
if you need spesific become method you can use --become-method su
, the default --become-method
is sudo
.
Answered by nothinux on January 5, 2022
4 Asked on January 14, 2021 by malloc
2 Asked on January 14, 2021 by linux_user_11880
3 Asked on January 14, 2021 by tess-in-oz
3 Asked on January 13, 2021 by tal-galili
2 Asked on January 13, 2021 by surfmadpig
0 Asked on January 13, 2021 by questionto42
4 Asked on January 13, 2021
0 Asked on January 13, 2021 by nstone101
12 Asked on January 12, 2021 by rdhainaut
0 Asked on January 12, 2021 by square_eyes
router wireless access point wireless networking wireless router
3 Asked on January 12, 2021 by asheesh-kubde
1 Asked on January 12, 2021 by andreas
1 Asked on January 12, 2021 by dhruv-garg
5 Asked on January 12, 2021 by lazer
1 Asked on January 11, 2021 by melvin-lai
3 Asked on January 11, 2021 by jakub
0 Asked on January 11, 2021
1 Asked on January 10, 2021 by darshan-l
Get help from others!
Recent Answers
Recent Questions
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP