All HowTo's Ansible & Terraform Automation Linux

Ansible AWX Targeting Windows via SSH – The details you might have missed

This article highlights some important details for those working with Ansible AWX. Specifically, when the target system/s are Windows based. The two options to target a Windows host is WinRM and SSH. SSH is easier. It just requires the OpenSSH Server “feature” to be installed which is a simple process. In my test environment, I used the “administrator” credentials that AWS (yes, it was hosted in AWS) generated. Once we can hit that server, we can change the password, etc.

This playbook will download the “7zip” MSI install package. It will place it in the Windows\Temp folder.

---
- name: Download and install 7zip on Windows
  hosts: all
  gather_facts: no

  tasks:
  - name: Download the 7-Zip package
    win_get_url:
      url: https://www.7-zip.org/a/7z1701-x64.msi
      dest: C:\Windows\Temp\7z.msi

  - name: Install MSI
    win_package:
      path: C:\Windows\Temp\7z.msi
      state: present

The following variables are used for the “Template” within AWX.

---
ansible_remote_tmp: C:\Windows\Temp
ansible_shell_type: cmd
ansible_connection: ssh

These details are incomplete by themselves, but they will save you time if this is where you’re stuck.

Leave a Reply

Your email address will not be published. Required fields are marked *