In your playbook.yml file, the "script" option can be used to invoke a script. In this example, script.sh must reside on your Ansible server.
--- - hosts: all remote_user: root tasks: - name: my script script: /path/to/your/script.sh
The playbook can then be executed using this command.
ansible-playbook playbook.yml -i inventory.yml
The following should be produced.
PLAY [all] TASK [Gathering Facts] ok: [server1.example.com] TASK [my script] changed: [server1.example.com] PLAY RECAP server1.example.com : ok=2 changed=1 unreacable=0 failed=0
By default, no stdout is printed. The - debug option can be used to print output to the console.