Chapter 4. Managing Ansible Roles

In Satellite, you can import Ansible roles and Red Hat Enterprise Linux system roles to help with automation of routine tasks. Ansible is enabled by default on Satellite and Capsule.

If you use custom or third party Ansible roles, you must add the roles to the /etc/ansible/roles directory of the Capsule or Satellite where you want to use them.

For more information about support levels for Ansible in Satellite, see the Support for Ansible in Satellite section of the New Features and Enhancements in the Release Notes.

You must import the Ansible roles into Satellite Server from the /etc/ansible/roles directory before you can use them.

4.1. Importing Ansible Roles

You can import Ansible roles from a Capsule that has Ansible enabled or from the /etc/ansible/roles directory where Satellite Server is installed.

To import Ansible roles, complete the following steps:

  1. In the Satellite web UI, navigate to Configure > Roles and click the Capsule that contains the roles that you want to import.
  2. From the list of Ansible roles, select the check box of the roles you want to import, and then click Update.

4.2. Importing Ansible Variables

Ansible roles use variables to help refine the configuration of systems that have specific requirements. For example, you might need to identify the IP address of a system and use it as a configuration value on another system.

If you want to use Ansible variables in your Ansible playbooks, you must import the Ansible variables from Capsule.

Procedure

To import Ansible variables, complete the following steps:

  1. In the Satellite web UI, navigate to Configure > Variables.
  2. In the upper right of the window, select the Capsule that contains the Ansible variables that you want to import.
  3. Select the Ansible variables that you want to import, and click Update.

4.3. Creating Ansible Variables

Ansible roles use variables to help refine the configuration of systems that have specific requirements.

Usually, you can import Ansible variables for the Ansible roles that you are using. If you require further refinement of your system configuration, you can also create Ansible variables in Satellite.

Procedure

  1. In the Satellite web UI, navigate to Configure > Variables.
  2. In the upper right of the window, click New Ansible Variable.
  3. In the Key field, enter a name for the variable. Ensure that the name references the Ansible role name.
  4. In the Description field, add a description for the variable.
  5. From the Ansible role list, select the Ansible role to associate with the variable.
  6. Optional: To override the Ansible variable with Satellite, see the Section 4.4, “Overriding Ansible Variables in Satellite”.
  7. To save the Ansible variable, click Submit.

4.4. Overriding Ansible Variables in Satellite

If you run Ansible roles in Satellite, you can use Satellite to override Ansible variables for those roles.

Precedence in Overriding Variables

If you use an Ansible role to run a task as a user that is not the Effective User, there is a strict order of precedence for overriding Ansible variables. To ensure that the variable that you override follows the correct order of precedence, see Variable precedence: Where should I put a variable? in the Ansible User Guide.

Prerequisite

You must have Ansible variables in Satellite.

To import Ansible variables, see Section 4.2, “Importing Ansible Variables”.

To create Ansible variables, see Section 4.3, “Creating Ansible Variables”.

The following procedure makes reference to hosts and host groups. For more information about hosts and host groups, see the Managing Hosts guide.

Procedure

To override an Ansible variable, complete the following steps:

  1. In the Satellite web UI, navigate to Configure > Variables.
  2. Select the Ansible variable that you want to override and manage with Satellite.
  3. Navigate to the Default Behavior area, and select the Override check box.
  4. From the Parameter Type select the value type for validation. For example, a string or boolean variable.
  5. In the Default Value field, enter the default value that you want to use if there is no match for the variable.
  6. Optional: If you do not want to display the Ansible variable in plain text, select the Hidden Values check box to display the content of the variable as asterisks in the Satellite web UI.
  7. To save the override settings, click Submit.

To use the Ansible variable, add the variable as a parameter to your host or host group, or add the variable as a global parameter.

For a Host Group:

  1. In the Satellite web UI, navigate to Configure > Host Groups, and select the host group that you want to use.
  2. Click the Parameters tab, and in the Host Group Parameters area, click Add Parameter.
  3. In the Name field, add the Ansible variable name.
  4. From the Type list, select the type of the variable for validation.
  5. In the Value field, enter the value for the variable.

For a Host:

  1. In the Satellite web UI, navigate to Hosts > All Hosts, and on the host that you want to use, click the Edit button.
  2. Click the Parameters tab, and in the Host Parameters area, click Add Parameter.
  3. In the Name field, add the Ansible variable name.
  4. From the Type list, select the type of the variable for validation.
  5. In the Value field, enter the value for the variable.

To add as a Global Parameter:

  1. In the Satellite web UI, navigate to Configure > Global Parameters, and click Create Parameter.
  2. In the Name field, add the Ansible variable name.
  3. From the Type list, select the type of the variable for validation.
  4. In the Value field, enter the value for the variable.
  5. Optional: If you do not want to display the Ansible variable in plain text, select the Hidden Values check box to display the content of the variable as asterisks in the Satellite web UI.

4.5. Adding Red Hat Enterprise Linux System Roles

Red Hat Enterprise Linux System Roles is a configuration interface for Red Hat Enterprise Linux subsystems. You can use Red Hat Enterprise Linux System Roles to add Ansible roles in Satellite. Using Ansible Roles in Satellite can make configuration faster and easier.

For more information about Red Hat Enterprise Linux System Roles, see Red Hat Enterprise Linux System Roles.

Before subscribing to the Extras channels, see the Red Hat Enterprise Linux Extras Product Life Cycle article.

To Add Red Hat Enterprise Linux System Roles:

  1. Ensure that the rhel-7-server-extras-rpms repository is enabled.

    # subscription-manager repos --enable=rhel-7-server-extras-rpms
  2. Install the rhel-system-roles package.

    # satellite-maintain packages install rhel-system-roles

    The rhel-system-roles package downloads to /usr/share/ansible/roles/. You can view and make any modifications that you want to the files before you import.

  3. In the Satellite web UI, navigate to Configure > Roles and click the Capsule that contains the roles that you want to import.
  4. From the list of Ansible roles, select the check box of the roles you want to import, and then click Update.

You can now assign Ansible roles to hosts or host groups. For more information, see Assigning Ansible Roles to an Existing Host in the Managing Hosts guide.

You can also add the modules contained in these roles to your Ansible playbooks by adding them to Ansible Job Templates. You must include the hosts:all line in the job template. For more information, see Red Hat Enterprise Linux (RHEL) System Roles.