I have a shell script ./install-agent.sh and wish to run it on Ansible; how do I run it?
Hi. You can write a playbook that uses the ansible.builtin.script module.
$ cat playbook.yml
---
- name: Playbook that runs a shell script.
hosts: localhost
tasks:
- name: Run shell script
ansible.builtin.script: install-agent.sh
You can run the playbook with the ansible-playbook command.
$ ansible-playbook playbook.yml
I would even suggest using the script
action as that will copy the script to the target machine, run it and clean up after itself. ansible.builtin.script module – Runs a local script on a remote node after transferring it — Ansible Community Documentation
2 Likes