diff --git a/tasks/common/skip_rhel_enforcement.yaml b/tasks/common/skip_rhel_enforcement.yaml index db9ce4b4..224f42a9 100644 --- a/tasks/common/skip_rhel_enforcement.yaml +++ b/tasks/common/skip_rhel_enforcement.yaml @@ -1,16 +1,39 @@ --- -- name: Create the entry in undercloud.conf - ini_file: +- name: Check undercloud.conf exists + stat: path: "{{ working_dir }}/undercloud.conf" - section: DEFAULT - option: custom_env_files - value: "{{ working_dir }}/skip_rhel_release.yaml" - -- name: Create the heat parameter file for undercloud. - vars: - skip_rhel: - parameter_defaults: - SkipRhelEnforcement: true - copy: - content: "{{ skip_rhel | to_nice_yaml }}" - dest: "{{ working_dir }}/skip_rhel_release.yaml" + register: under_conf_exist +- block: + - name: "Retrieve remote ini file" + fetch: + src: "{{ working_dir }}/undercloud.conf" + dest: '/tmp/' + flat: true + - name: Read current custom_env_files files + set_fact: + current_custom_env: "{{ lookup( 'ini', 'custom_env_files section=DEFAULT file=/tmp/undercloud.conf') }}" + - name: Append skip_rhel_release.yaml to custom_env_files + ini_file: + path: "{{ working_dir }}/undercloud.conf" + section: DEFAULT + option: custom_env_files + value: "{{ current_custom_env.split(',')| union([working_dir+'/skip_rhel_release.yaml'])|map('trim')|unique|join(',')}}" + backup: true + when: current_custom_env | default([]) | length > 0 + - name: Insert custom_env_files + ini_file: + path: "{{ working_dir }}/undercloud.conf" + section: DEFAULT + option: custom_env_files + value: "{{ working_dir }}/skip_rhel_release.yaml" + backup: true + when: current_custom_env | default([]) | length == 0 + - name: Create the heat parameter file for undercloud. + vars: + skip_rhel: + parameter_defaults: + SkipRhelEnforcement: true + copy: + content: "{{ skip_rhel | to_nice_yaml }}" + dest: "{{ working_dir }}/skip_rhel_release.yaml" + when: under_conf_exist.stat.exists