Deploy an exe file to a list of servers

I can copy an exe file to the destination server and run it using PS, to install it.

A need has arised where this exe file would need to be copied to a list of 100+ servers and installed.

Can someone show me an example of a playbook yaml file, how we can achieve this?

Thanks

What did you try already?

I am new to ansible, and this is what I tried to run it on 1 server:

  • hosts: ‘{{ hostname }}’
    gather_facts: no
    become_method: runas
    vars:
    ansible_become_password: “{{ domain_password }}”
    tasks:

  • name: Include vars of server.yaml file
    include_vars:
    file: /etc/ansible/servers/{{ hostname }}.yaml
    name: server

  • name: Wait For Connection to Continue
    wait_for_connection:
    connect_timeout: 30

  • import_role:
    name: net481

The above works for 1 server… not sure how I can use the above for multiple servers. Thanks

You probably need to create an inventory (https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html) with all of your machines in it, then when you run your playbook you can run it against all of them, or a subset (host or group).
You can specify custom variables in your inventory at your host level or at a group level, so you don’t need to have a specific include_vars task if you don’t want to.

For example, I like to use YAML for my inventory (https://docs.ansible.com/ansible/latest/plugins/inventory/yaml.html), so it might be in a file called inventory.yaml (but you can use /etc/ansible/hosts instead) and look like this: