foreman_maintain 1.11.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/definitions/checks/container/podman_login.rb +30 -0
- data/definitions/checks/iop_advisor/db_up.rb +33 -0
- data/definitions/checks/iop_inventory/db_up.rb +33 -0
- data/definitions/checks/iop_remediations/db_up.rb +33 -0
- data/definitions/checks/iop_vmaas/db_up.rb +33 -0
- data/definitions/checks/iop_vulnerability/db_up.rb +33 -0
- data/definitions/features/containers.rb +8 -0
- data/definitions/features/iop.rb +46 -0
- data/definitions/features/iop_advisor_database.rb +45 -0
- data/definitions/features/iop_inventory_database.rb +45 -0
- data/definitions/features/iop_remediations_database.rb +45 -0
- data/definitions/features/iop_vmaas_database.rb +45 -0
- data/definitions/features/iop_vulnerability_database.rb +45 -0
- data/definitions/procedures/backup/online/iop_advisor_db.rb +20 -0
- data/definitions/procedures/backup/online/iop_inventory_db.rb +20 -0
- data/definitions/procedures/backup/online/iop_remediations_db.rb +21 -0
- data/definitions/procedures/backup/online/iop_vmaas_db.rb +20 -0
- data/definitions/procedures/backup/online/iop_vulnerability_db.rb +21 -0
- data/definitions/procedures/restore/drop_databases.rb +46 -1
- data/definitions/procedures/restore/iop_advisor_dump.rb +27 -0
- data/definitions/procedures/restore/iop_inventory_dump.rb +27 -0
- data/definitions/procedures/restore/iop_remediations_dump.rb +27 -0
- data/definitions/procedures/restore/iop_vmaas_dump.rb +25 -0
- data/definitions/procedures/restore/iop_vulnerability_dump.rb +27 -0
- data/definitions/reports/image_mode_hosts.rb +24 -1
- data/definitions/reports/inventory.rb +12 -0
- data/definitions/scenarios/backup.rb +10 -0
- data/definitions/scenarios/restore.rb +25 -0
- data/definitions/scenarios/satellite_upgrade.rb +1 -0
- data/definitions/scenarios/update.rb +1 -0
- data/lib/foreman_maintain/cli/report_command.rb +112 -10
- data/lib/foreman_maintain/concerns/downstream.rb +5 -0
- data/lib/foreman_maintain/utils/backup.rb +5 -0
- data/lib/foreman_maintain/utils/service/systemd.rb +2 -2
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +25 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfa2280e285e63ea4e7b6269dc6761598c17034fc9febfde0aca731b19a684c3
|
4
|
+
data.tar.gz: b83257b1cefd0ed6e6ad12205442b1817a2b2395b315b08f59a34c8b09833517
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da581d87a81c7b38ab139245323e2ad3f9958fff5094c27b00ef28ff7e519741f18bb909388c660208ce2531ddc14bb39c7873deeacc1502d11185417f4bb321
|
7
|
+
data.tar.gz: 143cd40662be08087e1da5f2cb29c40dbe24bbecd19ea292c6c34394b218606aeb024ddd2757d7fbbbb0edfc5d1220b92dcde0596bd011be6e8ec2cc47274a3c
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Checks::Container
|
2
|
+
class PodmanLogin < ForemanMaintain::Check
|
3
|
+
metadata do
|
4
|
+
for_feature :satellite
|
5
|
+
confine do
|
6
|
+
feature(:satellite)&.connected? && feature(:containers)
|
7
|
+
end
|
8
|
+
description 'Check whether podman is logged in to registry'
|
9
|
+
tags :pre_upgrade
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
login_status, _output = execute_with_status('podman login --get-login registry.redhat.io')
|
14
|
+
assert(
|
15
|
+
login_status == 0,
|
16
|
+
failure_message
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def failure_message
|
23
|
+
<<~MSG
|
24
|
+
You are using containers from registry.redhat.io,
|
25
|
+
but your system is not logged in to the registry, or the login expired.
|
26
|
+
Please login to registry.redhat.io.
|
27
|
+
MSG
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Checks
|
2
|
+
module IopAdvisor
|
3
|
+
class DBUp < ForemanMaintain::Check
|
4
|
+
metadata do
|
5
|
+
description 'Make sure IoP Advisor DB is up'
|
6
|
+
label :iop_advisor_db_up
|
7
|
+
for_feature :iop_advisor
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
status = false
|
12
|
+
if feature(:iop_advisor_database).psql_cmd_available?
|
13
|
+
with_spinner('Checking connection to the IoP Advisor DB') do
|
14
|
+
status = feature(:iop_advisor_database).ping
|
15
|
+
end
|
16
|
+
assert(status, 'IoP Advisor DB is not responding. ' \
|
17
|
+
'It needs to be up and running to perform the following steps',
|
18
|
+
:next_steps => start_pgsql)
|
19
|
+
else
|
20
|
+
feature(:iop_advisor_database).raise_psql_missing_error
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def start_pgsql
|
25
|
+
if feature(:iop_advisor_database).local?
|
26
|
+
[Procedures::Service::Start.new(:only => 'postgresql')]
|
27
|
+
else
|
28
|
+
[] # there is nothing we can do for remote db
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Checks
|
2
|
+
module IopInventory
|
3
|
+
class DBUp < ForemanMaintain::Check
|
4
|
+
metadata do
|
5
|
+
description 'Make sure IoP Inventory DB is up'
|
6
|
+
label :iop_inventory_db_up
|
7
|
+
for_feature :iop_inventory
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
status = false
|
12
|
+
if feature(:iop_inventory_database).psql_cmd_available?
|
13
|
+
with_spinner('Checking connection to the IoP Inventory DB') do
|
14
|
+
status = feature(:iop_inventory_database).ping
|
15
|
+
end
|
16
|
+
assert(status, 'IoP Inventory DB is not responding. ' \
|
17
|
+
'It needs to be up and running to perform the following steps',
|
18
|
+
:next_steps => start_pgsql)
|
19
|
+
else
|
20
|
+
feature(:iop_inventory_database).raise_psql_missing_error
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def start_pgsql
|
25
|
+
if feature(:iop_inventory_database).local?
|
26
|
+
[Procedures::Service::Start.new(:only => 'postgresql')]
|
27
|
+
else
|
28
|
+
[] # there is nothing we can do for remote db
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Checks
|
2
|
+
module IopRemediations
|
3
|
+
class DBUp < ForemanMaintain::Check
|
4
|
+
metadata do
|
5
|
+
description 'Make sure IoP Remediations DB is up'
|
6
|
+
label :iop_remediations_db_up
|
7
|
+
for_feature :iop_remediations
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
status = false
|
12
|
+
if feature(:iop_remediations_database).psql_cmd_available?
|
13
|
+
with_spinner('Checking connection to the IoP Remediations DB') do
|
14
|
+
status = feature(:iop_remediations_database).ping
|
15
|
+
end
|
16
|
+
assert(status, 'IoP Remediations DB is not responding. ' \
|
17
|
+
'It needs to be up and running to perform the following steps',
|
18
|
+
:next_steps => start_pgsql)
|
19
|
+
else
|
20
|
+
feature(:iop_remediations_database).raise_psql_missing_error
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def start_pgsql
|
25
|
+
if feature(:iop_remediations_database).local?
|
26
|
+
[Procedures::Service::Start.new(:only => 'postgresql')]
|
27
|
+
else
|
28
|
+
[] # there is nothing we can do for remote db
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Checks
|
2
|
+
module IopVmaas
|
3
|
+
class DBUp < ForemanMaintain::Check
|
4
|
+
metadata do
|
5
|
+
description 'Make sure IoP Vmaas DB is up'
|
6
|
+
label :iop_vmaas_db_up
|
7
|
+
for_feature :iop_vmaas
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
status = false
|
12
|
+
if feature(:iop_vmaas_database).psql_cmd_available?
|
13
|
+
with_spinner('Checking connection to the IoP Vmaas DB') do
|
14
|
+
status = feature(:iop_vmaas_database).ping
|
15
|
+
end
|
16
|
+
assert(status, 'IoP Vmaas DB is not responding. ' \
|
17
|
+
'It needs to be up and running to perform the following steps',
|
18
|
+
:next_steps => start_pgsql)
|
19
|
+
else
|
20
|
+
feature(:iop_vmaas_database).raise_psql_missing_error
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def start_pgsql
|
25
|
+
if feature(:iop_vmaas_database).local?
|
26
|
+
[Procedures::Service::Start.new(:only => 'postgresql')]
|
27
|
+
else
|
28
|
+
[] # there is nothing we can do for remote db
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Checks
|
2
|
+
module IopVulnerability
|
3
|
+
class DBUp < ForemanMaintain::Check
|
4
|
+
metadata do
|
5
|
+
description 'Make sure IoP Vulnerability DB is up'
|
6
|
+
label :iop_vulnerability_db_up
|
7
|
+
for_feature :iop_vulnerability
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
status = false
|
12
|
+
if feature(:iop_vulnerability_database).psql_cmd_available?
|
13
|
+
with_spinner('Checking connection to the IoP Vulnerability DB') do
|
14
|
+
status = feature(:iop_vulnerability_database).ping
|
15
|
+
end
|
16
|
+
assert(status, 'IoP Vulnerability DB is not responding. ' \
|
17
|
+
'It needs to be up and running to perform the following steps',
|
18
|
+
:next_steps => start_pgsql)
|
19
|
+
else
|
20
|
+
feature(:iop_vulnerability_database).raise_psql_missing_error
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def start_pgsql
|
25
|
+
if feature(:iop_vulnerability_database).local?
|
26
|
+
[Procedures::Service::Start.new(:only => 'postgresql')]
|
27
|
+
else
|
28
|
+
[] # there is nothing we can do for remote db
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class Features::Iop < ForemanMaintain::Feature
|
2
|
+
metadata do
|
3
|
+
label :iop
|
4
|
+
|
5
|
+
confine do
|
6
|
+
File.exist?('/etc/containers/networks/iop-core-network.json') ||
|
7
|
+
File.exist?('/etc/containers/systemd/iop-core.network')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def config_files
|
12
|
+
[
|
13
|
+
'/var/lib/kafka',
|
14
|
+
'/var/lib/vmaas',
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
18
|
+
# rubocop:disable Metrics/MethodLength
|
19
|
+
def services
|
20
|
+
[
|
21
|
+
system_service('iop-core-engine', 20),
|
22
|
+
system_service('iop-core-gateway', 20),
|
23
|
+
system_service('iop-core-host-inventory', 20),
|
24
|
+
system_service('iop-core-host-inventory-api', 20),
|
25
|
+
system_service('iop-core-host-inventory-migrate', 20),
|
26
|
+
system_service('iop-core-ingress', 20),
|
27
|
+
system_service('iop-core-kafka', 20),
|
28
|
+
system_service('iop-core-puptoo', 20),
|
29
|
+
system_service('iop-core-yuptoo', 20),
|
30
|
+
system_service('iop-service-advisor-backend-api', 20),
|
31
|
+
system_service('iop-service-advisor-backend-service', 20),
|
32
|
+
system_service('iop-service-remediations-api', 20),
|
33
|
+
system_service('iop-service-vmaas-reposcan', 20),
|
34
|
+
system_service('iop-service-vmaas-webapp-go', 20),
|
35
|
+
system_service('iop-service-vuln-dbupgrade', 20),
|
36
|
+
system_service('iop-service-vuln-evaluator-recalc', 20),
|
37
|
+
system_service('iop-service-vuln-evaluator-upload', 20),
|
38
|
+
system_service('iop-service-vuln-grouper', 20),
|
39
|
+
system_service('iop-service-vuln-listener', 20),
|
40
|
+
system_service('iop-service-vuln-manager', 20),
|
41
|
+
system_service('iop-service-vuln-taskomatic', 20),
|
42
|
+
system_service('iop-service-vuln-vmaas-sync', 20),
|
43
|
+
]
|
44
|
+
end
|
45
|
+
# rubocop:enable Metrics/MethodLength
|
46
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class Features::IopAdvisorDatabase < ForemanMaintain::Feature
|
2
|
+
include ForemanMaintain::Concerns::BaseDatabase
|
3
|
+
|
4
|
+
metadata do
|
5
|
+
label :iop_advisor_database
|
6
|
+
|
7
|
+
confine do
|
8
|
+
File.exist?('/etc/containers/networks/iop-core-network.json') ||
|
9
|
+
File.exist?('/etc/containers/systemd/iop-core.network')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def configuration
|
14
|
+
@configuration || load_configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
def services
|
18
|
+
[
|
19
|
+
system_service('postgresql', 10, :component => 'iop',
|
20
|
+
:db_feature => feature(:iop_advisor_database)),
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def load_configuration
|
27
|
+
podman_command = "podman exec iop-service-advisor-api bash -c 'env |grep DB_'"
|
28
|
+
podman_result = execute!(podman_command, merge_stderr: false).lines.map do |l|
|
29
|
+
l.strip.split('=')
|
30
|
+
end.to_h
|
31
|
+
|
32
|
+
db_host = if podman_result['ADVISOR_DB_HOST'].start_with?('/var/run/postgresql')
|
33
|
+
'localhost'
|
34
|
+
else
|
35
|
+
podman_result['ADVISOR_DB_HOST']
|
36
|
+
end
|
37
|
+
@configuration = {
|
38
|
+
'host' => db_host,
|
39
|
+
'port' => podman_result['ADVISOR_DB_PORT'],
|
40
|
+
'database' => podman_result['ADVISOR_DB_NAME'],
|
41
|
+
'password' => podman_result['ADVISOR_DB_PASSWORD'],
|
42
|
+
'username' => podman_result['ADVISOR_DB_USER'],
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class Features::IopInventoryDatabase < ForemanMaintain::Feature
|
2
|
+
include ForemanMaintain::Concerns::BaseDatabase
|
3
|
+
|
4
|
+
metadata do
|
5
|
+
label :iop_inventory_database
|
6
|
+
|
7
|
+
confine do
|
8
|
+
File.exist?('/etc/containers/networks/iop-core-network.json') ||
|
9
|
+
File.exist?('/etc/containers/systemd/iop-core.network')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def configuration
|
14
|
+
@configuration || load_configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
def services
|
18
|
+
[
|
19
|
+
system_service('postgresql', 10, :component => 'iop',
|
20
|
+
:db_feature => feature(:iop_inventory_database)),
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def load_configuration
|
27
|
+
podman_command = "podman exec iop-core-host-inventory bash -c 'env |grep INVENTORY_DB_'"
|
28
|
+
podman_result = execute!(podman_command, merge_stderr: false).lines.map do |l|
|
29
|
+
l.strip.split('=')
|
30
|
+
end.to_h
|
31
|
+
|
32
|
+
db_host = if podman_result['INVENTORY_DB_HOST'].start_with?('/var/run/postgresql')
|
33
|
+
'localhost'
|
34
|
+
else
|
35
|
+
podman_result['INVENTORY_DB_HOST']
|
36
|
+
end
|
37
|
+
@configuration = {
|
38
|
+
'host' => db_host,
|
39
|
+
'port' => podman_result['INVENTORY_DB_PORT'],
|
40
|
+
'database' => podman_result['INVENTORY_DB_NAME'],
|
41
|
+
'password' => podman_result['INVENTORY_DB_PASS'],
|
42
|
+
'username' => podman_result['INVENTORY_DB_USER'],
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class Features::IopRemediationsDatabase < ForemanMaintain::Feature
|
2
|
+
include ForemanMaintain::Concerns::BaseDatabase
|
3
|
+
|
4
|
+
metadata do
|
5
|
+
label :iop_remediations_database
|
6
|
+
|
7
|
+
confine do
|
8
|
+
File.exist?('/etc/containers/networks/iop-core-network.json') ||
|
9
|
+
File.exist?('/etc/containers/systemd/iop-core.network')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def configuration
|
14
|
+
@configuration || load_configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
def services
|
18
|
+
[
|
19
|
+
system_service('postgresql', 10, :component => 'iop',
|
20
|
+
:db_feature => feature(:iop_remediations_database)),
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def load_configuration
|
27
|
+
podman_command = "podman exec iop-service-remediations-api bash -c 'env |grep DB_'"
|
28
|
+
podman_result = execute!(podman_command, merge_stderr: false).lines.map do |l|
|
29
|
+
l.strip.split('=')
|
30
|
+
end.to_h
|
31
|
+
|
32
|
+
db_host = if podman_result['DB_HOST'].start_with?('/var/run/postgresql')
|
33
|
+
'localhost'
|
34
|
+
else
|
35
|
+
podman_result['DB_HOST']
|
36
|
+
end
|
37
|
+
@configuration = {
|
38
|
+
'host' => db_host,
|
39
|
+
'port' => podman_result['DB_PORT'],
|
40
|
+
'database' => podman_result['DB_DATABASE'],
|
41
|
+
'password' => podman_result['DB_PASSWORD'],
|
42
|
+
'username' => podman_result['DB_USERNAME'],
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class Features::IopVmaasDatabase < ForemanMaintain::Feature
|
2
|
+
include ForemanMaintain::Concerns::BaseDatabase
|
3
|
+
|
4
|
+
metadata do
|
5
|
+
label :iop_vmaas_database
|
6
|
+
|
7
|
+
confine do
|
8
|
+
File.exist?('/etc/containers/networks/iop-core-network.json') ||
|
9
|
+
File.exist?('/etc/containers/systemd/iop-core.network')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def configuration
|
14
|
+
@configuration || load_configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
def services
|
18
|
+
[
|
19
|
+
system_service('postgresql', 10, :component => 'iop',
|
20
|
+
:db_feature => feature(:iop_vmaas_database)),
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def load_configuration
|
27
|
+
podman_command = "podman exec iop-service-vmaas-reposcan bash -c 'env |grep POSTGRESQL_'"
|
28
|
+
podman_result = execute!(podman_command, merge_stderr: false).lines.map do |l|
|
29
|
+
l.strip.split('=')
|
30
|
+
end.to_h
|
31
|
+
|
32
|
+
db_host = if podman_result['POSTGRESQL_HOST'].start_with?('/var/run/postgresql')
|
33
|
+
'localhost'
|
34
|
+
else
|
35
|
+
podman_result['POSTGRESQL_HOST']
|
36
|
+
end
|
37
|
+
@configuration = {
|
38
|
+
'host' => db_host,
|
39
|
+
'port' => podman_result['POSTGRESQL_PORT'],
|
40
|
+
'database' => podman_result['POSTGRESQL_DATABASE'],
|
41
|
+
'password' => podman_result['POSTGRESQL_PASSWORD'],
|
42
|
+
'username' => podman_result['POSTGRESQL_USER'],
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class Features::IopVulnerabilityDatabase < ForemanMaintain::Feature
|
2
|
+
include ForemanMaintain::Concerns::BaseDatabase
|
3
|
+
|
4
|
+
metadata do
|
5
|
+
label :iop_vulnerability_database
|
6
|
+
|
7
|
+
confine do
|
8
|
+
File.exist?('/etc/containers/networks/iop-core-network.json') ||
|
9
|
+
File.exist?('/etc/containers/systemd/iop-core.network')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def configuration
|
14
|
+
@configuration || load_configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
def services
|
18
|
+
[
|
19
|
+
system_service('postgresql', 10, :component => 'iop',
|
20
|
+
:db_feature => feature(:iop_vulnerability_database)),
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def load_configuration
|
27
|
+
podman_command = "podman exec iop-service-vuln-manager bash -c 'env |grep POSTGRES_'"
|
28
|
+
podman_result = execute!(podman_command, merge_stderr: false).lines.map do |l|
|
29
|
+
l.strip.split('=')
|
30
|
+
end.to_h
|
31
|
+
|
32
|
+
db_host = if podman_result['POSTGRES_HOST'].start_with?('/var/run/postgresql')
|
33
|
+
'localhost'
|
34
|
+
else
|
35
|
+
podman_result['POSTGRES_HOST']
|
36
|
+
end
|
37
|
+
@configuration = {
|
38
|
+
'host' => db_host,
|
39
|
+
'port' => podman_result['POSTGRES_PORT'],
|
40
|
+
'database' => podman_result['POSTGRES_DB'],
|
41
|
+
'password' => podman_result['POSTGRES_PASSWORD'],
|
42
|
+
'username' => podman_result['POSTGRES_USER'],
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Procedures::Backup
|
2
|
+
module Online
|
3
|
+
class IopAdvisorDB < ForemanMaintain::Procedure
|
4
|
+
metadata do
|
5
|
+
description 'Backup IoP Advisor database'
|
6
|
+
tags :backup
|
7
|
+
label :backup_online_iop_advisor_db
|
8
|
+
for_feature :iop_advisor_database
|
9
|
+
preparation_steps { Checks::IopAdvisor::DBUp.new }
|
10
|
+
param :backup_dir, 'Directory where to backup to', :required => true
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
with_spinner('Getting IoP Advisor DB dump') do
|
15
|
+
feature(:iop_advisor_database).dump_db(File.join(@backup_dir, 'iop_advisor.dump'))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Procedures::Backup
|
2
|
+
module Online
|
3
|
+
class IopInventoryDB < ForemanMaintain::Procedure
|
4
|
+
metadata do
|
5
|
+
description 'Backup IoP Inventory database'
|
6
|
+
tags :backup
|
7
|
+
label :backup_online_iop_inventory_db
|
8
|
+
for_feature :iop_inventory_database
|
9
|
+
preparation_steps { Checks::IopInventory::DBUp.new }
|
10
|
+
param :backup_dir, 'Directory where to backup to', :required => true
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
with_spinner('Getting IoP Inventory DB dump') do
|
15
|
+
feature(:iop_inventory_database).dump_db(File.join(@backup_dir, 'iop_inventory.dump'))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Procedures::Backup
|
2
|
+
module Online
|
3
|
+
class IopRemediationsDB < ForemanMaintain::Procedure
|
4
|
+
metadata do
|
5
|
+
description 'Backup IoP Remediations database'
|
6
|
+
tags :backup
|
7
|
+
label :backup_online_iop_remediations_db
|
8
|
+
for_feature :iop_remediations_database
|
9
|
+
preparation_steps { Checks::IopRemediations::DBUp.new }
|
10
|
+
param :backup_dir, 'Directory where to backup to', :required => true
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
with_spinner('Getting IoP Remediations DB dump') do
|
15
|
+
feature(:iop_remediations_database).dump_db(File.join(@backup_dir,
|
16
|
+
'iop_remediations.dump'))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Procedures::Backup
|
2
|
+
module Online
|
3
|
+
class IopVmaasDB < ForemanMaintain::Procedure
|
4
|
+
metadata do
|
5
|
+
description 'Backup IoP Vmaas database'
|
6
|
+
tags :backup
|
7
|
+
label :backup_online_iop_vmaas_db
|
8
|
+
for_feature :iop_vmaas_database
|
9
|
+
preparation_steps { Checks::IopVmaas::DBUp.new }
|
10
|
+
param :backup_dir, 'Directory where to backup to', :required => true
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
with_spinner('Getting IoP Vmaas DB dump') do
|
15
|
+
feature(:iop_vmaas_database).dump_db(File.join(@backup_dir, 'iop_vmaas.dump'))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Procedures::Backup
|
2
|
+
module Online
|
3
|
+
class IopVulnerabilityDB < ForemanMaintain::Procedure
|
4
|
+
metadata do
|
5
|
+
description 'Backup IoP Vulnerability database'
|
6
|
+
tags :backup
|
7
|
+
label :backup_online_iop_vulnerability_db
|
8
|
+
for_feature :iop_vulnerability_database
|
9
|
+
preparation_steps { Checks::IopVulnerability::DBUp.new }
|
10
|
+
param :backup_dir, 'Directory where to backup to', :required => true
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
with_spinner('Getting IoP Vulnerability DB dump') do
|
15
|
+
feature(:iop_vulnerability_database).dump_db(File.join(@backup_dir,
|
16
|
+
'iop_vulnerability.dump'))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -8,7 +8,12 @@ module Procedures::Restore
|
|
8
8
|
:required => true
|
9
9
|
|
10
10
|
confine do
|
11
|
-
feature(:foreman_database) || feature(:candlepin_database) || feature(:pulpcore_database)
|
11
|
+
feature(:foreman_database) || feature(:candlepin_database) || feature(:pulpcore_database) ||
|
12
|
+
feature(:iop_advisor_database) ||
|
13
|
+
feature(:iop_inventory_database) ||
|
14
|
+
feature(:iop_remediations_database) ||
|
15
|
+
feature(:iop_vmaas_database) ||
|
16
|
+
feature(:iop_vulnerability_database)
|
12
17
|
end
|
13
18
|
end
|
14
19
|
|
@@ -20,6 +25,11 @@ module Procedures::Restore
|
|
20
25
|
drop_foreman(backup, spinner)
|
21
26
|
drop_candlepin(backup, spinner)
|
22
27
|
drop_pulpcore(backup, spinner)
|
28
|
+
drop_iop_advisor(backup, spinner)
|
29
|
+
drop_iop_inventory(backup, spinner)
|
30
|
+
drop_iop_remediations(backup, spinner)
|
31
|
+
drop_iop_vmaas(backup, spinner)
|
32
|
+
drop_iop_vulnerability(backup, spinner)
|
23
33
|
end
|
24
34
|
end
|
25
35
|
|
@@ -43,5 +53,40 @@ module Procedures::Restore
|
|
43
53
|
feature(:pulpcore_database).dropdb
|
44
54
|
end
|
45
55
|
end
|
56
|
+
|
57
|
+
def drop_iop_advisor(backup, spinner)
|
58
|
+
if backup.file_map[:iop_advisor_dump][:present]
|
59
|
+
spinner.update('Dropping iop_advisor database')
|
60
|
+
feature(:iop_advisor_database).dropdb
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def drop_iop_inventory(backup, spinner)
|
65
|
+
if backup.file_map[:iop_inventory_dump][:present]
|
66
|
+
spinner.update('Dropping iop_inventory database')
|
67
|
+
feature(:iop_inventory_database).dropdb
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def drop_iop_remediations(backup, spinner)
|
72
|
+
if backup.file_map[:iop_remediations_dump][:present]
|
73
|
+
spinner.update('Dropping iop_remediations database')
|
74
|
+
feature(:iop_remediations_database).dropdb
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def drop_iop_vmaas(backup, spinner)
|
79
|
+
if backup.file_map[:iop_vmaas_dump][:present]
|
80
|
+
spinner.update('Dropping iop_vmaas database')
|
81
|
+
feature(:iop_vmaas_database).dropdb
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def drop_iop_vulnerability(backup, spinner)
|
86
|
+
if backup.file_map[:iop_vulnerability_dump][:present]
|
87
|
+
spinner.update('Dropping iop_vulnerability database')
|
88
|
+
feature(:iop_vulnerability_database).dropdb
|
89
|
+
end
|
90
|
+
end
|
46
91
|
end
|
47
92
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Procedures::Restore
|
2
|
+
class IopAdvisorDump < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
description 'Restore IoP Advisor dump from backup'
|
5
|
+
param :backup_dir,
|
6
|
+
'Path to backup directory',
|
7
|
+
:required => true
|
8
|
+
preparation_steps { Checks::IopAdvisor::DBUp.new }
|
9
|
+
confine do
|
10
|
+
feature(:iop_advisor_database)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
backup = ForemanMaintain::Utils::Backup.new(@backup_dir)
|
16
|
+
|
17
|
+
with_spinner('Restoring IoP Advisor dump') do |_spinner|
|
18
|
+
if backup.file_map[:candlepin_dump][:present]
|
19
|
+
local = feature(:iop_advisor_database).local?
|
20
|
+
feature(:iop_advisor_database).restore_dump(
|
21
|
+
backup.file_map[:iop_advisor_dump][:path], local
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Procedures::Restore
|
2
|
+
class IopInventoryDump < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
description 'Restore IoP Inventory dump from backup'
|
5
|
+
param :backup_dir,
|
6
|
+
'Path to backup directory',
|
7
|
+
:required => true
|
8
|
+
preparation_steps { Checks::IopInventory::DBUp.new }
|
9
|
+
confine do
|
10
|
+
feature(:iop_inventory_database)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
backup = ForemanMaintain::Utils::Backup.new(@backup_dir)
|
16
|
+
|
17
|
+
with_spinner('Restoring IoP Inventory dump') do |_spinner|
|
18
|
+
if backup.file_map[:candlepin_dump][:present]
|
19
|
+
local = feature(:iop_inventory_database).local?
|
20
|
+
feature(:iop_inventory_database).restore_dump(
|
21
|
+
backup.file_map[:iop_inventory_dump][:path], local
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Procedures::Restore
|
2
|
+
class IopRemediationsDump < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
description 'Restore IoP Remediations dump from backup'
|
5
|
+
param :backup_dir,
|
6
|
+
'Path to backup directory',
|
7
|
+
:required => true
|
8
|
+
preparation_steps { Checks::IopRemediations::DBUp.new }
|
9
|
+
confine do
|
10
|
+
feature(:iop_remediations_database)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
backup = ForemanMaintain::Utils::Backup.new(@backup_dir)
|
16
|
+
|
17
|
+
with_spinner('Restoring IoP Remediations dump') do |_spinner|
|
18
|
+
if backup.file_map[:candlepin_dump][:present]
|
19
|
+
local = feature(:iop_remediations_database).local?
|
20
|
+
feature(:iop_remediations_database).restore_dump(
|
21
|
+
backup.file_map[:iop_remediations_dump][:path], local
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Procedures::Restore
|
2
|
+
class IopVmaasDump < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
description 'Restore IoP Vmaas dump from backup'
|
5
|
+
param :backup_dir,
|
6
|
+
'Path to backup directory',
|
7
|
+
:required => true
|
8
|
+
preparation_steps { Checks::IopVmaas::DBUp.new }
|
9
|
+
confine do
|
10
|
+
feature(:iop_vmaas_database)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
backup = ForemanMaintain::Utils::Backup.new(@backup_dir)
|
16
|
+
|
17
|
+
with_spinner('Restoring IoP Vmaas dump') do |_spinner|
|
18
|
+
if backup.file_map[:candlepin_dump][:present]
|
19
|
+
local = feature(:iop_vmaas_database).local?
|
20
|
+
feature(:iop_vmaas_database).restore_dump(backup.file_map[:iop_vmaas_dump][:path], local)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Procedures::Restore
|
2
|
+
class IopVulnerabilityDump < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
description 'Restore IoP Vulnerability dump from backup'
|
5
|
+
param :backup_dir,
|
6
|
+
'Path to backup directory',
|
7
|
+
:required => true
|
8
|
+
preparation_steps { Checks::IopVulnerability::DBUp.new }
|
9
|
+
confine do
|
10
|
+
feature(:iop_vulnerability_database)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
backup = ForemanMaintain::Utils::Backup.new(@backup_dir)
|
16
|
+
|
17
|
+
with_spinner('Restoring IoP Vulnerability dump') do |_spinner|
|
18
|
+
if backup.file_map[:candlepin_dump][:present]
|
19
|
+
local = feature(:iop_vulnerability_database).local?
|
20
|
+
feature(:iop_vulnerability_database).restore_dump(
|
21
|
+
backup.file_map[:iop_vulnerability_dump][:path], local
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Reports
|
2
2
|
class ImageModeHosts < ForemanMaintain::Report
|
3
3
|
metadata do
|
4
|
-
description 'Report
|
4
|
+
description 'Report metrics related to use of image mode'
|
5
5
|
confine do
|
6
6
|
feature(:katello)
|
7
7
|
end
|
@@ -9,6 +9,7 @@ module Reports
|
|
9
9
|
|
10
10
|
def run
|
11
11
|
merge_data('image_mode_hosts_by_os_count') { image_mode_hosts_by_os_count }
|
12
|
+
data['remote_execution_transient_package_actions_count'] = transient_actions_count
|
12
13
|
end
|
13
14
|
|
14
15
|
# OS usage on image mode hosts
|
@@ -23,5 +24,27 @@ module Reports
|
|
23
24
|
).
|
24
25
|
to_h { |row| [row['os_name'], row['hosts_count'].to_i] }
|
25
26
|
end
|
27
|
+
|
28
|
+
def transient_actions_count
|
29
|
+
cte = <<~CTE
|
30
|
+
WITH bootc_hosts AS (
|
31
|
+
SELECT hosts.id FROM hosts
|
32
|
+
INNER JOIN katello_content_facets AS kcf ON hosts.id = kcf.host_id
|
33
|
+
WHERE kcf.bootc_booted_digest IS NOT NULL
|
34
|
+
)
|
35
|
+
CTE
|
36
|
+
|
37
|
+
sql = <<~SQL
|
38
|
+
job_invocations AS ji
|
39
|
+
INNER JOIN remote_execution_features AS ref ON ji.remote_execution_feature_id = ref.id
|
40
|
+
INNER JOIN template_invocations AS ti ON ji.id = ti.job_invocation_id
|
41
|
+
INNER JOIN bootc_hosts ON bootc_hosts.id = ti.host_id
|
42
|
+
WHERE ref.label LIKE 'katello_package%'
|
43
|
+
OR ref.label LIKE 'katello_errata%'
|
44
|
+
OR ref.label LIKE 'katello_group%'
|
45
|
+
SQL
|
46
|
+
|
47
|
+
sql_count(sql, cte: cte)
|
48
|
+
end
|
26
49
|
end
|
27
50
|
end
|
@@ -7,6 +7,7 @@ module Reports
|
|
7
7
|
def run
|
8
8
|
merge_data('hosts_by_type_count') { hosts_by_type_count }
|
9
9
|
merge_data('hosts_by_os_count') { hosts_by_os_count }
|
10
|
+
merge_data('hosts_by_family_count') { hosts_by_family_count }
|
10
11
|
merge_data('facts_by_type') { facts_by_type }
|
11
12
|
merge_data('audits') { audits }
|
12
13
|
merge_data('parameters_count') { parameters }
|
@@ -31,6 +32,17 @@ module Reports
|
|
31
32
|
to_h { |row| [row['os_name'], row['hosts_count'].to_i] }
|
32
33
|
end
|
33
34
|
|
35
|
+
def hosts_by_family_count
|
36
|
+
query(
|
37
|
+
<<-SQL
|
38
|
+
select max(operatingsystems.type) as os_family, count(*) as hosts_count
|
39
|
+
from hosts inner join operatingsystems on operatingsystem_id = operatingsystems.id
|
40
|
+
group by operatingsystems.type
|
41
|
+
SQL
|
42
|
+
).
|
43
|
+
to_h { |row| [row['os_family'], row['hosts_count'].to_i] }
|
44
|
+
end
|
45
|
+
|
34
46
|
# Facts usage
|
35
47
|
def facts_by_type
|
36
48
|
query(
|
@@ -46,6 +46,11 @@ module ForemanMaintain::Scenarios
|
|
46
46
|
Procedures::Backup::Pulp => :backup_dir,
|
47
47
|
Procedures::Backup::Online::CandlepinDB => :backup_dir,
|
48
48
|
Procedures::Backup::Online::ForemanDB => :backup_dir,
|
49
|
+
Procedures::Backup::Online::IopAdvisorDB => :backup_dir,
|
50
|
+
Procedures::Backup::Online::IopInventoryDB => :backup_dir,
|
51
|
+
Procedures::Backup::Online::IopRemediationsDB => :backup_dir,
|
52
|
+
Procedures::Backup::Online::IopVmaasDB => :backup_dir,
|
53
|
+
Procedures::Backup::Online::IopVulnerabilityDB => :backup_dir,
|
49
54
|
Procedures::Backup::Online::PulpcoreDB => :backup_dir)
|
50
55
|
context.map(:preserve_dir,
|
51
56
|
Procedures::Backup::PrepareDirectory => :preserve_dir)
|
@@ -102,6 +107,11 @@ module ForemanMaintain::Scenarios
|
|
102
107
|
add_steps_with_context(
|
103
108
|
Procedures::Backup::Online::CandlepinDB,
|
104
109
|
Procedures::Backup::Online::ForemanDB,
|
110
|
+
Procedures::Backup::Online::IopAdvisorDB,
|
111
|
+
Procedures::Backup::Online::IopInventoryDB,
|
112
|
+
Procedures::Backup::Online::IopRemediationsDB,
|
113
|
+
Procedures::Backup::Online::IopVmaasDB,
|
114
|
+
Procedures::Backup::Online::IopVulnerabilityDB,
|
105
115
|
Procedures::Backup::Online::PulpcoreDB
|
106
116
|
)
|
107
117
|
end
|
@@ -52,6 +52,7 @@ module ForemanMaintain::Scenarios
|
|
52
52
|
end
|
53
53
|
# rubocop:enable Metrics/MethodLength,Metrics/AbcSize
|
54
54
|
|
55
|
+
# rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity
|
55
56
|
def restore_sql_dumps(backup)
|
56
57
|
if feature(:instance).postgresql_local?
|
57
58
|
add_step(Procedures::Service::Start.new(:only => ['postgresql']))
|
@@ -62,6 +63,24 @@ module ForemanMaintain::Scenarios
|
|
62
63
|
if backup.file_map[:foreman_dump][:present]
|
63
64
|
add_steps_with_context(Procedures::Restore::ForemanDump)
|
64
65
|
end
|
66
|
+
if backup.file_map[:iop_advisor_dump][:present]
|
67
|
+
add_steps_with_context(Procedures::Restore::IopAdvisorDump)
|
68
|
+
end
|
69
|
+
if backup.file_map[:iop_inventory_dump][:present]
|
70
|
+
add_steps_with_context(Procedures::Restore::IopInventoryDump)
|
71
|
+
end
|
72
|
+
if backup.file_map[:iop_remediations_dump][:present]
|
73
|
+
add_steps_with_context(Procedures::Restore::IopRemediationsDump)
|
74
|
+
end
|
75
|
+
if backup.file_map[:iop_advisor_dump][:present]
|
76
|
+
add_steps_with_context(Procedures::Restore::IopAdvisorDump)
|
77
|
+
end
|
78
|
+
if backup.file_map[:iop_vmaas_dump][:present]
|
79
|
+
add_steps_with_context(Procedures::Restore::IopVmaasDump)
|
80
|
+
end
|
81
|
+
if backup.file_map[:iop_vulnerability_dump][:present]
|
82
|
+
add_steps_with_context(Procedures::Restore::IopVulnerabilityDump)
|
83
|
+
end
|
65
84
|
if backup.file_map[:pulpcore_dump][:present]
|
66
85
|
add_steps_with_context(Procedures::Restore::PulpcoreDump)
|
67
86
|
end
|
@@ -69,6 +88,7 @@ module ForemanMaintain::Scenarios
|
|
69
88
|
add_step(Procedures::Service::Stop.new(:only => ['postgresql']))
|
70
89
|
end
|
71
90
|
end
|
91
|
+
# rubocop:enable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity
|
72
92
|
|
73
93
|
def set_context_mapping
|
74
94
|
context.map(:backup_dir,
|
@@ -81,6 +101,11 @@ module ForemanMaintain::Scenarios
|
|
81
101
|
Procedures::Restore::DropDatabases => :backup_dir,
|
82
102
|
Procedures::Restore::CandlepinDump => :backup_dir,
|
83
103
|
Procedures::Restore::ForemanDump => :backup_dir,
|
104
|
+
Procedures::Restore::IopAdvisorDump => :backup_dir,
|
105
|
+
Procedures::Restore::IopInventoryDump => :backup_dir,
|
106
|
+
Procedures::Restore::IopRemediationsDump => :backup_dir,
|
107
|
+
Procedures::Restore::IopVmaasDump => :backup_dir,
|
108
|
+
Procedures::Restore::IopVulnerabilityDump => :backup_dir,
|
84
109
|
Procedures::Restore::PulpcoreDump => :backup_dir,
|
85
110
|
Procedures::Restore::ExtractFiles => :backup_dir)
|
86
111
|
end
|
@@ -36,6 +36,7 @@ module Scenarios::Satellite
|
|
36
36
|
Checks::CheckHotfixInstalled,
|
37
37
|
Checks::CheckTmout,
|
38
38
|
Checks::CheckUpstreamRepository,
|
39
|
+
Checks::Container::PodmanLogin, # if downstream, connected, containers used
|
39
40
|
Checks::Disk::AvailableSpace,
|
40
41
|
Checks::Disk::AvailableSpaceCandlepin, # if candlepin
|
41
42
|
Checks::Disk::PostgresqlMountpoint,
|
@@ -35,6 +35,7 @@ module Scenarios::Update
|
|
35
35
|
Checks::CheckTmout,
|
36
36
|
Checks::CheckIpv6Disable,
|
37
37
|
Checks::CheckUpstreamRepository,
|
38
|
+
Checks::Container::PodmanLogin, # if downstream, connected, containers used
|
38
39
|
Checks::Disk::AvailableSpace,
|
39
40
|
Checks::Disk::AvailableSpaceCandlepin, # if candlepin
|
40
41
|
Checks::Foreman::ValidateExternalDbVersion, # if external database
|
@@ -3,23 +3,125 @@ module ForemanMaintain
|
|
3
3
|
class ReportCommand < Base
|
4
4
|
extend Concerns::Finders
|
5
5
|
|
6
|
+
def generate_report
|
7
|
+
scenario = run_scenario(Scenarios::Report::Generate.new({}, [:reports])).first
|
8
|
+
|
9
|
+
# description can be used too
|
10
|
+
report_data = scenario.steps.map(&:data).compact.reduce(&:merge).transform_keys(&:to_s)
|
11
|
+
report_data['version'] = 1
|
12
|
+
report_data
|
13
|
+
end
|
14
|
+
|
15
|
+
def save_report(report, file)
|
16
|
+
if file
|
17
|
+
File.write(file, report)
|
18
|
+
else
|
19
|
+
puts report
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
6
23
|
option '--output', 'FILE', 'Output the generate report into FILE'
|
7
24
|
subcommand 'generate', 'Generates the usage reports' do
|
8
25
|
def execute
|
9
|
-
|
10
|
-
|
11
|
-
# description can be used too
|
12
|
-
report_data = scenario.steps.map(&:data).compact.reduce(&:merge).transform_keys(&:to_s)
|
13
|
-
report_data['version'] = 1
|
26
|
+
report_data = generate_report
|
14
27
|
yaml = report_data.to_yaml
|
15
|
-
|
16
|
-
|
17
|
-
else
|
18
|
-
puts yaml
|
19
|
-
end
|
28
|
+
save_report(yaml, @output)
|
29
|
+
|
20
30
|
exit runner.exit_code
|
21
31
|
end
|
22
32
|
end
|
33
|
+
|
34
|
+
option '--input', 'FILE', 'Input the report from FILE'
|
35
|
+
option '--output', 'FILE', 'Output the condense report into FILE'
|
36
|
+
option '--max-age', 'HOURS', 'Max age of the report in hours'
|
37
|
+
subcommand 'condense',
|
38
|
+
'Generate a JSON formatted report with condensed data from the original report.' do
|
39
|
+
def execute
|
40
|
+
data = if fresh_enough?(@input, @max_age)
|
41
|
+
YAML.load_file(@input)
|
42
|
+
else
|
43
|
+
generate_report
|
44
|
+
end
|
45
|
+
|
46
|
+
report = condense_report(data)
|
47
|
+
report = prefix_keys(report)
|
48
|
+
save_report(JSON.dump(report), @output)
|
49
|
+
end
|
50
|
+
|
51
|
+
def condense_report(data)
|
52
|
+
result = {}
|
53
|
+
%w[advisor_on_prem_remediations_count rhel_ai_workload_host_count].each do |key|
|
54
|
+
result[key] = data[key] || 0
|
55
|
+
end
|
56
|
+
result.merge!(aggregate_host_count(data))
|
57
|
+
result.merge!(aggregate_image_mode_host_count(data))
|
58
|
+
result.merge!(aggregate_networking_metrics(data))
|
59
|
+
result
|
60
|
+
end
|
61
|
+
|
62
|
+
# Aggregates the host count numbers. The goal is to distinguish
|
63
|
+
# - RHEL hosts
|
64
|
+
# - RedHat family but not RHEL hosts
|
65
|
+
# - Other hosts
|
66
|
+
def aggregate_host_count(data)
|
67
|
+
result = {}
|
68
|
+
rhel_count = data['hosts_by_os_count|RedHat'] || 0
|
69
|
+
rh_count = data['hosts_by_family_count|Redhat'] || 0
|
70
|
+
result['host_rhel_count'] = rhel_count
|
71
|
+
result['host_redhat_count'] = rh_count - rhel_count
|
72
|
+
result['host_other_count'] = data.select do |k, _|
|
73
|
+
k.start_with?('hosts_by_os_count')
|
74
|
+
end.values.sum - rhel_count - rh_count
|
75
|
+
result
|
76
|
+
end
|
77
|
+
|
78
|
+
def aggregate_image_mode_host_count(data)
|
79
|
+
count = data.select { |k, _| k.start_with?('image_mode_hosts_by_os_count') }.values.sum
|
80
|
+
{ 'image_mode_host_count' => count }
|
81
|
+
end
|
82
|
+
|
83
|
+
def aggregate_networking_metrics(data)
|
84
|
+
ipv6 = any_positive?(data, %w[subnet_ipv6_count hosts_with_ipv6only_interface_count
|
85
|
+
foreman_interfaces_ipv6only_count])
|
86
|
+
# Deployment is considered to run in dualstack mode if:
|
87
|
+
# - Foreman has both ipv6 and ipv4 addresses on a single interface
|
88
|
+
# - or if any host in Foreman has both ipv6 and ipv4 addresses on a single interface
|
89
|
+
dualstack = any_positive?(data, %w[hosts_with_dualstack_interface_count
|
90
|
+
foreman_interfaces_dualstack_count])
|
91
|
+
|
92
|
+
# - or if there are both ipv4 and ipv6 subnets defined
|
93
|
+
dualstack |= all_positive?(data, %w[subnet_ipv4_count subnet_ipv6_count])
|
94
|
+
|
95
|
+
# - or if any host in Foreman has an interface with only an ipv4 address
|
96
|
+
# as well as another interface with ipv6 address
|
97
|
+
dualstack |= all_positive?(data, %w[hosts_with_ipv4only_interface_count
|
98
|
+
hosts_with_ipv6only_interface_count])
|
99
|
+
|
100
|
+
# - or if Foreman has an interface with only an ipv4 address
|
101
|
+
# as well as another interface with ipv6 address
|
102
|
+
dualstack |= all_positive?(data,
|
103
|
+
%w[foreman_interfaces_ipv4only_count foreman_interfaces_ipv6only_count])
|
104
|
+
|
105
|
+
{ 'use_dualstack' => dualstack, 'use_ipv6' => ipv6 }
|
106
|
+
end
|
107
|
+
|
108
|
+
def all_positive?(source, keys)
|
109
|
+
source.values_at(*keys).map { |x| x || 0 }.all?(&:positive?)
|
110
|
+
end
|
111
|
+
|
112
|
+
def any_positive?(source, keys)
|
113
|
+
source.values_at(*keys).map { |x| x || 0 }.any?(&:positive?)
|
114
|
+
end
|
115
|
+
|
116
|
+
def prefix_keys(data)
|
117
|
+
data.transform_keys { |key| 'foreman.' + key }
|
118
|
+
end
|
119
|
+
|
120
|
+
def fresh_enough?(input, max_age)
|
121
|
+
@input && File.exist?(input) &&
|
122
|
+
(@max_age.nil? || (Time.now - File.stat(input).mtime <= 60 * 60 * max_age.to_i))
|
123
|
+
end
|
124
|
+
end
|
23
125
|
end
|
24
126
|
end
|
25
127
|
end
|
@@ -2,6 +2,7 @@ module ForemanMaintain
|
|
2
2
|
module Concerns
|
3
3
|
module Downstream
|
4
4
|
SATELLITE_MAINTAIN_CONFIG = '/usr/share/satellite-maintain/config.yml'.freeze
|
5
|
+
REDHAT_REPO_FILE = '/etc/yum.repos.d/redhat.repo'.freeze
|
5
6
|
|
6
7
|
def current_version
|
7
8
|
raise NotImplementedError
|
@@ -57,6 +58,10 @@ module ForemanMaintain
|
|
57
58
|
ForemanMaintain.upgrade_in_progress == satellite_maintain_target_version
|
58
59
|
end
|
59
60
|
|
61
|
+
def connected?
|
62
|
+
File.exist?(REDHAT_REPO_FILE) && File.new(REDHAT_REPO_FILE).read.include?('https://cdn.redhat.com')
|
63
|
+
end
|
64
|
+
|
60
65
|
private
|
61
66
|
|
62
67
|
def satellite_maintain_config
|
@@ -31,6 +31,11 @@ module ForemanMaintain
|
|
31
31
|
:pgsql_data => map_file(@backup_dir, 'pgsql_data.tar.gz'),
|
32
32
|
:pulp_data => map_file(@backup_dir, 'pulp_data.tar'),
|
33
33
|
:foreman_dump => map_file(@backup_dir, 'foreman.dump'),
|
34
|
+
:iop_advisor_dump => map_file(@backup_dir, 'iop_advisor.dump'),
|
35
|
+
:iop_inventory_dump => map_file(@backup_dir, 'iop_inventory.dump'),
|
36
|
+
:iop_remediations_dump => map_file(@backup_dir, 'iop_remediations.dump'),
|
37
|
+
:iop_vmaas_dump => map_file(@backup_dir, 'iop_vmaas.dump'),
|
38
|
+
:iop_vulnerability_dump => map_file(@backup_dir, 'iop_vulnerability.dump'),
|
34
39
|
:candlepin_dump => map_file(@backup_dir, 'candlepin.dump'),
|
35
40
|
:config_files => map_file(@backup_dir, 'config_files.tar.gz'),
|
36
41
|
:metadata => map_file(@backup_dir, 'metadata.yml'),
|
@@ -50,12 +50,12 @@ module ForemanMaintain::Utils
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def exist?
|
53
|
-
['enabled', 'disabled'].include?(service_enabled_status)
|
53
|
+
['enabled', 'disabled', 'generated'].include?(service_enabled_status)
|
54
54
|
end
|
55
55
|
|
56
56
|
def enabled?
|
57
57
|
if @sys.systemd_installed?
|
58
|
-
|
58
|
+
['enabled', 'generated'].include?(service_enabled_status)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_maintain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
@@ -162,6 +162,7 @@ files:
|
|
162
162
|
- definitions/checks/check_ipv6_disable.rb
|
163
163
|
- definitions/checks/check_sha1_certificate_authority.rb
|
164
164
|
- definitions/checks/check_tmout.rb
|
165
|
+
- definitions/checks/container/podman_login.rb
|
165
166
|
- definitions/checks/disk/available_space.rb
|
166
167
|
- definitions/checks/disk/available_space_candlepin.rb
|
167
168
|
- definitions/checks/disk/available_space_postgresql13.rb
|
@@ -184,6 +185,11 @@ files:
|
|
184
185
|
- definitions/checks/foreman_tasks/invalid/check_planning_state.rb
|
185
186
|
- definitions/checks/foreman_tasks/not_paused.rb
|
186
187
|
- definitions/checks/foreman_tasks/not_running.rb
|
188
|
+
- definitions/checks/iop_advisor/db_up.rb
|
189
|
+
- definitions/checks/iop_inventory/db_up.rb
|
190
|
+
- definitions/checks/iop_remediations/db_up.rb
|
191
|
+
- definitions/checks/iop_vmaas/db_up.rb
|
192
|
+
- definitions/checks/iop_vulnerability/db_up.rb
|
187
193
|
- definitions/checks/maintenance_mode/check_consistency.rb
|
188
194
|
- definitions/checks/non_rh_packages.rb
|
189
195
|
- definitions/checks/package_manager/dnf/validate_dnf_config.rb
|
@@ -206,6 +212,7 @@ files:
|
|
206
212
|
- definitions/features/candlepin.rb
|
207
213
|
- definitions/features/candlepin_database.rb
|
208
214
|
- definitions/features/capsule.rb
|
215
|
+
- definitions/features/containers.rb
|
209
216
|
- definitions/features/cron.rb
|
210
217
|
- definitions/features/dynflow_sidekiq.rb
|
211
218
|
- definitions/features/foreman_cockpit.rb
|
@@ -218,6 +225,12 @@ files:
|
|
218
225
|
- definitions/features/hammer.rb
|
219
226
|
- definitions/features/installer.rb
|
220
227
|
- definitions/features/instance.rb
|
228
|
+
- definitions/features/iop.rb
|
229
|
+
- definitions/features/iop_advisor_database.rb
|
230
|
+
- definitions/features/iop_inventory_database.rb
|
231
|
+
- definitions/features/iop_remediations_database.rb
|
232
|
+
- definitions/features/iop_vmaas_database.rb
|
233
|
+
- definitions/features/iop_vulnerability_database.rb
|
221
234
|
- definitions/features/iptables.rb
|
222
235
|
- definitions/features/katello.rb
|
223
236
|
- definitions/features/katello_install.rb
|
@@ -239,6 +252,11 @@ files:
|
|
239
252
|
- definitions/procedures/backup/metadata.rb
|
240
253
|
- definitions/procedures/backup/online/candlepin_db.rb
|
241
254
|
- definitions/procedures/backup/online/foreman_db.rb
|
255
|
+
- definitions/procedures/backup/online/iop_advisor_db.rb
|
256
|
+
- definitions/procedures/backup/online/iop_inventory_db.rb
|
257
|
+
- definitions/procedures/backup/online/iop_remediations_db.rb
|
258
|
+
- definitions/procedures/backup/online/iop_vmaas_db.rb
|
259
|
+
- definitions/procedures/backup/online/iop_vulnerability_db.rb
|
242
260
|
- definitions/procedures/backup/online/pulpcore_db.rb
|
243
261
|
- definitions/procedures/backup/prepare_directory.rb
|
244
262
|
- definitions/procedures/backup/pulp.rb
|
@@ -292,6 +310,11 @@ files:
|
|
292
310
|
- definitions/procedures/restore/extract_files.rb
|
293
311
|
- definitions/procedures/restore/foreman_dump.rb
|
294
312
|
- definitions/procedures/restore/installer_reset.rb
|
313
|
+
- definitions/procedures/restore/iop_advisor_dump.rb
|
314
|
+
- definitions/procedures/restore/iop_inventory_dump.rb
|
315
|
+
- definitions/procedures/restore/iop_remediations_dump.rb
|
316
|
+
- definitions/procedures/restore/iop_vmaas_dump.rb
|
317
|
+
- definitions/procedures/restore/iop_vulnerability_dump.rb
|
295
318
|
- definitions/procedures/restore/pulpcore_dump.rb
|
296
319
|
- definitions/procedures/restore/reindex_databases.rb
|
297
320
|
- definitions/procedures/restore/required_packages.rb
|
@@ -451,7 +474,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
451
474
|
- !ruby/object:Gem::Version
|
452
475
|
version: '0'
|
453
476
|
requirements: []
|
454
|
-
rubygems_version: 3.6.
|
477
|
+
rubygems_version: 3.6.9
|
455
478
|
specification_version: 4
|
456
479
|
summary: Foreman maintenance tool belt
|
457
480
|
test_files: []
|