- become : 특정 사용자로 전환(become)할지 여부이고, true/false/yes/no로 설정한다.
- become_user : 어떤 사용자로 전환될지 설정한다. default = root
- become_method : 사용해야하는 권한 에스컬레이션 방법
- sudo | su | pbrun | pfexec | doas | dzdo | ksu 중 선택, default = sudo
- name: Run a command as nobody
command: somecommand
become: yes
become_method: su
become_user: nobody
become_flags: '-s /bin/sh'
- hosts: all
gather_facts: no
become: yes
become_method: sudo
tasks:
- name: Create a blank file
file:
path: /home/admin/test.txt
state: touch
파일이 root 권한으로 생성이 된다
- hosts: all
gather_facts: no
become: yes
become_user: admin
tasks:
- name: Create a blank file
file:
path: /home/admin/test.txt
state: touch
become_user: admin. 으로 admin 권한으로 파일이 생성됨
반응형
'Ansible' 카테고리의 다른 글
Ansible Vault (0) | 2023.06.29 |
---|---|
Ansible SSH Keys to managed nodes (0) | 2023.06.28 |
Ansible Configuration files (0) | 2023.06.28 |
Playbook run options (0) | 2023.06.28 |
Ansible Roles (0) | 2023.06.28 |