IBM-Cloud / ibmcloud-image-builder

ibmcloud-image-builder
Apache License 2.0
10 stars 8 forks source link

Packet Template for Windows Evaluation Cloud Image #47

Open syyang-in-cloud opened 3 years ago

syyang-in-cloud commented 3 years ago

What's the issue?

Definition of Done

syyang-in-cloud commented 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$
syyang-in-cloud commented 3 years ago

https://ibm-cloudplatform.slack.com/archives/CJG6YPZV2/p1598508327139100?thread_ts=1598242111.059100&cid=CJG6YPZV2