Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
12.2. Configuring and Running Remote Commands
12.2.1. Setting up Job Templates Link kopierenLink in die Zwischenablage kopiert!
Procedure 12.1. To Create a Job Template:
- Navigate to
. - Click Actions column, select Clone from the drop-down menu.. As an alternative, you can modify an existing template – in the
- Configure the job template:
- On the Template tab, enter a unique name for your job template. Select Default to make the template available for all organizations and locations. You can insert the template manually using Template editor or upload it from a text file by clicking . Templates use Embedded Ruby (ERB) template syntax, see Section 12.2.4, “Creating Advanced Templates” for more information. An advanced template is required, for example, for executing jobs that perform power actions; see Example 12.4, “Including Power Actions in Templates” for information on how to include the Power Action - SSH Default template in a custom template.
- On the Job tab, you can define the job category (define your own or select from the default categories listed in Table 12.1, “Default Job Template Categories”) as well as the effective user; these settings can be configured also when invoking the job (see Procedure 12.2, “To Execute a Remote Job:”). You can also define input parameters for template commands. These parameters are then requested when executing the job.
- Remaining tabs enable setting the template type, organizations and locations as well as viewing the template history.
- Click. When the page refreshes, your new template should appear in the list of job templates.
Important
Job template category
|
Description
|
---|---|
Packages | Templates for performing package related actions. Install, update, and remove actions are included by default. |
Puppet | Templates for executing Puppet runs on target hosts. |
Power | Templates for performing power related actions. Restart and shutdown actions are included by default. |
Commands | Templates for executing custom commands on remote hosts. |
Services | Templates for performing service related actions. Start, stop, restart, and status actions are included by default. |
Katello | Templates for performing content related actions. These templates are used mainly from different parts of the Satellite web UI (for example bulk actions UI for content hosts), but can be used separately to perform operations such as errata installation. |
Example 12.1. Creating a restorecon Template
SELinux
context for all files in the selected directory on target hosts.
- Navigate to
. Click . - Insert Run Command - restorecon in the Name field. Select Default to make the template available to all organizations. Add the following text to the Template editor:
restorecon -RvF <%= input("directory") %>
restorecon -RvF <%= input("directory") %>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The<%= input("directory") %>
string will be replaced by a user-defined directory during job invocation. - On the Job tab, perform the following actions:
- Set Job category to
Commands
. - Clickto allow job customization. Insert
directory
to the Name field. The input name must match the value specified in the Template editor. - Click Required so that the command cannot be executed without the user specified parameter.
- Select
User input
from the Input type drop-down list. Also provide a Description to be shown during job invocation, for example Target directory for restorecon.
- Click.
12.2.2. Executing Jobs Link kopierenLink in die Zwischenablage kopiert!
Procedure 12.2. To Execute a Remote Job:
- Navigate to
and select the target hosts for your job. You can use the search field to narrow down the host list. - From the Select Action menu at the upper right of the screen select Run Job. This will take you to the Job invocation page. Alternatively, if you target just one host, click its name and click on the host information page. Note that you can invoke jobs also from the Job Templates page by using the button.
- On the Job invocation page, define the main job settings:
- Select the Job category and the Job template you want to use. These settings are required.
- Optionally, select a stored search string in the Bookmark list to specify the target hosts.
- Optionally, further limit the targeted hosts by inserting a Search query. The Resolves to line displays the number of hosts affected by your query. Use the refresh button to recalculate the number after changing the query. The preview icon will list the targeted hosts.
- The remaining settings depend on the selected job template. See Procedure 12.1, “To Create a Job Template:” for information on adding custom parameters to a template.
- Clicking Display advanced fields will show advanced setting for the job. Some of the advanced settings depend on the job template, the following settings are general:
- Effective user defines the user for executing the job, by default it is the SSH user.
- Concurrency level defines maximum number of jobs executed at once, which can prevent overload of systems' resources in a case of executing the job on a large number of hosts.
- Time span defines time interval in seconds after which the job should be killed, if it is not finished already. A task which could not be started during the defined interval, for example, if the previous task took too long to finish, is canceled.
- Type of query defines when the search query is evaluated. This helps to keep the query up to date for scheduled tasks.
Concurrency level and Time span settings enable you to tailor job execution to fit your infrastructure hardware and needs. - If you want to execute the job immediately, ensure that Schedule is set to
Execute now
. You can also define a one-time future job, or set up a recurring job. For recurring tasks, you can define start and end dates, number and frequency of runs. You can also use cron syntax to define repetition. For more information about cron, see Automating System Tasks section of the Red Hat Enterprise Linux 7 System Administrator's Guide. - Click Job Overview page, and when the job completes, also displays the status of the job.. This displays the
Example 12.2. Executing a restorecon Template on Multiple Hosts
/home/
directory.
- Navigate to
and select target hosts. Select Run Job from the Select Action drop-down list. - In the Job invocation page, select the
Commands
job category and theRun Command - restorecon
job template. - Type
/home
in the directory field. - Set Schedule to
Execute now
. - Click Job invocation page where you can monitor the status of job execution.. You are taken to the
12.2.3. Monitoring Jobs Link kopierenLink in die Zwischenablage kopiert!
Procedure 12.3. To Monitor a Job:
- Navigate to the Job page. This page is automatically displayed if you triggered the job with the
Execute now
setting. To monitor scheduled jobs, navigate toand select the job run you wish to inspect. - On the Job page, click the Hosts tab. This displays the list of hosts on which the job is running.
- In the Host column, click the name of the host that you want to inspect. This displays the Detail of Commands page where you can monitor the job execution in real time.
- Click Job Details page.at any time to return to the
12.2.4. Creating Advanced Templates Link kopierenLink in die Zwischenablage kopiert!
httpd
service on Red Hat Enterprise Linux systems:
<%= render_template 'Package Action - SSH Default', :action => 'install', :package => 'httpd' %> <%= render_template 'Service Action - SSH Default', :action => 'start', :service_name => 'httpd' %>
<%= render_template 'Package Action - SSH Default', :action => 'install', :package => 'httpd' %>
<%= render_template 'Service Action - SSH Default', :action => 'start', :service_name => 'httpd' %>
input()
method to allow users to define input for the rendered template on job execution. For example, you can use the following syntax:
<%= render_template 'Package Action - SSH Default', :action => 'install', :package => input("package") %>
<%= render_template 'Package Action - SSH Default', :action => 'install', :package => input("package") %>
Example 12.3. Rendering a restorecon Template
/home/
directory on target hosts.
<%= render_template("Run Command - restorecon", :directory => "/home") %>
<%= render_template("Run Command - restorecon", :directory => "/home") %>
Example 12.4. Including Power Actions in Templates
<%= render_template("Power Action - SSH Default", :action => "restart") %>
<%= render_template("Power Action - SSH Default", :action => "restart") %>