简体   繁体   English

怎么变成作品呢?

[英]How become works in ansible?

In Ansible I found some keywords like become and become_user . 在Ansible中,我发现了一些关键词,例如变为变得 _用户 I am implementing ansible by making server01 as ansible control node (from where I will write playbooks and will execute playbooks on other remote server/s) and server02 as remote node. 我通过将server01设置ansible控制节点(从此处我将编写剧本并在其他远程服务器上执行剧本)和将server02作为远程节点来实现ansible

server01 - Ansible control node Users of server01 - root, vagrant server01 -Ansible控制节点server01的用户-root ,vagrant

server02 - Ansible remote node Users of server02 - root, test Server02上 - Server02上的Ansible远程节点用户-根,测试

Note: I am able to ssh server02 using it's test user. 注意:我可以使用它的测试用户来SSH server02

Suppose I have written a playbook for "tree" installation on server02 . 假设我已经为server02上的“ tree”安装写了一部剧本。

---
  - name: Installation of software on ubuntu server
    hosts: PROD
    become: true
    tasks:
      - name: Install tree software
        apt:
          name: tree
          state: present
          update_cache: yes

Now, I have executed the playbook and I want to know the significance of become keyword. 现在,我已经执行了剧本,我想知道成为关键字的重要性。

From which user server01 ansible-playbook will login into the server02 . 服务器server01 ansible - book将从该用户登录到server02 and why I used become keyword. 以及为什么我曾经成为关键字。 Please also write about become_user keyword? 还请写关于begin_user关键字吗?

Your server01, running the playbook, will log into server02 using the remote_user . 运行剧本的server01将使用remote_user登录到server02。 That's either the user running the playbook, or another user configured in your inventory, your configuration, or via the ANSIBLE_REMOTE_USER environment variable. 那是运行剧本的用户,还是在您的清单,配置中或者通过ANSIBLE_REMOTE_USER环境变量配置的另一个用户。

become points at what happens next: When activated, the ansible process on server02 will become another user. become下一步发生的要点:激活后,server02上的ansible进程将成为另一个用户。 Practically, it calls sudo for every command. 实际上,它为每个命令调用sudo Per default, the become_user is root . 默认情况下, become_userroot

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM