Enable and configure remote execution jobs, and use remote execution to run Ansible Playbooks on a content host.
Outcomes
Configure a managed host for remote execution.
Run remote execution jobs, including Ansible Playbooks.
Create job templates for multiple executions of remote commands on a content host.
The comprehensive review labs are related exercises, and you can start with any lab in the sequence. If you reset your lab environment before your first comprehensive review lab, then you do not need to reset again. If you did not reset your lab environment after performing exercises from previous chapters, then you must reset your lab environment before starting any comprehensive review lab.
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-remote
Specifications
Register the serverb system to the Finance organization by using the FinanceServers activation key.
Use a remote job to query the serverb system uptime.
Use the provided playbook-example-cr.yml Ansible Playbook to create the Custom banner job template.
Execute the job on the serverb system.
Register the serverb system to the Finance organization.
Log in to the serverb system as the student user and switch to the root user.
[student@workstation ~]$ssh student@serverb[student@serverb ~]$sudo -i[sudo] password for student:student[root@serverb ~]#
Install the client certificate package, katello-ca-consumer-latest.noarch.rpm, on the serverb system.
[root@serverb ~]# dnf localinstall \
http://satellite.lab.example.com/pub/katello-ca-consumer-latest.noarch.rpm
...output omitted...Register the serverb system to the Finance organization by using the FinanceServers activation key.
[root@serverb ~]#subscription-manager register --org=Finance \ --activationkey=FinanceServersThe system has been registered with ID:95424d51-69a1-4142-ad18-4453dc96364eThe registered system name is: serverb.lab.example.com Installed Product Current Status: Product Name: Red Hat Enterprise Linux Server Status: Subscribed
Return to the workstation system as the student user.
[root@serverb ~]#exitlogout [student@serverb ~]$exitlogout Connection to serverb closed. [student@workstation ~]$
Distribute the Satellite Server Foreman SSH keys to the serverb content host.
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 ~]#
Copy the Foreman SSH key to the serverb system.
The key is at ~foreman-proxy/.ssh/id_rsa_foreman_proxy.pub.
[root@satellite ~]#ssh-copy-id -i \ ~foreman-proxy/.ssh/id_rsa_foreman_proxy.pub \ root@serverb.lab.example.com...output omitted... Are you sure you want to continue connecting (yes/no)?yes...output omitted... root@servera.lab.example.com's password:redhatNumber of key(s) added: 1 ...output omitted...
Run a remote command on the serverb content host.
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 Finance.
Set the location to Any Location.
Click → , and then click the link.
Click .
Select Commands in the field.
Select Run Command - SSH Default in the field.
Enter uptime in the field.
Click .
Wait for the process to complete.
To view the remote command output, scroll down and click the link. Your results should be similar to the following output.
1: 15:30:22 up 2 days, 1 user, load average: 0.00, 0.00, 0.00 2: Exit status: 0
Use the provided playbook-example-cr.yml Ansible Playbook to create the Custom banner job template.
Click → , and then click .
Enter Custom banner in the field.
Locate the playbook-example-cr.yml Ansible file in the student home directory on the workstation system.
In the window, paste the content of the playbook-example-cr.yml file.
Click .
Remove the existing job category, and select Ansible Playbook from the list.
Select Ansible in the field.
Click .
Remotely execute the Custom banner job template on the serverb content host.
Click → , and then click the link.
Click .
Select Ansible Playbook for the .
Select Custom banner for the field.
Click .
To view the remote command output, scroll down and click the link. View the Ansible Playbook execution output.
Verify that the serverb system banner now contains your custom message.
Log in to the serverb system as the student user.
View the custom banner.
Return to the workstation system as the student user.
[student@workstation ~]$ssh student@serverb"Welcome to the RH403 course,Comprehensive Review chapter"Activate the web console with: systemctl enable --now cockpit.socket Register this system with Red Hat Insights: insights-client --register ...output omitted... [student@serverb ~]$exitlogout [student@workstation ~]$