-1

Right now I am installing agents one by one on several Workstations. But I like to use Ansible with which I can automate the installation of the agents for the Workstation.

This is the command line I am trying to translate into the Ansible playbooks:

curl https://repository.rudder.io/tools/rudder-setup | bash -s setup-agent 7.3 [policy server hostname or ip]

Having troubles to put this together since I am still a beginner with Ansible.

U880D
  • 8,601
  • 6
  • 24
  • 40
  • 1
    Can you be more clear? It is really hard to understand what are you trying achieve, but I would suggest splitting this command to several Ansible tasks. For example download given rudder-setup script in first task and executing it in another one. – 32cupo Jun 14 '23 at 08:15

1 Answers1

0

Lets assume:

1.) You have an infrastructure and therefore build your inventory file hosts.ini like

[controlnode]
ctrl.example.com

[rudder_server]
pol.example.com

[rudder_clients]
wrkst1.example.com
wrkst2.example.com
wrkst3.example.com

2.) You like to organize and group variables in a file group_vars/rudder_clients/policy_server

---
policy_server: pol.example.com

3.) You don't want to do curl {something} | sudo bash - because of "Is that really a reasonably safe installation method?" - therefore the Bash installation script is already downloaded, reviewed and stored under group_files/rudder_clients/rudder-setup.sh.


A minimal example playbook could look like

- hosts: rudder_clients
  become: true
  gather_facts: false
  
  # For convenience and demonstration purpose stored here
  # instead of the corresponding group_vars file

  vars:
  
    role: 'setup-agent'
    version: '7.3'
  
  tasks:
  
  - name: Install Rudder Agent on Workstations
    script: rudder-setup.sh {{ role }} {{ version }} {{ policy_server }}
    args:
      creates: /opt/rudder-setup.sh
      executable: /bin/bash

Further Documentation

Please take note that this needs to be adjusted to your needs, it is not considered as a good practice and you may also have a look into


How to proceed further?

Since the above (script)

... will setup Rudder repository on your system and the use the package manager to install rudder ... in latest version ...

you probably want to convert rudder-setup.sh script parts into an Ansible playbook at all instead of just executing it. For the agent part it looks achievable within a day and to do so, start from line 846 and # Setup rudder agent # first.

By doing this you will take advantage of all available Ansible capabilities and modules like Conditionals based on ansible_facts, package_facts, yum_repository, yum, service, systemctl etc., and many more. It would end up in something simple like shown in Running node_exporter with Ansible.

In order to proceed further you might find out during your research that there is already a Rudder Ansible Collection and a role to install rudder_agent. So you may either use it as it is or adopt from there.

U880D
  • 8,601
  • 6
  • 24
  • 40