Bookmark this page

Lab: Run Remote Execution

Configure a host for remote execution.

Outcomes

  • Configure a host for remote execution.

  • Import an Ansible Role into Satellite and modify the role's default variables.

  • Run a role remotely to install and configure an Apache web server.

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-review

Instructions

  1. Copy the Foreman SSH keys from each Capsule Server to the serverb and serverd content hosts that are the remote execution targets.

    Important

    Satellite Server can delegate any Capsule Server that is authorized to provide remote execution to content hosts in managed locations. Copy the required Foreman SSH public keys from each authorized Capsule Server, including the integrated Capsule Server on the Satellite Server, to each content host that can be a remote execution target.

    1. Log in to the capsule system as the student user and switch to the root user.

      [student@workstation ~]$ ssh student@capsule
      [student@capsule ~]$ sudo -i
      [sudo] password for student: student
      [root@capsule ~]#
    2. Copy the Capsule Server's Foreman SSH public key to the serverb content host.

      [root@capsule ~]# 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@serverb.lab.example.com's password: redhat
      
      Number of key(s) added: 1
      ...output omitted...
    3. Copy the Capsule Server's Foreman SSH public key to the serverd content host.

      [root@capsule ~]# ssh-copy-id \
      -i ~foreman-proxy/.ssh/id_rsa_foreman_proxy.pub \
      root@serverd.lab.example.com
      ...output omitted...
      Are you sure you want to continue connecting (yes/no)? yes
      ...output omitted...
      root@serverd.lab.example.com's password: redhat
      
      Number of key(s) added: 1
      ...output omitted...
    4. Use the foreman-proxy identity to test the root@serverb account for passwordless access from the capsule system. If the public key was successfully copied, then you can access the account without a password prompt. Exit the serverb system to return to the capsule system.

      [root@capsule ~]# ssh -i ~foreman-proxy/.ssh/id_rsa_foreman_proxy root@serverb
      ...output omitted...
      Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
      ...output omitted...
      [root@serverb ~]# exit
      logout
      [root@capsule ~]#
    5. Use the foreman-proxy identity to test the root@serverd account for passwordless access from the capsule system. If the public key was successfully copied, then you can access the account without a password prompt. Exit the serverd system to return to the capsule system.

      [root@capsule ~]# ssh -i ~foreman-proxy/.ssh/id_rsa_foreman_proxy root@serverd
      ...output omitted...
      Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
      ...output omitted...
      [root@serverd ~]# exit
      logout
      [root@capsule ~]#
    6. Return to the workstation system as the student user. Log in to the satellite server as the student user and switch to the root user.

      [root@capsule ~]# exit
      logout
      [student@capsule ~]$ exit
      logout
      [student@workstation ~]$ ssh student@satellite
      [student@satellite ~]$ sudo -i
      [sudo] password for student: student
      [root@satellite ~]#
    7. Copy the Satellite Server's Foreman SSH public key to the serverb content host.

      [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@serverb.lab.example.com's password: redhat
      
      Number of key(s) added: 1
      ...output omitted...
    8. Copy the Satellite Server's Foreman SSH public key to the serverd content host.

      [root@satellite ~]# ssh-copy-id -i \
      ~foreman-proxy/.ssh/id_rsa_foreman_proxy.pub \
      root@serverd.lab.example.com
      ...output omitted...
      Are you sure you want to continue connecting (yes/no)? yes
      ...output omitted...
      root@serverd.lab.example.com's password: redhat
      
      Number of key(s) added: 1
      ...output omitted...
    9. Use the foreman-proxy identity to test the root@serverb account for passwordless access from the satellite system. If the public key was successfully copied, then you can access the account without a password prompt. Exit the serverb system to return to the satellite system.

      [root@satellite ~]# ssh -i ~foreman-proxy/.ssh/id_rsa_foreman_proxy root@serverb
      ...output omitted...
      Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
      ...output omitted...
      [root@serverb ~]# exit
      logout
      [root@satellite ~]#
    10. Use the foreman-proxy identity to test the root@serverd account for passwordless access from the satellite system. If the public key was successfully copied, then you can access the account without a password prompt. Exit the serverd system to return to the satellite system.

      [root@satellite ~]# ssh -i ~foreman-proxy/.ssh/id_rsa_foreman_proxy root@serverd
      ...output omitted...
      Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
      ...output omitted...
      [root@serverd ~]# exit
      logout
      [root@satellite ~]#
  2. Create a custom Ansible Role on the satellite system from the downloaded apache-setup-role.tgz archive. Store the extracted role content in the /etc/ansible/roles directory.

    1. The downloaded role archive is in the root account's home directory on the satellite system. Extract the apache-setup-role.tgz file.

      [root@satellite ~]# tar xzvf apache-setup-role.tgz
      ...output omitted...
    2. Copy the apache-setup-role directory to the /etc/ansible/roles/ directory:

      [root@satellite ~]# cp -R apache-setup-role /etc/ansible/roles/
  3. Import the apache-setup-role Ansible Role into the Finance organization in Satellite.

    1. Log in to the Satellite Server web UI, https://satellite.lab.example.com, as the admin user with redhat as the password.

    2. In the upper-left corner of the web page, set the organization to Finance. Set the location to Any Location.

    3. Click ConfigureRoles, and then click Import from satellite.lab.example.com. Select the checkbox for apache-setup-role from the list of available Ansible Roles. Click Submit.

  4. Set the apache_test_message role variable to Satellite set this variable.

    1. Click ConfigureVariables, and then click the apache_test_message variable.

    2. Select the checkbox for Override. In the Default Value field, enter Satellite set this variable. Click Submit.

  5. Assign the new role to the serverb and serverd content hosts.

    1. Click HostsAll Hosts, and then click the serverb.lab.example.com link.

    2. Click Edit, and then click the Ansible Roles tab. Click the plus sign (+) next to apache-setup-role to move the role to the Assigned Ansible Roles list, and then click Submit.

    3. Click HostsAll Hosts, and then click the serverd.lab.example.com link.

    4. Click Edit, and then click the Ansible Roles tab. Click the plus sign next to apache-setup-role to move the role to the Assigned Ansible Roles list, and then click Submit.

  6. Use the Ansible Role to install and configure a web server on each of the serverb and serverd hosts.

    1. Click HostsAll Hosts. Select the checkbox for the serverb.lab.example.com and serverd.lab.example.com hosts.

    2. Select Run all Ansible roles in the Select Action list.

    3. On the Overview tab, monitor the remote execution status. Wait for the process to complete.

  7. Verify that a functional Apache web server is deployed on each of the serverb and serverd hosts, and that the displayed output includes the apache_test_message text.

    1. Use your browser to navigate to http://serverb.lab.example.com. Verify that the output includes the Satellite set this variable text on the first line.

    2. Use your browser to navigate to http://serverd.lab.example.com. Verify that the output includes the Satellite set this variable text on the first line.

Evaluation

As the student user on the workstation machine, use the lab command to grade your work. Correct any reported failures and rerun the command until successful.

[student@workstation ~]$ lab grade remote-review

Finish

On the workstation machine, change to the student user home directory and use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish remote-review

Revision: rh403-6.11-3ad886e