Configure several job templates, as well as a supporting project and source control credentials.
Outcomes
Create a machine credential and a source control credential.
Create a project.
Create an inventory and use a static inventory file stored in a Git repository as its source.
Create some job templates.
Launch the job templates from the automation controller web UI.
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 compreview-templates
Specifications
In this lab, you create a job template for a log server configuration and a job template for the configuration of the clients. You also create the necessary credentials and use an existing inventory stored in a Git repository as an inventory source.
Your automation controller is at https://controller.lab.example.com. You can log in to it using admin as the user and redhat as the password.
Create a machine credential in your automation controller using the information in the following table.
| Field | Value |
|---|---|
Virtual Machines
| |
Credential for managing virtual machines
| |
devops
| |
redhat
| |
root
|
Because the devops user does not need to enter a password to run sudo commands, you do not need to enter a password in the field.
Create a source control credential in your automation controller using the information in the following table.
| Field | Value |
|---|---|
Git Credential
| |
git
| |
Contents of the /home/student/.ssh/gitlab_rsa file |
If you choose to browse for the /home/student/.ssh/gitlab_rsa file, then right-click anywhere in the directory navigation and select . With this option enabled, you can see the .ssh directory within the /home/student directory.
Create a new project in your automation controller using the information in the following table. Notice that you use the source control credential previously created. After you save the project, verify that automation controller reports the success of the project synchronization.
| Field | Value |
|---|---|
Log Centralization
| |
Log Centralization Project
| |
git@git.lab.example.com:git/compreview-templates.git
| |
If the project synchronization fails, then ensure that the project specifies the correct source control URL and the correct source control credential. Ensure that the source control credential uses the correct values and then attempt the project synchronization again.
Create an inventory in your automation controller called Lab Git Sourced in the Default organization.
| Field | Value |
|---|---|
Lab Git Sourced
| |
Then, add a source for this inventory using the information in the following table. After you save the Git Inventory Lab source, start the synchronization process. Verify that the synchronization process succeeds.
| Field | Value |
|---|---|
Git Inventory Lab
| |
| (selected) |
You might see the following message below the field, even if you selected the project name from the list of projects.
That value was not found. Please enter or select a valid value.
The message disappears as soon as you select a different field.
Review the tab and the tab for the Lab Git Sourced inventory. The hosts are grouped as shown in the following table. Notice that the variables for the dev_clients and prod_clients groups are also imported.
| Parent group | Children group | Host |
|---|---|---|
log_servers
|
dev_servers
|
servera.lab.example.com
|
prod_servers
|
serverd.lab.example.com
| |
log_clients
|
dev_clients
|
serverb.lab.example.com
|
serverc.lab.example.com
| ||
prod_clients
|
servere.lab.example.com
| |
serverf.lab.example.com
|
Create a job template in your automation controller using the information in the following table. This job template configures a centralized log server on each of the hosts in the log_servers group for the Lab Git Sourced inventory.
| Field | Value |
|---|---|
Log Servers Deploy
| |
Create a job template in your automation controller using the information in the following table. This job template configures each of the hosts in the log_clients group for the Lab Git Sourced inventory as a client for its respective log server.
| Field | Value |
|---|---|
Log Clients Deploy
| |
Launch the Log Servers Deploy job template. Observe the live output of the running job. Verify that the job succeeds.
Launch the Log Clients Deploy job template. Observe the live output of the running job. Verify that the job succeeds.
Verify that the hosts from the dev_clients group in the Lab Git Sourced inventory send logs to servera.lab.example.com. Use the logger "This is a test" command to create a log entry in the dev_clients hosts.
Verify that the hosts from the prod_clients group in the Lab Git Sourced inventory send logs to serverd.lab.example.com. Use the logger "This is a test" command to create a log entry in the prod_clients hosts.
Navigate to https://controller.lab.example.com and log in as the admin user with redhat as the password.
Create a machine credential using the information in the following table.
| Field | Value |
|---|---|
Virtual Machines
| |
Credential for managing virtual machines
| |
devops
| |
redhat
| |
root
|
Navigate to → and click to add a new credential.
Enter Virtual Machines in the field and Credential for managing virtual machines in the field.
Select the organization.
In the list, choose .
Enter devops in the field and redhat in the field.
In the list, choose .
Enter root in the field.
Click to save the machine credential.
Create a source control credential using the information in the following table.
| Field | Value |
|---|---|
Git Credential
| |
git
| |
Content of the /home/student/.ssh/gitlab_rsa file. |
Navigate to → and click to add a new credential.
Enter Git Credential in the field.
Select the organization.
In the list, choose .
Enter git in the field and click in the field.
By default, the directory navigation window opens in the directory. Click to move to the home directory for the student user.
Right-click anywhere in the directory navigation window and select .
Change to the hidden directory, then select the file, and click .
Click to save the source control credential.
Create a new project using the information in the following table. After you save the project, verify that automation controller reports the success of the project synchronization.
| Field | Value |
|---|---|
Log Centralization
| |
Log Centralization Project
| |
git@git.lab.example.com:git/compreview-templates.git
| |
Navigate to → and then click to create a new project.
Enter Log Centralization in the field and Log Centralization Project in the field.
Select the organization if it is not selected by default.
In the list, choose .
Enter git@git.lab.example.com:git/compreview-templates.git in the field.
Select the source control credential.
Click to save the project.
Automation controller automatically attempts to synchronize the new project. On the page for the project, verify that the field displays the message.
If the project synchronization fails, then ensure that the project specifies the correct source control URL and the correct source control credential.
Create an inventory called Lab Git Sourced in the Default organization.
| Field | Value |
|---|---|
Lab Git Sourced
| |
Then, add a source for this inventory using the information in the following table. After you save the Git Inventory Lab source, start the synchronization process. Verify that the synchronization process succeeds.
| Field | Value |
|---|---|
Git Inventory Lab
| |
| (selected) |
Navigate to → .
Click → .
Enter Lab Git Sourced in the field and select the organization. When done, click .
Click in the tab, and then click to add a source for the inventory.
Enter Git Inventory Lab in the field.
In the list, choose .
Select the project. You might see the following message below the field:
That value was not found. Please enter or select a valid value.
The message disappears as soon as you select a different field.
Select inventory as the .
Select the option and click when done.
Click and wait until the value of the field displays the message.
Review the tab and the tab for each group in the Lab Git Sourced inventory. The hosts are grouped as shown in the following table. Notice that the variables for the hosts in the log_clients group are also imported.
| Parent group | Child group | Host |
|---|---|---|
log_servers
|
dev_servers
|
servera.lab.example.com
|
prod_servers
|
serverd.lab.example.com
| |
log_clients
|
dev_clients
|
serverb.lab.example.com
|
serverc.lab.example.com
| ||
prod_clients
|
servere.lab.example.com
| |
serverf.lab.example.com
|
Navigate to → .
Click the link.
Review the tab and the tab and notice the groups and hosts that were added to the inventory. You can use the preceding table for reference.
Click the tab for the dev_clients group and notice the variables are also imported.
Click the tab for the prod_clients group and notice the variables are also imported.
Create a job template using the information in the following table. This job template configures a centralized log server on each of the hosts in the log_servers group for the Lab Git Sourced inventory.
| Field | Value |
|---|---|
Log Servers Deploy
| |
Navigate to → .
Click → .
Enter Log Servers Deploy in the field.
Select as the if it is not selected by default.
Select the inventory and the project.
In the list, choose .
Select the credential.
Click to save the job template.
Create a job template using the information in the following table. This job template configures each of the hosts in the log_clients group for the Lab Git Sourced inventory as a client for its respective log server.
| Field | Value |
|---|---|
Log Clients Deploy
| |
Navigate to → .
Click → .
Enter Log Clients Deploy in the field.
Select as the if it is not selected by default.
Select the inventory and the project.
In the list, choose .
Select the credential.
Click to save the job template.
Launch the Log Servers Deploy job template. Observe the live output of the running job. Verify that the job succeeds.
Navigate to → .
Click the icon for the job template.
Observe the live output of the running job.
Click the tab and verify that the field displays the message.
Launch the Log Clients Deploy job template. Observe the live output of the running job. Verify that the job succeeds.
Navigate to → .
Click the icon for the job template.
Observe the live output of the running job.
Click the tab and verify that the field displays the message.
Use the logger "This is a test" command to create a log entry in each of the dev_clients hosts. Verify that servera.lab.example.com, which is the only host in the dev_servers group, receives the log entries.
Open a terminal on the workstation machine and use the logger command to create a log entry in the serverb.lab.example.com and serverc.lab.example.com hosts.
[student@workstation ~]$ssh serverb.lab.example.com "logger 'This is a test'"[student@workstation ~]$ssh serverc.lab.example.com "logger 'This is a test'"[student@workstation ~]$
Verify that the logging server receives the messages. Use the devops user in the servera.lab.example.com host for consulting the message in the /var/log/messages file. This user can run sudo commands without entering a password.
[student@workstation ~]$ssh devops@servera.lab.example.com \>"sudo grep 'This is a test' /var/log/messages"Aug 10 13:06:01serverbstudent[1266]: This is a test Aug 10 13:06:07servercstudent[1263]: This is a test [student@workstation ~]$
Use the logger "This is a test" command to create a log entry in the prod_clients hosts. Verify that serverd.lab.example.com, which is the only host in the prod_servers group, receive the log entry.
Open a terminal on workstation and use the logger command to create a log entry in the servere.lab.example.com and serverf.lab.example.com hosts.
[student@workstation ~]$ssh servere.lab.example.com "logger 'This is a test'"[student@workstation ~]$ssh serverf.lab.example.com "logger 'This is a test'"[student@workstation ~]$
Verify that the logging server receives the messages. Use the devops user in the serverd.lab.example.com host for consulting the message in the /var/log/messages file. This user can run sudo commands without entering a password.
[student@workstation ~]$ssh devops@serverd.lab.example.com \>"sudo grep 'This is a test' /var/log/messages"Aug 10 13:07:37serverestudent[1310]: This is a test Aug 10 13:07:41serverfstudent[1308]: This is a test [student@workstation ~]$