Ansible remote_user vs ansible_user

前端 未结 2 1872
一个人的身影
一个人的身影 2020-12-05 12:52

The question is simple: what is the difference between ansible_user (former ansible_ssh_user) and remote_user in Ansible, besides that

2条回答
  •  自闭症患者
    2020-12-05 13:41

    One difference between remote_user and ansible_user:
    When you run a role with different users from a playbook, e.g.:

    - name: Apply user configuration to user root 
      hosts: all
      remote_user: root
    - name: Apply user configuration to user murphy
      hosts: all
      remote_user: murphy
    

    Then you can perform a conditional task for a distinct user by using "when: ansible_user == .." but not with "when: remote_user == ..". e.g.:

    - name: Add user murphy to wheel group
      user:
        name: murphy
        groups: wheel
        append: yes
      when: ansible_user == "root"
    

提交回复
热议问题