64 lines
3.0 KiB
YAML
64 lines
3.0 KiB
YAML
---
|
|
- name: Init service name
|
|
ansible.builtin.import_tasks: ../utils/init-service-name.yml
|
|
|
|
- name: Clone repo
|
|
ansible.builtin.import_tasks: ../utils/clone-repo.yml
|
|
|
|
- name: Get and set ioc_port
|
|
ansible.builtin.import_tasks: ../utils/get-ioc-port.yml
|
|
|
|
- name: "[{{ target_service_name_lower }}] Establish environment naming conventions"
|
|
ansible.builtin.set_fact:
|
|
service_name_upper: "{{ target_service_name_lower | upper }}"
|
|
|
|
- name: "[{{ target_service_name_lower }}] Define file paths"
|
|
ansible.builtin.set_fact:
|
|
ioc_base_dir: "{{ workspace_dir }}/services/{{ target_service_name_lower }}/current/ioc"
|
|
orig_subs_name: "AGEBD-CPCL-{{ service_name_upper }}_main.subs"
|
|
target_subs_name: "AGEBD-CPCL-{{ service_name_upper }}{{ env_suffix_upper }}_main.subs"
|
|
orig_params_name: "AGEBD-CPCL-{{ service_name_upper }}_parameters.yaml"
|
|
target_params_name: "AGEBD-CPCL-{{ service_name_upper }}{{ env_suffix_upper }}_parameters.yaml"
|
|
|
|
# Rename the subs file if we are in DEV
|
|
- name: "[{{ target_service_name_lower }}] Rename substitution file for environment"
|
|
ansible.builtin.command:
|
|
cmd: "mv {{ ioc_base_dir }}/{{ orig_subs_name }} {{ ioc_base_dir }}/{{ target_subs_name }}"
|
|
removes: "{{ ioc_base_dir }}/{{ orig_subs_name }}" # Only runs if the original file exists
|
|
|
|
# Rename the paramters file if we are in DEV
|
|
- name: "[{{ target_service_name_lower }}] Rename parameters file for environment"
|
|
ansible.builtin.command:
|
|
cmd: "mv {{ ioc_base_dir }}/{{ orig_params_name }} {{ ioc_base_dir }}/{{ target_params_name }}"
|
|
removes: "{{ ioc_base_dir }}/{{ orig_params_name }}" # Only runs if the original file exists
|
|
|
|
# Replace {{ agebd_env_suffix }} inside the newly renamed subs file
|
|
- name: "[{{ target_service_name_lower }}] Substitute environment tokens inside subs file"
|
|
ansible.builtin.replace:
|
|
path: "{{ ioc_base_dir }}/{{ target_subs_name }}"
|
|
regexp: '\{\{\s*agebd_env_suffix\s*\}\}'
|
|
replace: "{{ env_suffix_upper }}"
|
|
|
|
# Replace {{ agebd_env_suffix }} and {{ ioc_port }} inside the newly renamed params file
|
|
- name: "[{{ target_service_name_lower }}] Substitute environment token inside params file"
|
|
ansible.builtin.replace:
|
|
path: "{{ ioc_base_dir }}/{{ target_params_name }}"
|
|
regexp: "{{ item.regexp }}"
|
|
replace: "{{ item.replace | string }}"
|
|
with_items:
|
|
- { regexp: '\{\{\s*agebd_env_suffix\s*\}\}', replace: "{{ env_suffix_lower }}" }
|
|
- { regexp: '\{\{\s*ioc_port\s*\}\}', replace: "{{ ioc_port }}" }
|
|
|
|
- name: "[{{ target_service_name_lower }}] Run ioc install"
|
|
ansible.builtin.shell:
|
|
cmd: "ioc install -V --facility sls --ioc AGEBD-CPCL-{{ service_name_upper }}{{ env_suffix_upper }} --clean"
|
|
chdir: "{{ ioc_base_dir }}"
|
|
changed_when: true
|
|
register: ioc_install_result
|
|
# Force a pipeline failure if the command output contains error keywords
|
|
# (ioc install ... returns exit code 0 even on failure...)
|
|
failed_when: >
|
|
ioc_install_result.rc != 0 or
|
|
"[error]" in ioc_install_result.stderr or
|
|
"Unable to write" in ioc_install_result.stderr
|