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
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 Any Organization.
Set the location to Any Location.
Create the Compliance Auditor role by combining the Viewer and Auditor role permissions.
The role needs access to the Finance and Operations organizations.
Click → , and locate the Viewer role.
Click from the list on the Viewer row.
Enter Compliance Auditor as the name.
Select the Finance and Operations organizations, and then click .
On the Roles page, locate the Compliance Auditor role.
Select from the list on the Compliance Auditor row.
Verify that the row that contains the Audit resource and the view_audit_logs permission is marked with a checkmark in the column.
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.
Click → , and then click .
On the tab, enter auditor in the field.
Enter root@satellite.lab.example.com in the field.
Select INTERNAL for the field.
Enter redhat for the password.
Click the tab.
In the list, select the Finance and Operations locations to move to the list.
Click the tab.
In the list, select the Compliance Auditor role to move to the list.
Click .
Log out of the admin user, and then log in as the auditor user with redhat as the password.
Click → .
Click the greater-than symbol (>) to the left of any audit log entry to expand the details.
Verify that you can view the details.
In the upper-left corner of the web page, set the organization to Finance.
Verify that you can still view the audit record details.
In the upper-left corner of the web page, set the organization to Operations.
Verify that you can still view the audit record details.
Count the existing audit records, and then remove audit records that expired more than one day ago.
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 ~]#
Count the audit log entries. Your result would differ from the following example.
[root@satellite ~]# hammer audit list | wc -l
564Remove 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!Verify the current PostgreSQL database size, and then reclaim unused space in the PostgreSQL database.
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]
--------------------------------------------------------------------------------Switch to the postgres user and environment.
[root@satellite ~]# su - postgres
[postgres@satellite ~]$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)
Reclaim unused space in the PostgreSQL database.
[postgres@satellite ~]$ vacuumdb --full --dbname=foreman
vacuumdb: vacuuming database "foreman"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 ~]$exitlogout [root@satellite ~]#
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]
--------------------------------------------------------------------------------Back up the Satellite configuration and database to /var/tmp/backup, excluding Pulp content.
Create the directory for storing the backup files.
[root@satellite ~]# mkdir /var/tmp/backupStart an offline backup without Pulp content.
[root@satellite ~]#satellite-maintain backup offline \ --skip-pulp-content \ /var/tmp/backupStarting 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 ****
Configure the prerequisites for exporting content views, and then export the FinanceServerBase v1.0 content view.
In the Satellite web UI, log out of the auditor user.
Log in 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.
On the tab, click the link.
Select Immediate in the field.
Return to the tab.
Click the link.
Select Immediate in the field.
Return to the tab.
Click the link.
Select Immediate in the field.
Click → , and then click the link. Select → to synchronize all of the repositories in the product. Wait for the process to complete.
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: LibraryExport 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.jsonReturn to the workstation system as the student user.
[root@satellite ~]#exitlogout [student@satellite ~]$exitlogout [student@workstation ~]$