This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Deploy agents with Chef or Puppet

Since SAM 6.3 supports installing SolarWinds Orion agents on Linux-based computers, you can use automation technologies like Chef or Puppet to mass deploy them.  The examples show two different scripting methods to deploy agents. These methods are independent of Chef or Puppet and either method can be used to automate your agent installations if it is supported by your automation software. And a special thank you to Toby.

By the way, SolarWinds doesn't support these automation technologies, and the instructions are provided as reference only and assume that your automation software is installed and configured correctly.

Here's what we've got:

Deploy an agent with an expect script


This method uses a Chef cookbook to create and deploy an expect script to target nodes. It contains two parts that must be performed in order.

Here's the example recipe used in the instructions:

# Install the swiagent package using the repository
    package 'swiagent'
# Create a driver to configure the agent
    cookbook_file '/opt/SolarWinds/Agent/bin/driver.ini' do
    source 'driver.ini'
    owner 'swiagent'
    group 'swiagent'
    mode '0755'
    action :create
       end 
# Start the agent and configure it
# You only have to start and configure the agent once.
# Assume that if the swiagent.cfg file exists, the agent is provisioned
    execute 'swiagent init' do
    command 'cat /opt/SolarWinds/Agent/bin/driver.ini | service swiagentd init'
    creates '/opt/SolarWinds/Agent/bin/swiagent.cfg'
  end

  1. Create a recipe.
    1. Configure the node to use the SolarWinds repository.
    2. Get the package from the repository.
       package 'swiagent'
    3. Create the driver.
      cookbook_file '/opt/SolarWinds/Agent/bin/driver.ini' do
          source 'driver.ini'
          owner 'swiagent'
          group 'swiagent'
          mode '0755'
          action :create
      end
    4. Start and configure the agent.
      execute 'swiagent init' do
          command 'cat /opt/SolarWinds/Agent/bin/driver.ini | service swiagentd init'
          creates '/opt/SolarWinds/Agent/bin/swiagent.cfg'
      end
    5. Save the recipe.
  2. Create a driver.ini file that configures the agent to connect to the poller and use a specific Orion credential.
    2
    IPaddress  

    admin 
    7

You can apply the cookbook to any Chef registered node that you want to monitor with an Orion agent.

Deploy an agent with a shell script


