I'm trying to write a play that will take a locally stored powershell script from my Ansible server and run it on Windows hosts. I have been using the "win_shell" module to run scripts placed inside my playbook files, but for testability I want to have the scripts being executed stored outside of my playbook yaml files.
Here's what I'm trying right now:
- hosts: "AnsibleDevTestingHosts"
tasks:
- name: "showing playbook_dir"
debug:
msg: "{{ playbook_dir }}"
- name: Testing Ansible
ansible.builtin.script: "{{ playbook_dir }}/scripts/calibrate_flux_capacitor.ps1"
When I run this, I'm currently getting back an error message:
TASK [Testing Ansible] *********************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: IndexError: list index out of range
fatal: [delorian-car-1.local]: FAILED! => {"msg": "Unexpected failure during module execution.", "stdout": ""}
I've been looking at the Ansible docs for ansible.builtin.script and it seems pretty simple to use (and supports Windows). So, I'm unsure what the problem here is.