简体   繁体   中英

How become works in ansible?

In Ansible I found some keywords like become and become_user . 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 control node Users of server01 - root, vagrant

server02 - Ansible remote node Users of server02 - root, test

Note: I am able to ssh server02 using it's test user.

Suppose I have written a playbook for "tree" installation on server02 .

---
  - 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 . and why I used become keyword. Please also write about become_user keyword?

Your server01, running the playbook, will log into server02 using the remote_user . 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.

become points at what happens next: When activated, the ansible process on server02 will become another user. Practically, it calls sudo for every command. Per default, the become_user is root .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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