Deploy an exe file to a list of servers

61 views
Skip to first unread message

Wassam Ashraf

unread,
Dec 3, 2021, 10:23:19 AM12/3/21
to Ansible Project
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

Dick Visser

unread,
Dec 3, 2021, 11:50:37 AM12/3/21
to ansible...@googlegroups.com
What did you try already?


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f5fc6f23-06a1-4bc4-b767-1886f1f7cfd1n%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Nitrous

unread,
Dec 3, 2021, 12:12:31 PM12/3/21
to Ansible Project
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

Chris Smart

unread,
Dec 3, 2021, 4:49:59 PM12/3/21
to ansible...@googlegroups.com
On Sat, 4 Dec 2021 at 04:12, Nitrous <wassama...@gmail.com> wrote:
I am new to ansible, and this is what I tried to run it on 1 server:

<snip> The above works for 1 server.. not sure how I can use the above for multiple servers.

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:

---
all:
  hosts:
    server1:
    server2:
      custom_var: "server 1 custom variable overrides group variable"
    server3:
      custom_var: "server 2 custom variable overrides group variable"
  vars:
    custom_var: "group level var for all hosts"

Then your play (site.yml) can look something like this:

---
- hosts: all
  gather_facts: no
  become_method: runas
  vars:
    ansible_become_password: "{{ domain_password }}"
  tasks:
  - name: Wait For Connection to Continue
    wait_for_connection:
      connect_timeout: 30
- import_role:
      name: net481

Then to run you could do something like this:

$ ansible-playbook --inventory inventory.yaml site.yml

If you want to restrict it to specific hosts instead of all the hosts, then you can use the limit function.

$ ansible-playbook --inventory inventory.yaml --limit server1,server2 site.yml

Note that if you do still want to use your task to load vars, then each machine will have a variable "inventory_hostname" which will be the host name you can use, so it could be:

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

Hope that helps.

-c
 
Thanks

On Friday, December 3, 2021 at 10:50:37 AM UTC-6 dick....@geant.org wrote:
What did you try already?


On Fri, 3 Dec 2021 at 16:23, Wassam Ashraf <wassama...@gmail.com> wrote:
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

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f5fc6f23-06a1-4bc4-b767-1886f1f7cfd1n%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages