Ansible-Puppet-Chef
[ansible] become
'김용환'
2018. 2. 1. 11:40
ansible의 become은 sudo를 사용할 수 없이 실제 해당 유저로 로그인함을 의미한다.
http://docs.ansible.com/ansible/latest/become.html
ansible 예제처럼 특정 사용자로 인증 후 사용될 수 있다.
- name: Run a command as the apache user command: somecommand become: true become_user: apache
만약 root로 접근하고 싶다면, 미리 장비에서 root로 접근할 수 있는 설정이 되어 있어야 잘 동작한다.
www@aaa~$ sudo -i
root@aaa:~#
다음은 playbook 예제이다.
- name: create /home/www
become: yes
become_method: sudo
file: path=/home/www state=directory owner=www group=www
- hosts: webservers
tasks:
- service: name=nginx state=started
become: yes
become_method: sudo