The question is simple: what is the difference between ansible_user
(former ansible_ssh_user
) and remote_user
in Ansible, besides that
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"