Automating Plugin Deployment Across Servers

Built-in Plugins vs Custom Plugins

Server Scout includes several built-in plugins that are automatically managed for you. The cPanel, DirectAdmin, Plesk, JetBackup, and devices plugins are included with the agent installation and update automatically alongside the agent itself. You don't need to do anything to deploy or maintain these standard plugins.

This guide focuses specifically on deploying custom plugins that you've developed or obtained from third-party sources. Custom plugins require manual deployment and management across your server infrastructure.

Custom Plugin Deployment Basics

Custom plugins must be placed in the /opt/scout-agent/plugins.d/ directory on each server where you want them to run. The plugin file should be executable and follow the Server Scout plugin format.

Here's the basic deployment process:

  1. Copy your custom plugin script to /opt/scout-agent/plugins.d/
  2. Set executable permissions: chmod +x /opt/scout-agent/plugins.d/your-plugin.sh
  3. Restart the scout-agent service: systemctl restart scout-agent

For a single server, this is straightforward. However, managing custom plugins across multiple servers requires a more systematic approach.

Configuration Management Deployment

The most robust approach for managing plugins across multiple servers is to use configuration management tools like Ansible, Puppet, Chef, or Salt. These tools ensure consistent deployment and make updates much simpler.

Ansible Example

Here's a simple Ansible playbook task for deploying a custom plugin:

- name: Deploy Server Scout custom plugin
  hosts: monitored_servers
  tasks:
    - name: Copy custom plugin
      copy:
        src: files/my-custom-plugin.sh
        dest: /opt/scout-agent/plugins.d/my-custom-plugin.sh
        owner: root
        group: root
        mode: '0755'
      notify: restart scout-agent

    - name: Restart scout-agent service
      systemd:
        name: scout-agent
        state: restarted
      when: plugin_file.changed

  handlers:
    - name: restart scout-agent
      systemd:
        name: scout-agent
        state: restarted

This approach ensures the plugin is deployed consistently across all your servers and handles the service restart automatically.

Shell Script Deployment

For simpler environments or one-off deployments, you can use a shell script to deploy plugins across multiple servers:

#!/bin/bash

PLUGIN_FILE="my-custom-plugin.sh"
SERVERS=("server1.example.com" "server2.example.com" "server3.example.com")

for server in "${SERVERS[@]}"; do
    echo "Deploying plugin to $server..."
    
    # Copy plugin file
    scp "$PLUGIN_FILE" root@"$server":/opt/scout-agent/plugins.d/
    
    # Set permissions and restart agent
    ssh root@"$server" "chmod +x /opt/scout-agent/plugins.d/$PLUGIN_FILE && systemctl restart scout-agent"
    
    echo "Deployment to $server completed"
done

Make sure you have SSH key authentication configured for seamless deployment.

Version Management

To track plugin versions across your infrastructure, include a version comment at the top of your custom plugins:

#!/bin/bash
# Plugin: My Custom Plugin
# Version: 1.2.3
# Description: Monitors custom application metrics

After deployment, check the agent logs to verify the plugin loaded successfully:

journalctl -u scout-agent | grep plugin

You should see messages indicating the plugin was loaded during the agent restart.

Updating Custom Plugins

To update a custom plugin, follow the same deployment process:

  1. Update your plugin file with the new version
  2. Deploy using your chosen method (configuration management or shell script)
  3. Restart the scout-agent service on each server

The new version will be active immediately after the agent restarts.

Rollback Strategy

If a plugin update causes issues, you can quickly rollback:

Option 1: Deploy Previous Version Use the same deployment process to install the previous working version of the plugin.

Option 2: Disable the Plugin Add the following line to /opt/scout-agent/scout.conf on affected servers:

plugin_<plugin_name>=0

Then restart the scout-agent service. This disables the plugin without removing the file.

Best Practices

  • Always test custom plugins on a development server before deploying to production
  • Keep backup copies of working plugin versions
  • Use configuration management tools for consistent deployment
  • Monitor agent logs after deployment to catch any issues early
  • Document your custom plugins and maintain version history

Remember, this deployment process only applies to custom plugins. The built-in Server Scout plugins handle updates automatically as part of the agent's self-update mechanism.

Frequently Asked Questions

How do I deploy custom plugins to multiple Server Scout agents?

Copy your custom plugin to `/opt/scout-agent/plugins.d/` on each server, set executable permissions with `chmod +x`, and restart the scout-agent service. For multiple servers, use configuration management tools like Ansible or shell scripts to automate this process across your infrastructure.

What's the difference between built-in and custom Server Scout plugins?

Built-in plugins (cPanel, DirectAdmin, Plesk, JetBackup, and devices) are automatically managed and update with the agent. Custom plugins are third-party or self-developed scripts that require manual deployment to `/opt/scout-agent/plugins.d/` and manual management across servers.

How do I troubleshoot failed plugin deployments?

Check the agent logs using `journalctl -u scout-agent | grep plugin` to verify the plugin loaded successfully. Ensure the plugin file has executable permissions and is in the correct `/opt/scout-agent/plugins.d/` directory. Restart the scout-agent service after deployment.

Can I rollback a custom plugin update if it causes issues?

Yes, you can rollback by either deploying the previous working version using the same deployment process, or disable the plugin by adding `plugin_<plugin_name>=0` to `/opt/scout-agent/scout.conf` and restarting the scout-agent service.

What's the best way to manage plugin versions across servers?

Include version comments at the top of your plugin files with version number and description. Use configuration management tools like Ansible for consistent deployment. Keep backup copies of working versions and document your plugin history for easy rollback.

Do I need to use Ansible for plugin deployment automation?

No, Ansible is one option among several. You can use any configuration management tool like Puppet, Chef, or Salt. For simpler environments, shell scripts with SSH can work for deploying plugins across multiple servers, though configuration management provides more robust consistency.

How do I verify a custom plugin deployed successfully?

After deployment and restarting the scout-agent service, check the agent logs with `journalctl -u scout-agent | grep plugin`. You should see messages indicating the plugin was loaded during the agent restart. This confirms successful deployment and activation.

Was this article helpful?