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

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.

if remote_user: is used rather than user: the substitutions seem to work.