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
      $url = 
"https://github.com/ansible/ansible/raw/devel/examples/scripts/ConfigureRemotingForAnsible.ps1";
      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

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8416ed48-ce33-4804-950d-950e1c6886f0n%40googlegroups.com.

Reply via email to