我的loginuser是user1,我想用root执行playbook.我怎样才能做到这一点.如果我在cmdline中使用它不会像这样工作
ansible-playbook main.yaml -i hosts --user=git -k --become-user=root --ask-become-pass --become-method=su
请告诉我如何实现这一点.
name: Install and Configure IEM hosts: rhel ansible_become: yes ansible_become_method: su ansible_become_user: root ansible_become_pass: passw0rd tasks: - name: Creating masthead file path file: path=/etc/opt/BESClient state=directory - name: Creating install directory
解决方法
我用 :
deploy.yml
- name: Todo something hosts: all become: yes become_user: root become_method: su
当您执行playbook时,将密码作为额外的var传递.
--extra-vars='ansible_become_pass=password'
原文地址:https://www.jb51.cc/linux/396138.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。