This method uses a Puppet manifest to deploy a shell script to target nodes. It contains three parts that must be performed in order on the Puppet master node.

  1. Create a module with an swiagent class.
    class swiagent {
        file { 'swi-driver':
        path => '/tmp/driver.sh',
        ensure  => 'present',
        replace => 'no', # always include this resource declaration
        mode    => '0644',
        source => 'puppet:///modules/swiagent/driver.sh',
        } ->
        exec { 'provision_agent':
        command => 'sh /tmp/driver.sh',
        path    => '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin',
        creates => '/opt/SolarWinds/Agent/bin/swiagent.cfg',
        }
    }
  2. Create a driver.sh file located in swiagent/files/.
    1. Click All Settings > Agent Settings > Download Agent Software.
    2. Click Linux, and Next.
    3. Click Manually Install by Downloading Files via URL, and click Next.
    4. Select your Distribution and Communication Mode
    5. Enter the Connection Settings.
    6. Click Generate Command.
    7. Copy this command to the driver.sh file.
      bash -c 'x(){ P=/Orion/AgentManagement/DownloadLinuxOnlineInstallScript.ashx? 
      requestId=eeaeac49-75c7-46bb-83b8-ee22c4924ef1;U=(
      http://host.local:8787/
      http://host:8787 http://[2001:10:110:6:c802:e60b:70ba:7495]:8787 
      http://192.168.10.143:8787);dt(){ D=(wget curl);A=(-O\ -\ --no-check-certificate\ 
      --tries=1\ --read-timeout=30 --insecure\ --retry\ 1); for((i=0;i<${#D[@]};i++));do 
      which ${D[$i]}&>/dev/null&&export DT="${D[$i]} ${A[$i]}"&&return;done;>&2 echo 
      "Cannot find download tool - please install some (${D[*]}) or use other 
      installation method";exit 1;};dt;echo export DT=\"$DT\";>&2 echo; >&2 
      echo -n "Downloading installation data from Orion Poller...";for u in ${U[*]};do 
      echo "export URL=\"$u\""; if ${DT} $u$P 2>/dev/null; then FOUND=1; break; fi; >&2 
      echo -n "."; done; >&2 echo ""; if [ "${FOUND}" != "1" ]; then >&2 echo "Unable to 
      connect to Orion Poller to download agent package. Please use an alternate deployment 
      method, such as Add Node wizard."; >&2 echo "See
      http://www.solarwinds.com/documentation
      /helpLoader.aspx?lang=en&topic=OrionAgentDeployAgentTop"; exit 1; fi; };X=$(x);bash -c "${X}"'
  3. Add to the following to the main manifest for each node you want to monitor with an Orion agent:
    node 'host.local' { 
      include swiagent
      }

The next time the node pulls its configuration from the master, it evaluates the main manifest and apply the swiagent module.

Agent configuration options


These options may be different than the latest options built into the agent. Log on to the computer with the agent installed on it and type service swiagentd init to ensure that these options match the latest version of the software.

  1. Cancel and Exit without Saving
  2. Agent Mode (1 - Agent Initiated, 0 - Server Initiated)  [1]
  3. Orion Poller Hostname/IP  [10.110.6.154]
  4. Orion Poller Port        [17778]
  5. Orion Username            [admin]
  6. Orion Password            []
  7. Proxy Settings...        [mode=disabled]
  8. Save Changes and Exit
  • We don't use SAM, but do use puppet. This looks great, kudos.

  • This is excellent. Works great in our Chef environment. The driver.ini suggestion is what I needed. Thanks!

  • I use Ansible to push the agent installer to multiple hosts.   Really easy three task process.  First file: to create the directory I want to put the installer (my personal preference, but wherever you want it  is fine).  Then unarchive: to extract the swiagent tarball to said destination directory.  Followed by a command: to run the install.sh script. 

  • Thanks for this! Really appreciate it

  • This is how we do it in PUPPET

    class solarwinds {

    #+++

    # solarwinds install

    #

    # creates an install dir, places some files there, installs the RPM,

    # and then uses the placed files to config the app

    #

    #---

      $configSolarwinds = "/etc/init.d/swiagentd init /logfile /debug mode=installcert iniFile='/opt/SolarWinds/installer/SolarWindsAgent.ini' ca_cert='/opt/SolarWinds/installer/ca_cert.cert' cert='/opt/SolarWinds/installer/provisioning.pfx'"

      if ($::operatingsystem == 'RedHat') {

        file { '/etc/security/limits.d/solarwinds.conf':

          ensure => 'present',

          owner  => 'root',

          group  => 'root',

          mode   => 0644,

          source => 'puppet:///modules/solarwinds/solarwinds.conf'

        }

        file { '/opt/SolarWinds':

          ensure => 'directory',

        }

        file { '/opt/SolarWinds/installer':

          ensure  => 'directory',

          require => File['/opt/SolarWinds']

        }

        file { '/opt/SolarWinds/installer/ca_cert.cert':

          ensure  => 'present',

          owner   => 'root',

          group   => 'root',

          mode    => 0600,

          source  => 'puppet:///modules/solarwinds/ca_cert.cert',

          require => File['/opt/SolarWinds/installer'],

          notify  => Exec['SolarWindsInstall']

        }

        file { '/opt/SolarWinds/installer/provisioning.pfx':

          ensure  => 'present',

          owner   => 'root',

          group   => 'root',

          mode    => 0600,

          source  => 'puppet:///modules/solarwinds/provisioning.pfx',

          require => File['/opt/SolarWinds/installer'],

          notify  => Exec['SolarWindsInstall']

        }

        file { '/opt/SolarWinds/installer/SolarWindsAgent.ini':

          ensure  => 'present',

          owner   => 'root',

          group   => 'root',

          mode    => 0600,

          source  => 'puppet:///modules/solarwinds/SolarWindsAgent.ini',

          require => File['/opt/SolarWinds/installer'],

          notify  => Exec['SolarWindsInstall']

        }

        package { 'swiagent':

          ensure  => installed,

          notify  => Exec['SolarWindsInstall']

        }

        exec { 'SolarWindsInstall':

          command => $configSolarwinds,

          refreshonly => true,

          require => [

            Package['swiagent'],

            File['/opt/SolarWinds/installer/ca_cert.cert'],

            File['/opt/SolarWinds/installer/provisioning.pfx'],

            File['/opt/SolarWinds/installer/SolarWindsAgent.ini']

          ],

        }

        service { 'swiagentd':

          ensure  => running,

          require => [ Package['swiagent'], Exec['SolarWindsInstall'] ]

        }

      } #if RH

    }

  • Hello, would you be able to share complete Ansible script ? im just starting with Ansible and would be very helpful. Thanks mark

  • I wonder if petersjd​ playbook looks similar to this?  I am a real novice with ansible but seemed to get it to work.

    I just downloaded the tarball (from http://my_orion/Orion/AgentManagement/Admin/DownloadAgent.aspx ) for the Linux distro I wanted.  In this case it is called swiagent.tar.gz and placed in a working directory I was using for ansible.  Then I created the playbook below, called it deploy_swiagent.yml in the same directory.  Then lastly I executed the deployment with "ansible-playbook deploy_swiagent.yml'

    ---

    - hosts: ubuntu-box

     

      tasks:

      - name: lets make a directory to put the tarball

        file:

          path: /tmp/swiagent

          state: directory

          mode: 0755

      - name: copy over and extract the tarball

        unarchive:

            src: swiagent.tar.gz

            dest: /tmp/swiagent

      - name: Execute the install.sh

        shell: /tmp/swiagent/install.sh

        args:

            chdir: /tmp/swiagent/

  • Sorry for the late reply all.  Yes, that's pretty much verbatim what I have.