Skip to content

Commit

Permalink
verify interfaces based on backup metadata not answers
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Mar 6, 2024
1 parent 390a8b7 commit 951b653
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 49 deletions.
51 changes: 5 additions & 46 deletions roles/satellite-clone/tasks/interface_check.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,11 @@
---
- name: get answers file path from yaml
get_value_from_yaml_in_tarball:
tarball: "{{ config_files_path }}"
target_file: "etc/foreman-installer/scenarios.d/{{ satellite_scenario }}.yaml"
keys: [":answer_file"]
register: answer_file

- name: set answers file path
set_fact:
satellite_answers_path: "{{ answer_file.value | relpath('/') }}"

- name: Check if DNS is enabled
get_value_from_yaml_in_tarball:
tarball: "{{ config_files_path }}"
target_file: "{{ satellite_answers_path }}"
keys: ["foreman_proxy", "dns"]
register: dns_enabled

- name: Check if DHCP is enabled
get_value_from_yaml_in_tarball:
tarball: "{{ config_files_path }}"
target_file: "{{ satellite_answers_path }}"
keys: ["foreman_proxy", "dhcp"]
register: dhcp_enabled

- name: Grab DNS interface from Satellite answer file
get_value_from_yaml_in_tarball:
tarball: "{{ config_files_path }}"
target_file: "{{ satellite_answers_path }}"
keys: ["foreman_proxy", "dns_interface"]
register: dns_interface
when: dns_enabled.value

- name: Grab DHCP interface from Satellite answer file
get_value_from_yaml_in_tarball:
tarball: "{{ config_files_path }}"
target_file: "{{ satellite_answers_path }}"
keys: ["foreman_proxy", "dhcp_interface"]
register: dhcp_interface
when: dhcp_enabled.value

- name: Fail if interfaces on machine do not match answer file interfaces
- name: Fail if interfaces on machine do not match backup metadata interfaces
fail:
msg: "The network interface {{ dns_interface.value }} setup for DNS and {{ dhcp_interface.value }} setup for DHCP do not match the network interfaces on the current machine"
when:
- dns_enabled.value
- dhcp_enabled.value
- dns_interface.value not in network_interfaces
- dhcp_interface.value not in network_interfaces
- proxy_config.dns
- proxy_config.dhcp
- proxy_config.dns_interface not in network_interfaces
- proxy_config.dhcp_interface not in network_interfaces
vars:
network_interfaces: "{{ ansible_interfaces | reject('match', 'lo') | list }}"
6 changes: 3 additions & 3 deletions roles/satellite-clone/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
include_tasks: pre_install_check.yml
when: run_pre_install_check

- name: Run backup version check
include_tasks: backup_satellite_version_check.yml

- name: Run interface check
include_tasks: interface_check.yml
when: run_pre_install_check and check_networking_interfaces

- name: Run backup version check
include_tasks: backup_satellite_version_check.yml

- name: Run backup check
include_tasks: backup_check.yml

Expand Down

0 comments on commit 951b653

Please sign in to comment.