# Playbook for install .bin file

**URL:** <https://forum.ansible.com/t/playbook-for-install-bin-file/4393>\
**Category:** Get Help\
**Tags:** playbook\
**Created:** [March 15, 2024, 5:52am UTC](https://forum.ansible.com/t/playbook-for-install-bin-file/4393 "2024-03-15T05:52:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniil](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@Daniil](https://forum.ansible.com/u/Daniil)\
**Post date:** [March 15, 2024, 5:52am UTC](https://forum.ansible.com/t/playbook-for-install-bin-file/4393/1 "2024-03-15T05:52:01Z")

</div>

Good afternoon, could you help me?  
I need to copy a file to a remote host with a .bin extension and run it with administrator rights. What kind of playbook is needed (the one that displays the GPT chat does not work).

---

<div class="post-metadata">

**Author:** ![Daniil](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@Daniil](https://forum.ansible.com/u/Daniil)\
**Post date:** [March 15, 2024, 5:54am UTC](https://forum.ansible.com/t/playbook-for-install-bin-file/4393/2 "2024-03-15T05:54:26Z")

</div>

Remote host Ubuntu 22.04

---

<div class="post-metadata">

**Author:** ![Dustin](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dustin/32/2573_2.png) [@Dustin](https://forum.ansible.com/u/Dustin)\
**Post date:** [March 15, 2024, 3:21pm UTC](https://forum.ansible.com/t/playbook-for-install-bin-file/4393/3 "2024-03-15T15:21:26Z")

</div>

# Assumptions

I’m going to assume the following items for my example below

1. You have all the prerequisite items setup to make the playbook work  
(Inventory, host\_vars, etc.)
2. SSH To your remote system works
3. The admin user on the remote system is root
4. Your bin file is stored locally on your system at /tmp/my\_file.bin

# Items to Learn

1. Ansible’s [copy](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/copy_module.html) module.
2. Ansible’s [become](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_privilege_escalation.html) capabilities
3. Ansible’s [expect](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/expect_module.html) module, if your executable is going to require interaction to prompts in order to install properly.

# Example Playbook

If your executable requires prompt interaction, replace `ansible.builtin.copy` with `ansible.builtin.expect` and use the link above to learn how to use it.

```yaml
---
- name: Copy my_file.bin to Remote Server:/tmp/my_remote_file.bin
  hosts: all
  become: yes
  become_user: root
  become_method: sudo

  tasks:
    - name: Copy the file
      ansible.builtin.copy:
        src: /tmp/my_file.bin
        dest: /tmp/my_remote_file.bin

    - name: Execute the file
      ansible.builtin.shell: "sh /tmp/my_remote_file.bin"

```
