How do I use a symbolic user for a remote ansible task?

33 views
Skip to first unread message

Tim Daley

unread,
Jun 16, 2016, 7:36:47 PM6/16/16
to Ansible Project
I have the following snippet from my playbook. The hosts: substitutes just fine, but the user: gives "SSH Error: command-line line0: garbage at end of line; "{{ username }}". Is substitution of the user possible?

Enter code here...
- Other stuff
   - set_fact: username="user"

- name: gather facts
  hosts: "{{ aws_host_group }}"
  connections: ssh
  user: "{{ username }}"
  become: true
  vars:
    - aws_host_group: "{{ aws_type + 'hosts' }}"
  pre_tasks:
    - name: Yum Update
      yum: name='*' state=latest

if I delete the register and add the following to my vars: - username: user

The message changes to "SSH Error: command-line line0: garbage at end of line; "user".

This shows that there is at least partial substitution happening.

Tim Daley

unread,
Jun 20, 2016, 4:30:00 PM6/20/16
to Ansible Project
if remote_user: is used rather than user: the substitutions seem to work.
Reply all
Reply to author
Forward
0 new messages