Ansible中become的使用 (1)become
set to ‘true’/’yes’ to activate privilege escalation.
使用“true”或“yes”来表示启用这个特权,如:become=true
表示打开了become开关。
(2)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_user=root 设置为root账户,相当于我们以普通账户登入到远程主机时,再使用su - root切换为root账户。
(3)become_method
(at play or task level) overrides the default method set in ansible.cfg, set to sudo/su/pbrun/pfexec/doas/dzdo/ksu
become_method=su 表示用什么方式将普通账户切换到root或所需的其他账户,这里可以用su或sudo。
(4)become_flags
(at play or task level) permit to use specific flags for the tasks or role. One common use is to change user to nobody when the shell is set to no login. Added in Ansible 2.2.
表示允许为任务或角色使用特定的标志。一个常见的用法是在shell设置为不登录时将用户更改为nobody。ansible2.2版本中增加。