Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
Hello, Readers!!
Have you guys heard about Puppet Enterprise?
No? Don't worry. We got you covered. Puppet Enterprise, or PE, is the commercial version of Puppet. It is built on top of the Puppet platform. It allows the IT operations teams to manage and automate more infrastructure and complex workshops in a simple and powerful way.
In this blog, we will discuss about the Concept of running Puppet on demand.
So let us begin!!
Run Puppet on Demand
The user can use the orchestrator in order to run jobs from the console, command line, or even through the orchestrator API endpoints.
Run Puppet on demand from the console Whenever the user sets up a job to run the Puppet from the console, then the orchestrator creates a job ID in order to track the job, it shows the user all the nodes included in the job and also runs the Puppet on the targeted nodes in an appropriate order. Puppet compiles a new catalog for every node that is included in the job.
Run Puppet on demand from the CLI The user can start an on-demand Puppet run to enforce any changes made onto the agent nodes using the puppet job run command.
Run Puppet on Demand from the console
Whenever the user sets up a job to run the Puppet from the console, then the orchestrator creates a job ID in order to track the job, it shows the user all the nodes included in the job and also runs the Puppet on the targeted nodes in an appropriate order. Puppet compiles a new catalog for every node that is included in the job.
The user can specify only one of the below-mentioned targets for a job:
List of one or more specific nodes.
Node group.
PQL(Puppet Query Language) query that defines a set of nodes.
Run Puppet of one or more specific nodes
An orchestrator job has the ability to target one or more specific nodes. This comes in handy when the user wants to run Puppet on a single node, a few specific nodes, nodes that are not in the same node group, or nodes that a single PQL query can not easily identify.
From the Jobs page in the console, click on Run Puppet.
Provide a description in the Job description field. Optional.
Choose an environment
Run nodes in their own assigned environment: in this, the nodes run in the environment which is specified by the Node manager or Puppet.config file.
Choose an environment for the nodes to run in: the user can select an environment from the list. Nodes can run in an environment only if their environment is either agent specified or if they are classified in that environment by their node manager.
Choose a run mode for the job. By default, the run mode, which is applied for the job, tries to enforce the new catalogs on the nodes. The user can change the run mode using the following selections:
No-op: it simulates a Puppet run on all of the nodes in the job without enforcing a new catalog.
Debug: it prints all the debugging messages.
Trace: it prints stack traces on some errors.
Eval-trace: it displays how long it took for each of the steps to run.
Override noop = true configuration: if any of the nodes in the job has their noop=true set in their Puppet.conf file, then Puppet ignores that setting and enforces a new catalog for such nodes.
Select a Node list from the Inventory list.
In order to create a node list, start typing in the names of nodes to search for in the search field and then click on Search.
Choose the nodes that you want to add to the job. The user can select nodes from multiple searches in order to create a complete target node list.
Click Run job
Run Puppet on a PQL query
An orchestrator job has the ability to target a set of nodes that are based on a PQL query. This comes in handy when the user wants to target a variable set of nodes that meet certain conditions. When the user supplies a PQL query, the orchestrator then runs the job on a list of nodes that are generated by the PQL query.
From the Jobs page in the console, click on Run Puppet.
Provide a description in the Job description field. Optional.
Choose an environment
Run nodes in their own assigned environment: in this, the nodes run in the environment which is specified by the Node manager or Puppet.config file.
Choose an environment for the nodes to run in: the user can select an environment from the list. Nodes can run in an environment only if their environment is either agent specified or if they are classified in that environment by their node manager.
Choose a run mode for the job. By default, the run mode, which is applied for the job, tries to enforce the new catalogs on the nodes. The user can change the run mode using the following selections:
No-op: it simulates a Puppet run on all of the nodes in the job without enforcing a new catalog
Debug: it prints all the debugging messages.
Trace: it prints stack traces on some errors.
Eval-trace: it displays how long it took for each of the steps to run.
Override noop = true configuration: if any of the nodes in the job has their noop=true set in their Puppet.conf file, then Puppet ignores that setting and enforces a new catalog for such nodes.
Select a PQL query from the list of target types.
Select a target by performing any one of the following:
Enter a query that selects all the desired targets.
Or click on Common queries, choose any of the queries, and then replace the defaults in the braces with values that specify the desired target.
Click on Submit query and then click Refresh in order to update the node results.
If the user makes any changes to the query after it runs, then the user needs to click on Submit query again.
Click Run job
Add custom PQL queries to the console
The user can add their own PQL queries to the console in order to quickly access them when running jobs.
Copy the custom_pql_queries.json.example file, and remove the .example suffix on the primary server.
Edit the file contents as per need to either include your own PQL queries or to remove any existing queries.
Refresh the console UI.
Run Puppet on a node group
An orchestrator job has the ability to target all the nodes in a specific node group.
From the Jobs page in the console, click on Run Puppet.
Provide a description in the Job description field. Optional.
Choose an environment
Run nodes in their own assigned environment: in this, the nodes run in the environment which is specified by the Node manager or Puppet.config file.
Choose an environment for the nodes to run in: the user can select an environment from the list. Nodes can run in an environment only if their environment is either agent specified or if they are classified in that environment by their node manager.
Choose a run mode for the job. By default, the run mode, which is applied for the job, tries to enforce the new catalogs on the nodes. The user can change the run mode using the following selections:
No-op: it simulates a Puppet run on all of the nodes in the job without enforcing a new catalog.
Debug: it prints all the debugging messages.
Trace: it prints stack traces on some errors.
Eval-trace: it displays how long it took for each of the steps to run.
Override noop = true configuration: if any of the nodes in the job has their noop=true set in their Puppet.conf file, then Puppet ignores that setting and enforces a new catalog for such nodes.
Select a Node group from the list of target types.
Type or choose a node group and then click on Select from the Choose a node group box.
Click Run job
Schedule a Puppet run
The user can schedule a job in order to deploy the configuration changes at a particular date and time or on a recurring schedule.
If in case a reboot occurs or if the user restores a backup, then the scheduled Puppet jobs get rescheduled based on the last execution time. If in case a reboot occurs due to a scheduled Puppet job that was running in the orchestrator, then that job returns a failed status.
From the Jobs page in the console, click on Run Puppet.
Provide a description in the Job description field. Optional.
Choose an environment
Run nodes in their own assigned environment: in this, the nodes run in the environment which is specified by the Node manager or Puppet.config file.
Choose an environment for the nodes to run in: the user can select an environment from the list. Nodes can run in an environment only if their environment is either agent specified or if they are classified in that environment by their node manager.
In the Schedule section, choose Later and then select a start date, time, time zone, and frequency for that job to run.
Choose a run mode for the job. By default, the run mode, which is applied for the job, tries to enforce the new catalogs on the nodes. The user can change the run mode using the following selections:
No-op: it simulates a Puppet run on all of the nodes in the job without enforcing a new catalog.
Debug: it prints all the debugging messages.
Trace: it prints stack traces on some errors.
Eval-trace: it displays how long it took for each of the steps to run.
Override noop = true configuration: if any of the nodes in the job has their noop=true set in their Puppet.conf file, then Puppet ignores that setting and enforces a new catalog for such nodes.
Choose a category of nodes that you want to target from the list of target types:
Node list: add individual nodes by their name.
PQL query: use PQL to retrieve the list of nodes.
Node group: choose an existing node group.
Click on Schedule job.
Delete a scheduled job
The user can delete a job that is scheduled to run at a later time or even at recurring intervals.
If in case the user wants to delete a scheduled job that another user creates, then the user must have the appropriate role-based permissions in order to do it.
Go to Jobs in the console.
Switch to the Scheduled Puppet Run tab.
Select the scheduled job that is to be deleted, and then click Remove.
Stop an in-progress job
The user has the ability to stop a job. If the user stops a Puppet job, then the in-progress jobs finish, and jobs that aren't started yet are cancelled.
In order to stop a job:
Go to Jobs in the console. Switch to the Puppet run tab and choose the job that is to be stopped. Then click on Stop
Press CTRL + C f the job was started on the command line.
Run Puppet on demand from the CLI
The user can use the puppet job run command in order to start an on-demand Puppet run to enforce any changes made onto the agent nodes.
Each time when the Puppet job run command is used, the user can select only of the below-mentioned targets:
List of one or more specific nodes that are identified by certname.
Node group that is identified by node group ID
PQL query that defines a set of nodes.
Run Puppet on one or more specific nodes
An orchestrator job has the ability to target one or more specific nodes that are identified by certname. This comes in handy when the user wants to run Puppet on a single node, a few specific nodes, nodes that do not belong to the same node group or nodes that the PQL query can't easily identify.
The user needs to login into their primary server or client tools workstation.
Run any one of the below-mentioned commands:
In order to run a job on a single node:
puppet job run --nodes <NODE NAME>
In order to run a job on multiple nodes, use a comma-separated list of node names:
puppet job run --nodes <COMMA_SEPARATED_LIST_OF_NODE_NAMES>
In order to run a job of a list of nodes in a text file:
puppet job run --nodes @<PATH_TO_.txt_FILE>
Results
Whenever the puppet job run command is executed, the orchestrator creates a job ID for the job, shows the user all the nodes targeted by the job, and then runs the Puppet on the targeted nodes in an appropriate order. Puppet compiles a new catalog for every node that is included in the job.
In order to view the job status
puppet job show <JOB_ID>
Run Puppet on a PQL query
An orchestrator job has the ability to target a set of nodes that are based on a PQL query. This comes in handy when the user wants to target a variable set of nodes that meet certain conditions. When the user supplies a PQL query, the orchestrator then runs the job on a list of nodes that are generated by the PQL query.
The user needs to login into their primary server or client tools workstation.
Run any one of the below-mentioned commands:
In order to supply the PQL query in the command:
puppet job run --query '<QUERY>
In order to supply the query in a text file:
puppet job run --query @<PATH_TO_.txt_FILE>
The below table shows examples of PQL queries that the user might use for any particular node targets:
Results
Whenever the puppet job run command is executed, the orchestrator creates a job ID for the job, it shows the user all the nodes targeted by the job, and then runs the Puppet on the targeted nodes in an appropriate order. Puppet compiles a new catalog for every node that is included in the job.
In order to view the job status
puppet job show <JOB_ID>
Post-run node status
The orchestrator returns a list of target nodes along with their run statuses after the Puppet run.
Nodes can have any of the following statuses:
In case of completed runs, the orchestrator prints their configuration version, transaction ID, and summary of resource events along with a link to the full node run report in the console.
In case of in-progress runs, the orchestrator prints the elapsed time.
In case of a failed run, subsequent or related runs might be skipped. For the failed runs, the orchestrator prints an error message which indicates why the run failed, a complete list of applications which were affected by this failure, and any applications that were affected by the skipped node run.
Frequently Asked Questions
Which command is used to run Puppet on demand from the CLI
The puppet job run command is used to run Puppet on demand from the CLI.
Can a user delete a scheduled job?
Yes, a user can delete a scheduled job from the Scheduled Puppet Run tab.
Mention a way to stop an in-progress job.
An in-progress job can be stopped by pressing CTRL + C on the command line.
Conclusion
In this article, we have extensively discussed the Concept of running Puppet on demand.
If you wish to enhance your skills in Data Structures and Algorithms, Competitive Programming, JavaScript, etc., you should check out our Guided path column at Coding Ninjas Studio. We at Coding Ninjas Studio organize many contests in which you can participate. You can also prepare for the contests and test your coding skills by giving the mock test series available. In case you have just started the learning process, and your dream is to crack major tech giants like Amazon, Microsoft, etc., then you should check out the most frequently asked problems and the interview experiences of your seniors that will surely help you in landing a job in your dream company.