System Roles (Controller-driven)

In this exercise, you will use pre-existing content (roles and collections) from Automation Hub and Ansible Galaxy to configure hosts via Ansible Automation Controller. You will leverage Linux System Roles and RHEL System Roles with a simple Survey-driven job to manage firewall and timesync configuration.

Review the playbook

Open the repository in your browser and navigate to hardening.yml * https://github.com/ansible-tmm/RHEL-workshop-examples/blob/main/hardening.yml

Relevant tasks (roles are conditionally included):

- name: Configure Firewall
  when: harden_firewall | bool
  ansible.builtin.include_role:
    name: redhat.rhel_system_roles.firewall

- name: Configure Timesync
  when: harden_time | bool
  ansible.builtin.include_role:
    name: redhat.rhel_system_roles.timesync

About Linux and RHEL System Roles

System Roles provide consistent interfaces for subsystem configuration, abstracting implementation differences.

Examples:

  • firewall (linux-system-roles.firewall)

    • Controls services such as http/https and more

    • Example var:

      vars:
        firewall:
          service: 'http'
          state: 'enabled'
  • timesync (redhat.rhel_system_roles.timesync)

    • Manages chrony or ntp as appropriate

    • Example var:

      vars:
        timesync_ntp_servers:
          - hostname: pool.ntp.org
            iburst: yes

Create and launch the Job Template with a Survey

  1. In Controller, go to Automation Execution → Templates, click the Create template dropdown and select Create job template.

    Template fields:

Parameter Value

Name

SERVER / Hardening

Job Type

Run

Inventory

Workshop Inventory

Project

Workshop Project

Playbook

hardening.yml

Execution Environment

Default execution environment

Credentials

Workshop Credential

launch_template
  1. Click Create job template, then click the Survey tab and select Create survey question.

  2. Fill out the following for the first survey question:

    Parameter Value

    Question

    Configure Firewall?

    Answer Variable Name

    harden_firewall

    Answer Type

    Multiple Choice (single select)

    Multiple Choice Options

    true
    false

  3. Click Create survey question.

  4. Click Create survey question to add a second question:

    Parameter Value

    Question

    Configure Time?

    Answer Variable Name

    harden_time

    Answer Type

    Multiple Choice (single select)

    Multiple Choice Options

    true
    false

  5. Click Create survey question.

  6. Enable the survey by toggling the Survey enabled switch to the on position.

  7. Click Launch template. The survey will prompt you with two questions:

    • Configure Firewall? — select true

    • Configure Time? — select true

  8. Click Next, review the extra variables to confirm the survey values, then click Finish.

Verify configuration

Once the job completes, verify the time configuration is active using Run Command:

  1. Go to Automation Execution → Infrastructure → Inventories → Workshop Inventory and open the Hosts tab.

  2. Select node01 and node02, then click Run Command.

  3. In the Details window, set Module to command and Arguments to timedatectl. Click Next.

  4. In the Execution Environment window, select Default execution environment. Click Next.

  5. In the Credential window, select Workshop Credentials. Click Next.

  6. Review your inputs and click Finish.

Verify that the output shows NTP is active and synchronized.

Summary

In this exercise you:

  • Created a project pointing to the Product Demos repository with Linux and RHEL System Roles

  • Reviewed how firewall and timesync roles are conditionally included

  • Created a Job Template with a Survey to toggle role behavior

  • Launched the job and verified time synchronization configuration on managed hosts