Ansible - 特权提升的正确方法
Ansible - correct way for privilege elevation
我正在编写剧本以便从 portage 安装软件包:
---
- hosts: '1.2.3.4'
sudo: True
become_user: admin_x
- tasks:
- name: "install nspr"
portage: package=dev-libs/nspr state=present
这失败了,告诉我我没有 sudo 权限:
ansible-playbook foo.yml --limit 1.2.3.4 -k --ask-sudo-pass
我看到您应该使用 become,但是它的文档是 pretty much a gap。谁能举例说明如何正确执行此操作?
我使用:
deploy.yml:
- name: Todo something
hosts: all
become: yes
become_user: root
become_method: su
当你执行 playbook 时,像额外的变量一样传递密码。
--extra-vars='ansible_become_pass=password'
我正在编写剧本以便从 portage 安装软件包:
---
- hosts: '1.2.3.4'
sudo: True
become_user: admin_x
- tasks:
- name: "install nspr"
portage: package=dev-libs/nspr state=present
这失败了,告诉我我没有 sudo 权限:
ansible-playbook foo.yml --limit 1.2.3.4 -k --ask-sudo-pass
我看到您应该使用 become,但是它的文档是 pretty much a gap。谁能举例说明如何正确执行此操作?
我使用:
deploy.yml:
- name: Todo something
hosts: all
become: yes
become_user: root
become_method: su
当你执行 playbook 时,像额外的变量一样传递密码。
--extra-vars='ansible_become_pass=password'