gpt4 book ai didi

ansible - 登录 Ansible 后切换用户

转载 作者:行者123 更新时间:2023-12-01 04:57:03 25 4
gpt4 key购买 nike

我需要以 root 身份运行各种 ansible 任务,但由于安全限制,我只能通过运行命令“super su-root”并输入密码来执行此操作。不允许 sudo。像这样登录后可以切换用户吗?

最佳答案

对的,这是可能的:

Directives

These can be set from play to task level, but are overriden by connection variables as they can be host specific.

become
set to ‘true’/’yes’ to activate privilege escalation.

become_user
set to user with desired privileges, the user you ‘become’, NOT the user you login as. Does NOT imply become: yes, to allow it to be set at host level.

become_method
at play or task level overrides the default method set in ansible.cfg, set to ‘sudo’/’su’/’pbrun’/’pfexec’/’doas’

Connection variables
Each allows you to set an option per group and/or host, these are normally defined in inventory but can be used as normal variables.

ansible_become
equivalent of the become directive, decides if privilege escalation is used or not.

ansible_become_method
allows to set privilege escalation method

ansible_become_user
allows to set the user you become through privilege escalation, does not imply ansible_become: True

ansible_become_pass
allows you to set the privilege escalation password

http://docs.ansible.com/ansible/become.html

关于ansible - 登录 Ansible 后切换用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36419091/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com