I have a playbook that executes ‘emissary_deploy.yml’ as an include:
- name: Delete/link properties
hosts: emissary
remote_user: remoteUser
tasks:
- name: Link all properties files
...
The task executes as user 'ec2-user' when I'm expecting it to be
'remoteUser':
...
*01:11:53* <172.17.70.215> ESTABLISH SSH CONNECTION FOR USER: *ec2-user*
Variables will override playbook keywords. See "Precedence categories"
https://docs.ansible.com/ansible/latest/reference_appendices/general_precedence.html#precedence-categories
There must be a variable *ansible_user* or *ansible_ssh_user* or
environment *ANSIBLE_REMOTE_USER* with the value *ec2-user*
See "ssh connection plugin"
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/ssh_connection.html#ansible-builtin-ssh-connect-via-ssh-client-binary
For example, the playbook below
> cat pb.yml
- hosts: test_01
remote_user: remoteUser
tasks:
- debug:
var: ansible_user
gives (abridged)
> ANSIBLE_REMOTE_USER=admin ansible-playbook pb.yml
ok: [test_01] =>
ansible_user: admin
That was it. Thank you very much.