Self-Service Puppet Enterprise tasks with Morpheus - Hybrid Cloud Management and Automation | Morpheus

Self-Service Puppet Enterprise tasks with Morpheus

Automation is a key enabler of the digital transformation initiatives that organizations of all sizes have embarked upon the last few years. Automation is also a great force multiplier but is less effective when the automation builders are also the automation executors. As the adoption of automation has continued to grow, the need for scaling that automation beyond Centers of Excellence (CoE) or those well versed in the automation tools grows as well. Enterprise organizations have adopted Puppet Enterprise to meet their automation needs. Puppet Enterprise supports the execution of ad-hoc automation tasks. This complements the agent based configuration management that the platform has become known for. In this blog post we’ll walk through how to trigger a Puppet Enterprise automation task through the Morpheus self-service portal.


The goal of this solution is to empower individuals in enterprise organizations to self serve automation via the Morpheus service catalog. This post assumes that the Puppet Enterprise server is running a version that supports tasks and nodes have been added to the inventory.

The following high level steps are how the solution will work:

  • The requestor completes the request form in the Morpheus self-service catalog and submits the order
  • The Morpheus platform triggers the requested Puppet Enterprise task via a REST API call
  • Puppet Enterprise runs the task against the selected node(s)

Inputs/Options Types

The first thing we’ll do is create the inputs that the requestor will be prompted to fill in.

Package NamePackage ActionPuppet EnvironmentPuppet Targets
NamePuppet Package NamePuppet Package ActionPuppet EnvironmentPuppet Targets
Field NamepackageNamepackageActionpuppetEnvironmentpuppetTargets
LabelPackage NameActionPuppet EnvironmentTargets
Option ListN/APuppet Package ActionsN/APuppet Targets

Option Lists

We’ll use option lists for the package action and the Puppet Enterprise target nodes. The package action will use a manual list with static entries and the puppet targets list will query the Puppet Enterprise REST API for the target nodes. The Puppet Enterprise REST API call is against an authenticated endpoint and requires a Puppet Enterprise token for authentication.

Puppet Package ActionsPuppet Targets
NamePuppet Package ActionsPuppet Targets
TypeManualREST API
Data Set[
{“name”: “Install”, “value”: “install”},
Source URLN/A
Source MethodN/AGET
Source HeadersN/AContent-Type: application/json
X-Authentication: PE_TOKEN
Translation ScriptN/AinputData = data.items
for(var x=0;x < inputData.length; x++) {
results.push({name: inputData[x].name, value:inputData[x].name});


Before we create our Python script we’ll store the Puppet Enterprise token in Morpheus Cypher to easily access it from our Python script.

Automation Task

The core of the integration is the REST API call to the Puppet Enterprise server. In this case we’ll create a Morpheus python script task to interact with the Puppet Enterprise orchestrator API endpoint.

import requests
import time
from morpheuscypher import Cypher


url = ''
token = Cypher(morpheus=morpheus,ssl_verify=False).get('secret/petoken')
headers = {'X-Authentication': token, "Content-Type": "application/json"}

instances = []
if type(morpheus['customOptions']['puppetTargets']).__name__ == 'list':
    for vm in morpheus['customOptions']['puppetTargets']:
    instances = [morpheus['customOptions']['puppetTargets']]

payload = {}
payload['environment'] = morpheus['customOptions']['puppetEnvironment']
payload['task'] = "package"
payload['params'] = {}
payload['params']['action'] = morpheus['customOptions']['packageAction']
payload['params']['name'] = morpheus['customOptions']['packageName']
payload['scope'] = {}
payload['scope']['nodes'] = instances

r =, headers=headers, data=json.dumps(payload), verify=False)
jsonResponse = r.json()

jobDetails = requests.get(jsonResponse['job']['id'] + '/nodes', headers=headers, verify=False)
jobResponse = jobDetails.json()

for item in jobResponse['items']:
    print("Name: " + item['name'])
    print("Duration: " + str(item['duration']))
    print("State: " + item['state'])
    print("Result: " + str(item['result']))

Automation Workflow

Now that we’ve got our automation task, we need to create an operational workflow in Morpheus. The workflow enables us to associate inputs or option types with the automation task. It also allows us to create a catalog item in the self-service catalog. We’ll add the task we created in the previous step along with the inputs or option types.

Puppet Enterprise task automation workflow

Self-Service Catalog Item

At this point we can trigger the workflow without a catalog item but we want to simplify the request process by creating a service catalog item. In this example we’ve created a catalog item that includes the custom options created earlier.

Puppet Enterprise task service catalog item

Once the catalog item has been ordered the results of the task execution will be made available in the catalog inventory to review.


In this blog post we looked at how to run Puppet Enterprise tasks in a self-service fashion using the Morpheus self-service catalog. This enables IT teams to scale their automation across the organization and empower other teams to consume automation at the push of a button.

Try Morpheus Community Edition or Get a Demo
The Morpheus Community Edition lets you fully experience the Morpheus platform including nearly all features and capabilities! Register at Morpheus Hub and try it in your home lab or test environment today! Interested in learning more about Morpheus from one of our cloud transformation experts? Schedule a demo to walk through how Morpheus can help your organization here.