Open syyang-in-cloud opened 3 years ago
The below is how to Ansible to Windows (winrm) cloud-init user-data
ubuntu@ubuntu-jenkins:~/test/winrm$ cat user_win.ps1
#ps1_sysnative
$username = "ansible"
$password = "w36F9M1NAOzXNl7yfy4n"
$group = "Administrators"
& NET USER $username $password /add /y /expires:never
& NET LOCALGROUP $group $username /add
& WMIC USERACCOUNT where "Name='$username'" SET PasswordExpires=FALSE
$url = "https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1"
$file = "$env:temp\ConfigureRemotingForAnsible.ps1"
(New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file)
powershell.exe -ExecutionPolicy ByPass -File $file
ubuntu@ubuntu-jenkins:~/test/winrm$
ubuntu@ubuntu-jenkins:~/test/winrm$ cat hosts
[win]
52.117.14.22
[win:vars]
ansible_user=ansible
ansible_password=w36F9M1NAOzXNl7yfy4n
ansible_port=5986
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore
ubuntu@ubuntu-jenkins:~/test/winrm$
What's the issue?
Definition of Done