Hello, Foreman is very Linux centric, but there are users out there maintaining Windows templates and some documentation (or blog posts). You might be on your own figuring this out, report back to us if you get it working.
EC2 is image-based provisioning, I guess Foreman won’t do you much in this scenario anyway - Foreman can spawn an image on EC2 and that’s pretty much it. Then you need to bootstrap Puppet or other management system to report back to Foreman.
Thanks @lzap for the confirmation. That’s what I was starting to suspect.
I have this working in EC2 for my Linux hosts-- the instances are created and then their Ansible roles are automatically applied after a configurable amount of time (I just set it to 0 minutes in the settings to speed things up). I think I should be able to get this working now that I’ve explored it a little more. It should just require setting up the WinRM stuff in whatever AMI I’m using. I’ll post back with any progress I make.
Cool, I think I have this working with EC2 and Ansible! I got a successful response to my win_ping.
Here’s a user_data template that can be used as a starting point for others:
name: Windows default user data
# Set up both HTTP and HTTPS listeners with a self-signed certificate
# and enables the Basic authentication option on the service.
$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
That PS code is taken from the Ansible docs.
@lzap Right now I have to get the admin password either through the AWS console or CLI tools. Once I have this and set ansible_password in either host_vars or group_vars, WinRM works. Do you know of a better to go about doing this? Does Foreman provide access to this password in any way?
One thing I noticed is that jobs take significantly longer to run using WinRM:
This job template took 2+ minutes to run:
- hosts: all
- name: Get the current user
- debug: var=debug_info
**Started at:** 2018-11-02 22:02:52 UTC
**Ended at:** 2018-11-02 22:05:04 UTC
Is the longer duration to be expected when using WinRM? (I haven’t used it much before)
Also, I noticed there’s no console feedback until the very end of the playbook. Is that also to be expected when using WinRM?