Configure Winrm playbook issue

82 views
Skip to first unread message

Nitrous

unread,
Apr 19, 2022, 10:38:23 AM4/19/22
to Ansible Project
So I saw this example on github to configure remoting for ansible machines (https://docs.ansible.com/ansible/latest/collections/community/windows/psexec_module.html), and try to make it work, but errors out:

ERROR! playbook entries must be either valid plays or 'import_playbook' statements

My playbook is called multiple.yml and running it as:
ansible-playbook -i hosts playbooks/multiple.yml

- name: Download and run ConfigureRemotingForAnsible.ps1 to setup WinRM
  community.windows.psexec:
    hostname: servername
    connection_username: '{{ ansible_user }}'
    connection_password: '{{ ansible_password }}'
    encrypt: yes
    executable: powershell.exe
    arguments: '-'
    stdin: |
      $ErrorActionPreference = "Stop"
      $sec_protocols = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::SystemDefault
      $sec_protocols = $sec_protocols -bor [Net.SecurityProtocolType]::Tls12
      [Net.ServicePointManager]::SecurityProtocol = $sec_protocols
      Invoke-Expression ((New-Object Net.WebClient).DownloadString($url))
      exit
  delegate_to: localhost


What does this do and where is this defined:
hostname: '{{ hostvars[inventory_hostname]["ansible_host"] | default(inventory_hostname) }}'

My servername for the hostname is my server name, in my previous example, but trying to under the github example and what is trying to do.

We have 500+ machines on different domains, that we need ansible to connect to, and we are just using winrm currently to deploy new machines, which isnt an issue.

Issue is only connecting to servers, that werent built using ansible, hence need to run the configureremoting PS script to make them ansible ready to connect to.

Thanks
Reply all
Reply to author
Forward
0 new messages