Skip to main content
Ralph supports integration with configuration management tools like Puppet and Ansible through its configuration path system. This allows you to automate host configuration by fetching configuration data from Ralph’s API.

Overview

Ralph provides a hierarchical configuration system that can be mapped to your configuration management tool’s structure:
  • Configuration Modules - Top-level groupings (e.g., Puppet modules or Ansible roles)
  • Configuration Classes - Specific configurations to apply (e.g., Puppet classes or Ansible playbooks)
  • Configuration Path - Per-host configuration assignment
  • Configuration Variables - Custom fields exposed as variables

Configuration Modules

Configuration modules represent the top-level organization of your configurations.

Creating Configuration Modules

  1. Navigate to https://<YOUR-RALPH-URL>/assets/configurationmodule/
  2. Click “Add configuration module”
  3. Fill in the details:
    • Name - Module name (e.g., apache, mysql, monitoring)
    • Parent - Optional parent module for hierarchical organization
    • Support team - Team responsible for this module

Hierarchical Structure

You can organize modules in a tree structure to reflect your directory layout:
For Puppet users, configuration modules map directly to Puppet modules.For Ansible users, use modules to group related roles or playbooks.

Configuration Classes

Configuration classes define specific configurations to be applied to hosts.

Creating Configuration Classes

  1. Navigate to https://<YOUR-RALPH-URL>/assets/configurationclass/
  2. Click “Add configuration class”
  3. Configure:
    • Module - Parent configuration module
    • Class name - Specific configuration name
    • Path - Full path (auto-generated from module hierarchy)
For Puppet users, this maps to Puppet classes.For Ansible users, map this to Ansible playbooks.

Assigning Configuration to Hosts

Assign configuration to assets using the configuration_path field:
  1. Edit a Data Center Asset, Virtual Server, or Cloud Host
  2. Set the Configuration Path field
  3. Save the asset
The configuration path is now available via the API and can be used by your automation tools.

Via API

Assign configuration when creating or updating an asset:

Puppet Integration

Architecture

Ralph serves as the External Node Classifier (ENC) for Puppet:
  1. Puppet agent requests configuration for a host
  2. Puppet master queries Ralph API for host details
  3. Ralph returns configuration path and variables
  4. Puppet master applies the appropriate classes

Fetching Configuration from Ralph

Create a Puppet ENC script (/etc/puppetlabs/puppet/ralph_enc.py):
Make it executable:

Configure Puppet Master

Edit /etc/puppetlabs/puppet/puppet.conf:
Restart Puppet master:

Example Puppet Output

When Puppet queries Ralph for web01.example.com, the ENC script returns:

Ansible Integration

Dynamic Inventory Script

Create an Ansible dynamic inventory script (inventory/ralph.py):
Make it executable:

Using the Dynamic Inventory

Test the inventory:
Use with Ansible:

Configure ansible.cfg

Example Playbook

Configuration Variables

Ralph allows you to define custom fields that are exposed as configuration variables via the API.

Creating Configuration Variables

  1. Navigate to AdminCustom Fields
  2. Create a new custom field
  3. Check “Use as configuration variable”
  4. Apply to relevant model (Data Center Asset, Virtual Server, etc.)

Accessing Variables

Configuration variables are available in the API response under configuration_variables:
Response:
These variables can be used in your Puppet manifests, Ansible playbooks, or other automation tools.

Best Practices

Naming Conventions

  • Use clear, descriptive names for modules and classes
  • Follow your organization’s naming standards
  • Use hierarchical paths that reflect your infrastructure

Security

Protect your API tokens:
  • Store tokens in secure locations (e.g., HashiCorp Vault, AWS Secrets Manager)
  • Use read-only tokens when possible
  • Rotate tokens regularly
  • Never commit tokens to version control

Error Handling

  • Implement retry logic for API calls
  • Log all API errors for troubleshooting
  • Provide fallback configurations if Ralph is unavailable
  • Monitor API response times

Caching

Consider caching Ralph API responses to reduce load:

Testing

Always test configuration changes:

Troubleshooting

API Connection Issues

Missing Configuration Path

If assets don’t have a configuration path:
  1. Check that configuration modules and classes are created
  2. Verify the asset has a configuration path assigned
  3. Ensure your API query is correct
  4. Check API permissions for the user/token

Puppet ENC Debugging

Ansible Inventory Debugging