Configure the use of an Ansible Role on a Satellite Server.
Outcomes
Install an additional Ansible Role on the Satellite Server.
Customize and test an Ansible Role by using remote execution.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command prepares your environment and ensures that all required resources are available.
[student@workstation ~]$ lab start remote-configure
Instructions
The Operations system administration team uses Ansible Playbooks.
A system administrator created a playbook that can modify a system banner, packaged the files in a compressed archive, and placed the archive on the satellite system.
This exercise practices the same procedure as to install archived playbooks and roles that are downloaded from the Ansible Galaxy website.
Log in to the satellite system as the student user and switch to the root user.
[student@workstation ~]$ssh student@satellite[student@satellite ~]$sudo -i[sudo] password for student:student[root@satellite ~]#
The ansible-role.tgz archive is in the root user's home directory.
Create the motd role by using the extracted files from the ansible-role.tgz archive.
Build the role in the default /etc/ansible/roles/ directory.
Extract the files from the archive.
[root@satellite ~]# tar xzvf ansible-role.tgz
main.yaml
motd.j2View the contents of each file.
[root@satellite ~]#cat main.yaml- name: New /etc/motd file template: src: motd.j2 dest: /etc/motd mode: 644 owner: root group: root [root@satellite ~]#cat motd.j2This example configuration uses Ansible and Satellite to create the /etc/motd file for the RH403 course. This message uses a variable passed from Satellite: {{ new_var }}
Create the motd role subdirectories, and then copy each file into the correct subdirectory.
The main.yml file is a task playbook, and the motd.j2 file is a Jinja2 template.
[root@satellite ~]#mkdir -p /etc/ansible/roles/motd/{tasks,templates}[root@satellite ~]#cp main.yaml /etc/ansible/roles/motd/tasks[root@satellite ~]#cp motd.j2 /etc/ansible/roles/motd/templates
Log in to the Satellite Server web UI, https://satellite.lab.example.com, as the admin user with redhat as the password.
In the upper-left corner of the web page, set the organization to Operations.
Set the location to Any Location.
Import the motd Ansible Role into the Satellite Server and configure the new_var Jinja2 template variable.
Click → , and then click . Click the checkbox for the role and click .
Click → , and then click . Complete the fields in the following table and then click to create the variable.
| Field | Description |
|---|---|
| new_var | |
| Checked | |
Hello from the RH403 course.
|
Assign the motd role to the servera system.
Click → , and then click the link. Click .
Click the tab.
Click the plus sign (+) next to the role to assign the role to the servera system.
Click .
Use remote execution to run the motd role to customize the servera system banner.
Click → . Select the checkbox for . Select from the list.
On the Overview tab, monitor the remote execution status. Wait for the process to complete. To view the remote command output, scroll down and click the link.
Log in to the servera system, and verify that the role customized the system banner.
[student@workstation ~]$ssh student@serveraWelcome to my new customized serverThis example configuration uses Ansible and Satellite to create the /etc/motd file for the RH403 course. This message uses a variable that is passed from Satellite: Hello from the RH403 course....output omitted...
Return to the workstation system as the student user.
[student@servera ~]$ exit
logout
Connection to servera closed.
[student@workstation ~]$