Connecting to a WinRM host with different credentials?

I have a playbook in which I want to create a random password and use it later to connect to a windows box over WinRM

I’ve generated a random password like this:

  • name: Generate a temporary random password for new host
    set_fact:
    randopass: “{{ lookup(‘password’, ‘/dev/null length=15 chars=ascii_letters’) }}”

I set the admin password with vmware_guest os customization:
customization:

password: ‘{{ randopass }}’
timezone: 004

Then - I’m trying to use:

  • hosts: ‘hostname.internal.domain.com
    connection: winrm
    port: 5985
    remote_user: Administrator
    remote_pass: ‘{{ randopass }}’
    gather_facts: yes

I’ve tried “remote_password, remote_pass, ansible_pass, ansible_password” and I get an error message like this:

ERROR! ‘remote_pass’ is not a valid attribute for a Play

What can I use for this part of the play to connect as a different user/password?

I’m using ansible tower if it matters

Hi,

According to doc it should be

ansible_user: LocalUsername
ansible_password: Password
ansible_connection: winrm
ansible_winrm_transport: basic

Regards

Tom

Further to the above, those are variables and not attributes you can set on a play. You need to set them under your the vars key or just add them using add_host in the previous play.

That was what I was looking for. Thanks Jordan/Tom