# How to run install script on Ansible?

**URL:** <https://forum.ansible.com/t/how-to-run-install-script-on-ansible/8548>\
**Category:** Get Help\
**Tags:** playbook, ansible-core\
**Created:** [September 17, 2024, 10:33am UTC](https://forum.ansible.com/t/how-to-run-install-script-on-ansible/8548 "2024-09-17T10:33:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mk123](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@mk123](https://forum.ansible.com/u/mk123)\
**Post date:** [September 17, 2024, 10:33am UTC](https://forum.ansible.com/t/how-to-run-install-script-on-ansible/8548/1 "2024-09-17T10:33:12Z")

</div>

I have a shell script ./install-agent.sh and wish to run it on Ansible; how do I run it?

---

<div class="post-metadata">

**Author:** ![jiholland](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jiholland/32/11273_2.png) [@jiholland](https://forum.ansible.com/u/jiholland)\
**Post date:** [September 17, 2024, 12:59pm UTC](https://forum.ansible.com/t/how-to-run-install-script-on-ansible/8548/2 "2024-09-17T12:59:23Z")

</div>

Hi. You can write a playbook that uses the [ansible.builtin.script](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/script_module.html#ansible-collections-ansible-builtin-script-module) module.

```YAML
$ 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.

```YAML
$ ansible-playbook playbook.yml

```

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [September 17, 2024, 2:56pm UTC](https://forum.ansible.com/t/how-to-run-install-script-on-ansible/8548/3 "2024-09-17T14:56:52Z")

</div>

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](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/script_module.html)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [October 17, 2024, 2:56pm UTC](https://forum.ansible.com/t/how-to-run-install-script-on-ansible/8548/4 "2024-10-17T14:56:54Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
