diff --git a/playbooks/oracle_release_update/oracle_release_update/tasks/update_oem_targets.yml b/playbooks/oracle_release_update/oracle_release_update/tasks/update_oem_targets.yml deleted file mode 100644 index 2af2e402..00000000 --- a/playbooks/oracle_release_update/oracle_release_update/tasks/update_oem_targets.yml +++ /dev/null @@ -1,69 +0,0 @@ ---- -# The environment name will not be defined in the engineering environments as it is not in the Ansible group variables -- name: Get the Environment Name if Not Already Set - when: not environment_name is defined - block: - - name: Use local environment to get environment_name - shell: . /etc/environment && echo ${HMPPS_ENVIRONMENT} - register: get_environment_name - delegate_to: "{{ groups[update_host][0] }}" - - - name: Set environment name - set_fact: - environment_name: "{{ get_environment_name.stdout_lines[-1] }}" - -# This value comes from the inventory in hmpps-engineering-platform-terraform/env_configs -- name: Set Engineering environment AWS Account ID - set_fact: - engineering_account_id: "{{ account_id }}" - -- name: Update repositories cache and install AWS client package - shell: | - apt-get update - apt install -y awscli - apt install -y jq - -- community.aws.sts_assume_role: - role_arn: "arn:aws:iam::{{ engineering_account_id }}:role/terraform" - role_session_name: "{{ inventory_hostname }}_terraform" - register: assumed_role - -- name: Start OEM Target Update for {{ update_host }} - shell: | - aws ssm start-automation-execution --document-name "arn:aws:ssm:eu-west-2:{{ engineering_account_id }}:automation-definition/{{ document_name }}" --region eu-west-2 --parameters "Environment={{ environment_name }},TargetHost={{ update_host }},GridHome={{ grid_home }},DatabaseHome={{ database_home }}" | jq --raw-output '.AutomationExecutionId' - register: oem_automation - environment: - AWS_ACCESS_KEY_ID: "{{ assumed_role.sts_creds.access_key }}" - AWS_SECRET_ACCESS_KEY: "{{ assumed_role.sts_creds.secret_key }}" - AWS_SESSION_TOKEN: "{{ assumed_role.sts_creds.session_token }}" - -- name: Start Output - debug: var=oem_automation - -- name: Set Automation ID - set_fact: - oem_automation_id: "{{ oem_automation.stdout }}" - -- fail: - msg: "OEM Target Update CodeBuild failed to start." - when: oem_automation_id == '' - -- name: Report Automation ID - debug: - msg: "Running OEM Target Update in {{ environment_name }} account ({{ engineering_account_id }}). Automation ID is {{ oem_automation_id }}." - -- name: Wait for Update of {{ update_host }} OEM targets - shell: | - aws ssm describe-automation-step-executions --automation-execution-id "{{ oem_automation_id }}" --region=eu-west-2 --filters "Key=StepName,Values=CheckBuildStatus" | jq --raw-output '.StepExecutions[0].StepStatus' - register: oem_automation_status - until: oem_automation_status.stdout == 'Success' or oem_automation_status.stdout == 'Failed' - retries: 50 - delay: 30 - environment: - AWS_ACCESS_KEY_ID: "{{ assumed_role.sts_creds.access_key }}" - AWS_SECRET_ACCESS_KEY: "{{ assumed_role.sts_creds.secret_key }}" - AWS_SESSION_TOKEN: "{{ assumed_role.sts_creds.session_token }}" - -- fail: - msg: "Failed to complete OEM update for {{ update_host }}. See {{ environment_name }} Automation ID {{ oem_automation_id }}" - when: oem_automation_status.stdout != 'Success'