remote_user does not appear to be working correctly

21 views
Skip to first unread message

Mike Cavedon

unread,
Nov 24, 2020, 2:51:28 AM11/24/20
to Ansible Project
I have a playbook that executes 'emissary_deploy.yml' as an include:

---
- include: emissary_deploy.yml

emissary_deploy contains the following:

- name: Delete/link properties
  hosts: emissary
  remote_user: remoteUser
   tasks:
    - name: Link all properties files
      file: src="{{ item.src }}" dest="{{ item.dest }}"  state=link
      with_items:
        - src: "{{ emissary_shared }}/data"
          dest: "{{ new_extracted_path }}/data"

The task executes as user 'ec2-user' when I'm expecting it to be 'remoteUser':

01:11:53 TASK [Link all properties files] *********************************************** 01:11:53 task path: /var/lib/jenkins/workspace/emissary-jdk11_create_ami/emissary_deploy.yml:73 
01:11:53 Using module file /var/lib/jenkins/workspace/emissary-jdk11_create_ami/ansible_env/src/ansible/lib/ansible/modules/files/file.py 
01:11:53 <172.17.70.215> ESTABLISH SSH CONNECTION FOR USER: ec2-user

01:11:53 "item": { 
01:11:53 "dest": "/opt/emissary-dist/data", 
01:11:53 "src": "/opt/emissary-shared/data" 
01:11:53 }, 
01:11:53 "mode": "0777", 
01:11:53 "msg": "chown failed: [Errno 1] Operation not permitted: '/opt/emissary-dist/data'", 
01:11:53 "owner": "ec2-user", 
01:11:53 "path": "/opt/emissary-dist/data", 
01:11:53 "size": 25, 
01:11:53 "state": "link", 
01:11:53 "uid": 500 0

01:01:44 + ansible --version 
01:01:45 ansible 2.5.2 (dx-stable-2.5 88f872f238) last updated 2020/11/24 01:00:48 (GMT -400) 0

This used to work. This code hasn't been changed in years.

Thanks,
Mike

Vladimir Botka

unread,
Nov 24, 2020, 3:32:46 AM11/24/20
to Mike Cavedon, ansible...@googlegroups.com
On Mon, 23 Nov 2020 23:51:28 -0800 (PST)
Mike Cavedon <mpc...@gmail.com> wrote:

> - 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

shell> cat pb.yml
- hosts: test_01
remote_user: remoteUser
tasks:
- debug:
var: ansible_user

gives (abridged)

shell> ANSIBLE_REMOTE_USER=admin ansible-playbook pb.yml

ok: [test_01] =>
ansible_user: admin

--
Vladimir Botka

Mike Cavedon

unread,
Nov 24, 2020, 5:03:52 PM11/24/20
to Ansible Project
That was it. Thank you very much.
Reply all
Reply to author
Forward
0 new messages