Closed johnpmitsch closed 4 years ago
You can add this or similar commands to the top of roles/satellite-clone/tasks/main.yml
and run the playbook to test. It will abort before changes are made because of the fail command
- name: get answer value
get_value_from_yaml_in_tarball:
tarball: "{{ config_files_path }}"
target_file: "{{ satellite_answers_path }}"
keys: ["foreman_proxy", "dhcp"]
register: dhcp_answer
- name: get answer value
get_value_from_yaml_in_tarball:
tarball: "{{ config_files_path }}"
target_file: "{{ satellite_answers_path }}"
keys: ["certs", "generate"]
register: certs_generate_answer
- name: get answer value
get_value_from_yaml_in_tarball:
tarball: "{{ config_files_path }}"
target_file: "{{ satellite_answers_path }}"
keys: ["foreman::plugin::tasks", "package"]
register: plugin_tasks
# uncomment to test key not found error
#- name: answer value doesn't exist
# get_value_from_yaml_in_tarball:
# tarball: "{{ config_files_path }}"
# target_file: "{{ satellite_answers_path }}"
# keys: ["bologna", "sandwich"]
# register: plugin_tasks
# Identify hostname from backup config file
- 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: config_url
- name: Set backup_hostname variable
set_fact:
backup_hostname: "{{ config_url.value | urlsplit('hostname') }}"
- debug:
msg: "dhcp: {{ dhcp_answer.value }}, certs_generate: {{ certs_generate_answer.value }}, plugin_tasks: {{ plugin_tasks.value }}, backup_hostname: {{ backup_hostname }}"
- debug:
msg: "I should not be printing because the value is false"
when: dhcp_answer.value
- debug:
msg: I should be printing because the value is true
when: certs_generate_answer.value
- fail:
msg: "aborting early since only testing"
This module will be used more in https://github.com/RedHatSatellite/satellite-clone/pull/369
All passed on dolly:
192.168.121.152 : ok=21 changed=16 unreachable=0 failed=0
192.168.121.187 : ok=21 changed=16 unreachable=0 failed=0
192.168.121.198 : ok=21 changed=16 unreachable=0 failed=0
192.168.121.40 : ok=21 changed=16 unreachable=0 failed=0
For Satellite answers and other configs, it helps if we have a way to parse the yaml config files inside the tarball. This commit adds that custom module and updates a place where we parse the configs from the shell.