|
| 1 | +--- |
| 2 | +name: Upgrade PE with legacy compilers |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - .github/workflows/**/* |
| 7 | + - spec/**/* |
| 8 | + - lib/**/* |
| 9 | + - tasks/**/* |
| 10 | + - functions/**/* |
| 11 | + - types/**/* |
| 12 | + - plans/**/* |
| 13 | + - hiera/**/* |
| 14 | + - manifests/**/* |
| 15 | + - templates/**/* |
| 16 | + - files/**/* |
| 17 | + - metadata.json |
| 18 | + - Rakefile |
| 19 | + - Gemfile |
| 20 | + - provision.yaml |
| 21 | + - .rspec |
| 22 | + - .rubocop.yml |
| 23 | + - .puppet-lint.rc |
| 24 | + - .fixtures.yml |
| 25 | + branches: [main] |
| 26 | + workflow_dispatch: |
| 27 | + inputs: |
| 28 | + ssh-debugging: |
| 29 | + description: Boolean; whether or not to pause for ssh debugging |
| 30 | + required: true |
| 31 | + default: 'false' |
| 32 | +jobs: |
| 33 | + upgrade_with_legacy_compilers: |
| 34 | + name: Upgrade PE with legacy compilers |
| 35 | + runs-on: ubuntu-20.04 |
| 36 | + env: |
| 37 | + BOLT_GEM: true |
| 38 | + BOLT_DISABLE_ANALYTICS: true |
| 39 | + LANG: en_US.UTF-8 |
| 40 | + steps: |
| 41 | + - name: Start SSH session |
| 42 | + if: ${{ github.event.inputs.ssh-debugging == 'true' }} |
| 43 | + uses: luchihoratiu/debug-via-ssh@main |
| 44 | + with: |
| 45 | + NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }} |
| 46 | + SSH_PASS: ${{ secrets.SSH_PASS }} |
| 47 | + - name: Checkout Source |
| 48 | + uses: actions/checkout@v2 |
| 49 | + - name: Activate Ruby 2.7 |
| 50 | + uses: ruby/setup-ruby@v1 |
| 51 | + with: |
| 52 | + ruby-version: '2.7' |
| 53 | + bundler-cache: true |
| 54 | + - name: Print bundle environment |
| 55 | + if: ${{ github.repository_owner == 'puppetlabs' }} |
| 56 | + run: | |
| 57 | + echo ::group::info:bundler |
| 58 | + bundle env |
| 59 | + echo ::endgroup:: |
| 60 | + - name: Provision test cluster |
| 61 | + timeout-minutes: 15 |
| 62 | + run: | |
| 63 | + echo ::group::prepare |
| 64 | + mkdir -p $HOME/.ssh |
| 65 | + echo 'Host *' > $HOME/.ssh/config |
| 66 | + echo ' ServerAliveInterval 150' >> $HOME/.ssh/config |
| 67 | + echo ' ServerAliveCountMax 2' >> $HOME/.ssh/config |
| 68 | + bundle exec rake spec_prep |
| 69 | + echo ::endgroup:: |
| 70 | + echo ::group::provision |
| 71 | + bundle exec bolt plan run peadm_spec::provision_test_cluster \ |
| 72 | + --modulepath spec/fixtures/modules \ |
| 73 | + provider=provision_service \ |
| 74 | + image=almalinux-cloud/almalinux-8 \ |
| 75 | + architecture=large-with-dr |
| 76 | + echo ::endgroup:: |
| 77 | + echo ::group::certnames |
| 78 | + bundle exec bolt plan run peadm_spec::add_inventory_hostnames \ |
| 79 | + --inventory spec/fixtures/litmus_inventory.yaml \ |
| 80 | + --modulepath spec/fixtures/modules \ |
| 81 | + --no-host-key-check \ |
| 82 | + inventory_file=spec/fixtures/litmus_inventory.yaml |
| 83 | + echo ::endgroup:: |
| 84 | + echo ::group::info:request |
| 85 | + cat request.json || true; echo |
| 86 | + echo ::endgroup:: |
| 87 | + echo ::group::info:inventory |
| 88 | + sed -e 's/password: .*/password: "[redacted]"/' < spec/fixtures/litmus_inventory.yaml || true |
| 89 | + echo ::endgroup:: |
| 90 | + - name: Set up yq |
| 91 | + uses: frenck/action-setup-yq@v1 |
| 92 | + with: |
| 93 | + version: v4.30.5 |
| 94 | + - name: Create the params.json file |
| 95 | + run: | |
| 96 | + primary=$(yq '.groups[].targets[] | select(.vars.role == "primary") | .name' spec/fixtures/litmus_inventory.yaml) |
| 97 | + compiler=$(yq '.groups[].targets[] | select(.vars.role == "compiler") | .name' spec/fixtures/litmus_inventory.yaml | head -n 1) |
| 98 | + legacy_compiler=$(yq '.groups[].targets[] | select(.vars.role == "compiler") | .name' spec/fixtures/litmus_inventory.yaml | sed -n 2p) |
| 99 | + replica=$(yq '.groups[].targets[] | select(.vars.role == "replica") | .name' spec/fixtures/litmus_inventory.yaml) |
| 100 | + echo -n '{ "download_mode": "direct", "primary_host": "'$primary'", "replica_host": "'$replica'", "legacy_compilers": ["'$legacy_compiler'"], "compiler_hosts": ["'$compiler'"], "version": "2023.7.0", "console_password": "'${{ secrets.CONSOLE_PASSWORD }}'" }' > params.json |
| 101 | + - name: Install PE with legacy compilers |
| 102 | + timeout-minutes: 120 |
| 103 | + run: | |
| 104 | + echo ::group::params.json |
| 105 | + jq '.console_password = "[redacted]"' params.json || true |
| 106 | + echo ::endgroup:: |
| 107 | + echo ::group::install |
| 108 | + bundle exec bolt plan run peadm::install \ |
| 109 | + --inventoryfile spec/fixtures/litmus_inventory.yaml \ |
| 110 | + --modulepath spec/fixtures/modules \ |
| 111 | + --no-host-key-check \ |
| 112 | + --params @params.json |
| 113 | + echo ::endgroup:: |
| 114 | + - name: Wait as long as the file ${HOME}/pause file is present |
| 115 | + if: ${{ always() && github.event.inputs.ssh-debugging == 'true' }} |
| 116 | + run: | |
| 117 | + while [ -f "${HOME}/pause" ] ; do |
| 118 | + echo "${HOME}/pause present, sleeping for 60 seconds..." |
| 119 | + sleep 60 |
| 120 | + done |
| 121 | + echo "${HOME}/pause absent, continuing workflow." |
| 122 | + - name: Check if compilers are configured |
| 123 | + timeout-minutes: 120 |
| 124 | + run: | |
| 125 | + echo ::group::inventory |
| 126 | + sed -e 's/password: .*/password: "[redacted]"/' < spec/fixtures/litmus_inventory.yaml || true |
| 127 | + echo ::endgroup:: |
| 128 | + echo ::group::get_peadm_config |
| 129 | + primary=$(yq '.groups[].targets[] | select(.vars.role == "primary") | .name' spec/fixtures/litmus_inventory.yaml) |
| 130 | + compiler=$(yq '.groups[].targets[] | select(.vars.role == "compiler") | .name' spec/fixtures/litmus_inventory.yaml | head -n 1) |
| 131 | + legacy_compiler=$(yq '.groups[].targets[] | select(.vars.role == "compiler") | .name' spec/fixtures/litmus_inventory.yaml | sed -n 2p) |
| 132 | + bundle exec bolt task run peadm::get_peadm_config \ |
| 133 | + --targets $primary \ |
| 134 | + --inventoryfile spec/fixtures/litmus_inventory.yaml \ |
| 135 | + --modulepath spec/fixtures/modules \ |
| 136 | + --no-host-key-check \ |
| 137 | + --format json > peadm_config.json |
| 138 | + cat peadm_config.json |
| 139 | + echo ::endgroup:: |
| 140 | + echo ::group::smoke_test |
| 141 | + configured_legacy_compiler=$(yq '.items[0].value.params.legacy_compilers[0]' peadm_config.json) |
| 142 | + configured_compiler=$(yq '.items[0].value.params.compiler_hosts[0]' peadm_config.json) |
| 143 | + if [ "$configured_legacy_compiler" != "$legacy_compiler" ] && [ "$configured_compiler" != "$compiler" ]; then |
| 144 | + echo "Compilers are not configured, expected $legacy_compiler and $compiler, got $configured_legacy_compiler and $configured_compiler" |
| 145 | + exit 1 |
| 146 | + fi |
| 147 | + echo ::endgroup:: |
| 148 | + - name: Create the upgrade params.json file |
| 149 | + run: | |
| 150 | + primary=$(yq '.groups[].targets[] | select(.vars.role == "primary") | .name' spec/fixtures/litmus_inventory.yaml) |
| 151 | + compiler=$(yq '.groups[].targets[] | select(.vars.role == "compiler") | .name' spec/fixtures/litmus_inventory.yaml | head -n 1) |
| 152 | + legacy_compiler=$(yq '.groups[].targets[] | select(.vars.role == "compiler") | .name' spec/fixtures/litmus_inventory.yaml | sed -n 2p) |
| 153 | + replica=$(yq '.groups[].targets[] | select(.vars.role == "replica") | .name' spec/fixtures/litmus_inventory.yaml) |
| 154 | + echo -n '{ "primary_host": "'$primary'", "replica_host": "'$replica'", "compiler_hosts": ["'$compiler'", "'$legacy_compiler'"], "version": "2023.8.0"}' > upgrade_params.json |
| 155 | + - name: Upgrade PE with legacy compilers |
| 156 | + run: | |
| 157 | + echo ::group::upgrade_params.json |
| 158 | + cat upgrade_params.json |
| 159 | + echo ::endgroup:: |
| 160 | + echo ::group::upgrade |
| 161 | + bundle exec bolt plan run peadm::upgrade \ |
| 162 | + --inventoryfile spec/fixtures/litmus_inventory.yaml \ |
| 163 | + --modulepath spec/fixtures/modules \ |
| 164 | + --no-host-key-check \ |
| 165 | + --params @upgrade_params.json |
| 166 | + echo ::endgroup:: |
| 167 | + - name: Check if we still have legacy compilers configured |
| 168 | + timeout-minutes: 120 |
| 169 | + run: | |
| 170 | + echo ::group::inventory |
| 171 | + sed -e 's/password: .*/password: "[redacted]"/' < spec/fixtures/litmus_inventory.yaml || true |
| 172 | + echo ::endgroup:: |
| 173 | + echo ::group::get_peadm_config |
| 174 | + primary=$(yq '.groups[].targets[] | select(.vars.role == "primary") | .name' spec/fixtures/litmus_inventory.yaml) |
| 175 | + compiler=$(yq '.groups[].targets[] | select(.vars.role == "compiler") | .name' spec/fixtures/litmus_inventory.yaml | head -n 1) |
| 176 | + legacy_compiler=$(yq '.groups[].targets[] | select(.vars.role == "compiler") | .name' spec/fixtures/litmus_inventory.yaml | sed -n 2p) |
| 177 | + bundle exec bolt task run peadm::get_peadm_config \ |
| 178 | + --targets $primary \ |
| 179 | + --inventoryfile spec/fixtures/litmus_inventory.yaml \ |
| 180 | + --modulepath spec/fixtures/modules \ |
| 181 | + --no-host-key-check \ |
| 182 | + --format json > peadm_config.json |
| 183 | + cat peadm_config.json |
| 184 | + echo ::endgroup:: |
| 185 | + echo ::group::smoke_test |
| 186 | + configured_legacy_compiler=$(yq '.items[0].value.params.legacy_compilers[0]' peadm_config.json) |
| 187 | + configured_compiler=$(yq '.items[0].value.params.compiler_hosts[0]' peadm_config.json) |
| 188 | + if [ "$configured_legacy_compiler" != "$legacy_compiler" ] && [ "$configured_compiler" != "$compiler" ]; then |
| 189 | + echo "Compilers are not configured, expected $legacy_compiler and $compiler, got $configured_legacy_compiler and $configured_compiler" |
| 190 | + exit 1 |
| 191 | + fi |
| 192 | + echo ::endgroup:: |
| 193 | + - name: Tear down test cluster |
| 194 | + if: ${{ always() }} |
| 195 | + continue-on-error: true |
| 196 | + run: |- |
| 197 | + if [ -f spec/fixtures/litmus_inventory.yaml ]; then |
| 198 | + echo ::group::tear_down |
| 199 | + bundle exec rake 'litmus:tear_down' |
| 200 | + echo ::endgroup:: |
| 201 | + echo ::group::info:request |
| 202 | + cat request.json || true; echo |
| 203 | + echo ::endgroup:: |
| 204 | + fi |
0 commit comments