|
| 1 | +name: "Oracle: Deinstall Oracle Software" |
| 2 | +run-name: "Oracle: ${{ format('{0}-{1}', github.event.inputs.TargetEnvironment, github.event.inputs.TargetHost) }}-deinstall-oracle-software" |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + TargetEnvironment: |
| 7 | + description: "Target environment" |
| 8 | + required: true |
| 9 | + type: choice |
| 10 | + options: |
| 11 | + - "delius-core-dev" |
| 12 | + - "delius-core-test" |
| 13 | + - "delius-core-training" |
| 14 | + - "delius-core-stage" |
| 15 | + - "delius-core-pre-prod" |
| 16 | + - "delius-core-prod" |
| 17 | + TargetHost: |
| 18 | + description: "Database target host" |
| 19 | + type: choice |
| 20 | + options: |
| 21 | + - "delius_primarydb" |
| 22 | + - "delius_standbydb1" |
| 23 | + - "delius_standbydb2" |
| 24 | + - "delius_standbydb1,delius_standbydb2" |
| 25 | + - "delius_dbs" |
| 26 | + - "mis_primarydb" |
| 27 | + - "mis_standbydb1" |
| 28 | + - "mis_dbs" |
| 29 | + - "misboe_primarydb" |
| 30 | + - "misboe_standbydb1" |
| 31 | + - "misboe_dbs" |
| 32 | + - "misdsd_primarydb" |
| 33 | + - "misdsd_standbydb1" |
| 34 | + - "misdsd_dbs" |
| 35 | + GridHome: |
| 36 | + description: "Oracle Grid Infrastructure Home to Deinstall" |
| 37 | + type: choice |
| 38 | + default: "DO_NOT_DEINSTALL" |
| 39 | + options: |
| 40 | + - "DO_NOT_DEINSTALL" |
| 41 | + - "/u01/app/grid/product/19.0.0/grid" |
| 42 | + DatabaseHome: |
| 43 | + description: "Oracle Database Home to Deinstall" |
| 44 | + type: choice |
| 45 | + default: "DO_NOT_DEINSTALL" |
| 46 | + options: |
| 47 | + - "DO_NOT_DEINSTALL" |
| 48 | + - "/u01/app/oracle/product/19.0.0/db" |
| 49 | + VerboseOutput: |
| 50 | + description: "Verbose Output level" |
| 51 | + type: choice |
| 52 | + default: "" |
| 53 | + options: |
| 54 | + - "" |
| 55 | + - "-vv" |
| 56 | + - "-vvv" |
| 57 | + - "-vvvv" |
| 58 | + SourceCodeVersion: |
| 59 | + description: "Source version for the hmpps-delius-operation-automation. Enter a pull request, branch, commit ID, tag, or reference." |
| 60 | + type: string |
| 61 | + default: "main" |
| 62 | + SourceConfigVersion: |
| 63 | + description: "Source version for the modernisation-platform-configuration-management. Enter a pull request, branch, commit ID, tag, or reference." |
| 64 | + type: string |
| 65 | + default: "main" |
| 66 | + |
| 67 | +env: |
| 68 | + ansible_config: ansible/playbooks/ansible.cfg |
| 69 | + command: ansible-playbook operations/playbooks/oracle_release_update/deinstall_oracle.yml |
| 70 | + inventory: inventory/ansible |
| 71 | + |
| 72 | +permissions: |
| 73 | + contents: read |
| 74 | + packages: read |
| 75 | + id-token: write |
| 76 | + |
| 77 | +jobs: |
| 78 | + oracle-db-deinstall: |
| 79 | + name: oracle-db-deinstall |
| 80 | + environment: ${{ github.event.inputs.TargetEnvironment }} |
| 81 | + runs-on: ubuntu-latest |
| 82 | + container: |
| 83 | + image: ghcr.io/ministryofjustice/hmpps-delius-operational-automation:0.41.0 |
| 84 | + timeout-minutes: 1440 |
| 85 | + continue-on-error: false |
| 86 | + steps: |
| 87 | + |
| 88 | + - name: Prepare Target Name |
| 89 | + id: preparetargetname |
| 90 | + shell: bash |
| 91 | + run: | |
| 92 | + environment_name="environment_name_$(echo ${{ github.event.inputs.TargetEnvironment }} | sed 's/delius-core-dev/delius_core_development_dev/;s/delius-core-test/delius_core_test_test/;s/delius-core-training/delius_core_test_training/;s/delius-core-stage/delius_core_preproduction_stage/;s/delius-core-pre-prod/delius_core_preproduction_pre_prod/;s/delius-core-prod/delius_core_production_prod/')" |
| 93 | + IFS="," |
| 94 | + for target in ${{ github.event.inputs.TargetHost }} |
| 95 | + do |
| 96 | + IFS="" |
| 97 | + TargetHost+=${environment_name}_${target}, |
| 98 | + done |
| 99 | + echo "TargetHost=${TargetHost%?}" >> $GITHUB_OUTPUT |
| 100 | +
|
| 101 | + - name: Checkout From hmpps-delius-operational-automation |
| 102 | + uses: actions/checkout@v4 |
| 103 | + with: |
| 104 | + repository: ministryofjustice/hmpps-delius-operational-automation |
| 105 | + sparse-checkout-cone-mode: false |
| 106 | + sparse-checkout: | |
| 107 | + playbooks/oracle_release_update |
| 108 | + common/* |
| 109 | + playbooks/ansible.cfg |
| 110 | + path: operations |
| 111 | + ref: ${{ github.event.inputs.SourceCodeVersion }} |
| 112 | + fetch-depth: 0 |
| 113 | + |
| 114 | + - name: Checkout Inventory From modernisation-platform-configuration-management |
| 115 | + uses: actions/checkout@v4 |
| 116 | + with: |
| 117 | + repository: ministryofjustice/modernisation-platform-configuration-management |
| 118 | + sparse-checkout-cone-mode: false |
| 119 | + sparse-checkout: | |
| 120 | + ansible/hosts |
| 121 | + ansible/group_vars |
| 122 | + path: inventory |
| 123 | + ref: ${{ github.event.inputs.SourceConfigVersion }} |
| 124 | + fetch-depth: 0 |
| 125 | + |
| 126 | + - name: Checkout Ansible Required Roles From modernisation-platform-configuration-management |
| 127 | + uses: actions/checkout@v4 |
| 128 | + with: |
| 129 | + repository: ministryofjustice/modernisation-platform-configuration-management |
| 130 | + sparse-checkout-cone-mode: false |
| 131 | + sparse-checkout: | |
| 132 | + ansible/roles/secretsmanager-passwords |
| 133 | + ansible/roles/get-modernisation-platform-facts |
| 134 | + path: roles |
| 135 | + ref: ${{ github.event.inputs.SourceConfigVersion }} |
| 136 | + fetch-depth: 0 |
| 137 | + |
| 138 | + - name: Configure AWS Credentials |
| 139 | + id: login-aws |
| 140 | + uses: aws-actions/configure-aws-credentials@v4 |
| 141 | + with: |
| 142 | + role-to-assume: "arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/modernisation-platform-oidc-cicd" |
| 143 | + role-session-name: "hmpps-delius-operational-automation-${{ github.run_number }}" |
| 144 | + aws-region: "eu-west-2" |
| 145 | + |
| 146 | + - name: Start Deinstall Oracle Home |
| 147 | + run: | |
| 148 | + export ANSIBLE_CONFIG=$ansible_config |
| 149 | + ln -s $PWD/roles/ansible/roles $PWD/operations/playbooks/oracle_release_update/roles |
| 150 | + $command -i $inventory -e ansible_aws_ssm_bucket_name=${{ vars.ANSIBLE_AWS_SSM_BUCKET_NAME }} \ |
| 151 | + -e target_hosts="${{ steps.preparetargetname.outputs.TargetHost }}" \ |
| 152 | + -e oracle_grid_oracle_home="${{ github.event.inputs.GridHome }}" \ |
| 153 | + -e oracle_database_oracle_home="${{ github.event.inputs.DatabaseHome }}" ${{ github.event.inputs.VerboseOutput }} |
0 commit comments