lining up users when bootstrapping a system

I’ve been bashing at this since yesterday and have read around a lot and tried lots of things. I figured it was time to try the list.

Basically I’m trying to create a playbook that will be used when bootstrapping a fresh host. The root user is needed for the initial bootstrap. After the on target steps, several other systems have to have an action run on them authorizing the bootstrapped host, one of which is puppet. Here is are some examples of what I tried.

try:

- hosts: boxens
  remote_user: root
  tasks:
    - yum: name={{ item }} state=present
      with_items: packages
    - command: "puppet agent --noop --server={{ puppetmaster }}"
    - command: "puppet cert sign {{ ansible_fqdn }}"
      delegate_to: "{{ puppetmaster }}"
      remote_user: "{{lookup('env','USER')}}"

or just set your own user name directly.

problem with setting user directly is when the playbook is shared. Doing an env lookup has a problem in that local_user != remote_user.

-greg