Bookmark this page

Lab: Maintain a Red Hat Satellite Server

Perform maintenance tasks on a Satellite Server.

Outcomes

  • Create a Satellite role and user.

  • Clean up audit records.

  • Reclaim space from PostgreSQL.

  • Back up a Satellite Server.

  • Export a content view to disk.

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

Instructions

  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 Any Organization. Set the location to Any Location.

  3. Create the Compliance Auditor role by combining the Viewer and Auditor role permissions. The role needs access to the Finance and Operations organizations.

    1. Click AdministerRoles, and locate the Viewer role. Click Clone from the Actions list on the Viewer row.

    2. Enter Compliance Auditor as the name. Select the Finance and Operations organizations, and then click Submit.

    3. On the Roles page, locate the Compliance Auditor role. Select Filters from the Actions list on the Compliance Auditor row.

    4. Verify that the row that contains the Audit resource and the view_audit_logs permission is marked with a checkmark in the Unlimited column.

  4. Create the auditor user. Assign the Compliance Auditor role to the user in the Finance and Operations organizations. Verify that the auditor user can access audit records.

    1. Click AdministerUsers, and then click Create User. On the User tab, enter auditor in the Username field. Enter root@satellite.lab.example.com in the Email Address field. Select INTERNAL for the Authorized by field. Enter redhat for the password.

    2. Click the Organizations tab. In the All items list, select the Finance and Operations locations to move to the Selected items list.

    3. Click the Roles tab. In the All items list, select the Compliance Auditor role to move to the Selected items list. Click Submit.

    4. Log out of the admin user, and then log in as the auditor user with redhat as the password. Click MonitorAudits. Click the greater-than symbol (>) to the left of any audit log entry to expand the details. Verify that you can view the details.

    5. In the upper-left corner of the web page, set the organization to Finance. Verify that you can still view the audit record details.

    6. In the upper-left corner of the web page, set the organization to Operations. Verify that you can still view the audit record details.

  5. Count the existing audit records, and then remove audit records that expired more than one day ago.

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

      [student@workstation ~]$ ssh satellite
      [student@satellite ~]$ sudo -i
      [sudo] password for student: student
      [root@satellite ~]#
    2. Count the audit log entries. Your result would differ from the following example.

      [root@satellite ~]# hammer audit list | wc -l
      564
    3. Remove audit records that expired more than one day ago.

      [root@satellite ~]# foreman-rake audits:expire days=1
      Deleting audits older than 2022-08-10 21:39:28 UTC. This might take a few minutes...
      Successfully deleted 216 audits!
  6. Verify the current PostgreSQL database size, and then reclaim unused space in the PostgreSQL database.

    1. Stop all Satellite Server services, except for the postgresql service.

      [root@satellite ~]# satellite-maintain service stop --exclude postgresql
      Running Stop Services
      ================================================================================
      Check if command is run as root user:                                 [OK]
      --------------------------------------------------------------------------------
      Stop applicable services:
      
      Stopping the following service(s):
      ...output omitted...
      \ All services stopped                                                [OK]
      --------------------------------------------------------------------------------
    2. Switch to the postgres user and environment.

      [root@satellite ~]# su - postgres
      [postgres@satellite ~]$
    3. Verify the foreman database size. Your result would differ from the following example.

      [postgres@satellite ~]$ psql -c "SELECT pg_database_size('foreman');"
       pg_database_size
      ------------------
      				79258479
      (1 row)
    4. Reclaim unused space in the PostgreSQL database.

      [postgres@satellite ~]$ vacuumdb --full --dbname=foreman
      vacuumdb: vacuuming database "foreman"
    5. Verify the new database size. Exit the postgres user environment to return to the root user.

      [postgres@satellite ~]$ psql -c "SELECT pg_database_size('foreman');"
       pg_database_size
      ------------------
               63709699
      (1 row)
      [postgres@satellite ~]$ exit
      logout
      [root@satellite ~]#
    6. Start all of the Satellite Server services.

      [root@satellite ~]# satellite-maintain service start
      Running Start Services
      ================================================================================
      Check if command is run as root user:                                 [OK]
      --------------------------------------------------------------------------------
      Start applicable services:
      
      Starting the following service(s):
      ...output omitted...
      - All services started                                                [OK]
      --------------------------------------------------------------------------------
  7. Back up the Satellite configuration and database to /var/tmp/backup, excluding Pulp content.

    1. Create the directory for storing the backup files.

      [root@satellite ~]# mkdir /var/tmp/backup
    2. Start an offline backup without Pulp content.

      [root@satellite ~]# satellite-maintain backup offline \
      --skip-pulp-content \
      /var/tmp/backup
      Starting backup: 2022-08-11 17:55:53 -0400
      Running preparation steps required to run the next scenarios
      ================================================================================
      Make sure Foreman DB is up:
      / Checking connection to the Foreman DB                               [OK]
      --------------------------------------------------------------------------------
      
      
      Running Backup
      ================================================================================
      Confirm turning off services is allowed:
      WARNING: This script will stop your services.
      
      Do you want to proceed?, [y(yes), q(quit)] y
      ...output omitted...
      Done with backup: 2022-08-11 17:58:27 -0400
      **** BACKUP Complete, contents can be found in:
       /var/tmp/backup/satellite-backup-2022-08-11-17-55-53 ****
  8. Configure the prerequisites for exporting content views, and then export the FinanceServerBase v1.0 content view.

    1. In the Satellite web UI, log out of the auditor user. Log in 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 ContentProducts, and then click the Red Hat Enterprise Linux for x86_64 link. On the Repositories tab, click the Red Hat Enterprise Linux 9 for x86_64 - BaseOS RPMs 9 link. Select Immediate in the Download Policy field.

    4. Return to the Repositories tab. Click the Red Hat Enterprise Linux 9 for x86_64 - AppStream RPMs 9 link. Select Immediate in the Download Policy field.

    5. Return to the Repositories tab. Click the Red Hat Satellite Client 6 for RHEL 9 x86_64 RPMs link. Select Immediate in the Download Policy field.

    6. Click ContentProducts, and then click the Red Hat Enterprise Linux for x86_64 link. Select Select ActionSync Now to synchronize all of the repositories in the product. Wait for the process to complete.

    7. List the content views for the Finance organization. Note the ID for the FinanceServerBase 1.0 content view.

      [root@satellite ~]# hammer --output base \
      content-view version list \
      --organization Finance
      Id:                     5
      Name:                   FinanceServerBase 1.0
      Version:                1.0
      Description:            Base Repositories
      Lifecycle Environments:
      
      Id:                     4
      Name:                   Default Organization View 1.0
      Version:                1.0
      Description:
      Lifecycle Environments: Library
    8. Export the FinanceServerBase 1.0 content view by using the version ID obtained in the previous command output.

      [root@satellite ~]# hammer content-export complete version \
      --content-view FinanceServerBase \
      --id 5 \
      --organization Finance
      [....................................................................] [100%]
      Generated
      /var/lib/pulp/exports/Finance/FinanceServerBase/1.0/2023-04-10T15-17-21-04-00/metadata.json
    9. Return to the workstation system as the student user.

      [root@satellite ~]# exit
      logout
      [student@satellite ~]$ exit
      logout
      [student@workstation ~]$

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

Revision: rh403-6.11-3ad886e