3.7. Configuring Smart Variables from Puppet Classes

Some module classes contain variable parameters. Satellite 6 has the ability to import classes and allow modification of such parameters. This is called a smart variable.
For example, mymodule contains a parameter for the HTTP port of our web server. This parameter, httpd_port, is set to a default of 8120. However, a situation might occur where we need to use a different port for a provisioned system. Satellite 6 can convert the httpd_port parameter into a smart variable, override it, and send it back to the system during configuration. This provides an easy way to change the HTTP port on our webserver.
This procedure requires the mymodule module uploaded to a product and added to a content view. This is because we need to edit the classes in the resulting Puppet environment.
  1. Navigate to ConfigureSmart variables.
  2. A table appears listing all smart variables from the classes in your Puppet modules. Click on the httpd_port variable.
  3. The options for the smart variable appears. To allow overriding this variable during provisioning, select the Override option.
  4. Selecting the Override option allows us to change the Parameter type and Default value. This is useful if we aim to globally change this value for all future configurations.
    The following parameter types are available:
    String
    The value is interpreted as a plain text string. For example, if your smart variable sets the hostname, the value is interpreted as a string:
    myhost.example.com
    
    Boolean
    The value is interpreted and validated as a true or false value. Examples include:
    True
    true
    1
    
    Integer
    The value is interpreted and validated as an integer value. Examples include:
    8120
    -8120
    
    Real
    The value is interpreted and validated as a real number value. Examples include:
    8120
    -8120
    8.12
    
    Array
    The value is interpreted and validated as a JSON or YAML array. For example:
    ["Monday","Tuesday","Wednesday","Thursday","Friday"]
    
    Hash
    The value is interpreted and validated as a JSON or YAML hash map. For example:
    {"Weekdays": ["Monday","Tuesday","Wednesday","Thursday","Friday"], "Weekend": ["Saturday","Sunday"]}
    
    YAML
    The value is interpreted and validated as a YAML file. For example:
    email:
      delivery_method: smtp
      smtp_settings:
        address: smtp.example.com
        port: 25
        domain: example.com
        authentication: none
    
    JSON
    The value is interpreted and validated as a JSON file. For example:
    {
      "email":[
        {
          "delivery_method": "smtp"
          "smtp_settings": [
            {
              "address": "smtp.example.com",
              "port": 25,
              "domain": "example.com",
              "authentication": "none"
            }
          ]
        }
      ]
    }
    
    For this example, leave the default as 8120.
  5. Selecting the Override option also exposes Optional Input Validator, which provides validation for the overridden value. For example, we can include a regular expression to make sure httpd_port is a numerical value. For our example, leave this section blank.
  6. Selecting the Override option also exposes Override Value For Specific Hosts, which defines a hierarchical order of system facts and a set of matcher-value combinations. The matcher-value combinations determine the right parameter to use depending on an evaluation of the system facts. For our example, leave this section with the default settings.
  7. Click Submit.
We now have a smart variable for httpd_port. We can set a value for this smart variable at either a Host Group level or at a Host level.