From 7c8c6f1d304967f15241cc96df9713290dd2aa57 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Wed, 6 Mar 2024 13:18:28 +0100 Subject: [PATCH] use hostname from metadata no need to parse URLs --- .../library/parse_backup_metadata.py | 3 +++ .../tasks/backup_satellite_version_check.yml | 1 + roles/satellite-clone/tasks/main.yml | 15 ++------------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/roles/satellite-clone/library/parse_backup_metadata.py b/roles/satellite-clone/library/parse_backup_metadata.py index 689d172..d00cd21 100644 --- a/roles/satellite-clone/library/parse_backup_metadata.py +++ b/roles/satellite-clone/library/parse_backup_metadata.py @@ -48,6 +48,8 @@ def parse_backup_metadata(params): puppetserver_present = bool(find_rpm(rpms, "^puppetserver-[\d+].*")) qpidd_present = bool(find_rpm(rpms, "^qpid-cpp-server-[\d+].*")) + hostname = data['hostname'] + if not satellite_version: satellite_version = os.getenv('SATELLITE_CLONE_FORCE_VERSION') @@ -60,6 +62,7 @@ def parse_backup_metadata(params): result = dict(satellite_version=satellite_version, puppetserver_present=puppetserver_present, qpidd_present=qpidd_present, + hostname=hostname, msg=msg, changed=False) return True, result diff --git a/roles/satellite-clone/tasks/backup_satellite_version_check.yml b/roles/satellite-clone/tasks/backup_satellite_version_check.yml index bee6e3a..9ebe1b8 100644 --- a/roles/satellite-clone/tasks/backup_satellite_version_check.yml +++ b/roles/satellite-clone/tasks/backup_satellite_version_check.yml @@ -21,6 +21,7 @@ satellite_version: "{{ backup_metadata.satellite_version }}" puppetserver_present: "{{ backup_metadata.puppetserver_present }}" qpidd_present: "{{ backup_metadata.qpidd_present }}" + hostname: "{{ backup_metadata.hostname }}" when: - clone_metadata_exists - backup_metadata is defined diff --git a/roles/satellite-clone/tasks/main.yml b/roles/satellite-clone/tasks/main.yml index eef4ae4..abc5538 100644 --- a/roles/satellite-clone/tasks/main.yml +++ b/roles/satellite-clone/tasks/main.yml @@ -26,21 +26,10 @@ paths: - "vars" -- name: Identify the hostname from the backup config tar file - get_value_from_yaml_in_tarball: - tarball: "{{ config_files_path }}" - target_file: "etc/foreman-proxy/settings.yml" - keys: [":foreman_url"] - register: backup_hostname - -- name: Set backup_hostname variable - set_fact: - hostname: "{{ backup_hostname.value | urlsplit('hostname') }}" - - name: Check that the hostname is not none fail: - msg: "Unable to derive Satellite hostname from the backup config file - value ({{ hostname }}) doesn't look right" - when: backup_hostname|length == 0 + msg: "Unable to derive Satellite hostname from the backup metadata file - value ({{ hostname }}) doesn't look right" + when: hostname|length == 0 - name: Check that the registration variables (activationkey, org) are updated fail: