-
Notifications
You must be signed in to change notification settings - Fork 4
154 lines (137 loc) · 5.48 KB
/
mock-aws.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
---
name: mock-aws
on:
pull_request:
push:
branches:
- main
tags:
- '*'
schedule:
- cron: "0 5 * * 0"
defaults:
run:
working-directory: 'mtulio.okd_installer'
jobs:
create_destroy_all:
name: create-all
runs-on: ubuntu-latest
defaults:
run:
# ansible.cfg is under tests directory
working-directory: mtulio.okd_installer/tests
strategy:
fail-fast: false
matrix:
python-version:
- "3.9"
- "3.10"
test-env:
# format: provider-platform-profile
- "aws-none-ha"
# aws-sno is failing only in CI. Need more investigation to understand the root cause.
# to test it locally: bash tests/test_aws-sno_create_all-destroy.sh
#- "aws-none-sno"
dist-version:
- "okd-4.12.0-0"
- "okd-scos-4.13.0-0"
# container: ubuntu
services:
# Start Moto service (AWS mock) with custom image
mock_server_moto:
image: quay.io/mrbraga/motorserver-patch:latest
ports:
- 5000:5000
steps:
- uses: actions/checkout@v3
with:
repository: mtulio/ansible-collection-okd-installer
path: 'mtulio.okd_installer'
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set job vars
id: vars
run: |
echo "cluster-name=$(echo '{ "aws-none-ha": "aws-ha-okd", "aws-none-sno": "aws-sno-okd" }' | jq -r 'to_entries[] | select(.key=="${{ matrix.test-env }}") | .value')" >> $GITHUB_OUTPUT
echo "cache-key-pip=pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }}" >> $GITHUB_OUTPUT
echo "cache-dir-pip=$(pip cache dir)" >> $GITHUB_OUTPUT
echo "cache-key-collections=ansible-collections-${{ matrix.python-version }}-${{ hashFiles('**/requirements.yml') }}" >> $GITHUB_OUTPUT
echo "cache-dir-collections=${HOME}/.ansible/collections" >> $GITHUB_OUTPUT
echo "cache-key-bin=backend-binaries_${{ matrix.dist-version }}" >> $GITHUB_OUTPUT
echo "cache-dir-bin=${HOME}/.ansible/okd-installer/bin" >> $GITHUB_OUTPUT
- name: Set pip cache
uses: actions/cache@v3
with:
path: ${{ steps.vars.outputs.cache-dir-pip }}
key: ${{ steps.vars.outputs.cache-key-pip }}
- name: Set ansible cache
uses: actions/cache@v3
with:
path: ${{ steps.vars.outputs.cache-dir-collections }}
key: ${{ steps.vars.outputs.cache-key-collections }}
- name: Set okd installer binaries cache
uses: actions/cache@v3
with:
path: ${{ steps.vars.outputs.cache-dir-bin }}
key: ${{ steps.vars.outputs.cache-key-bin }}
- name: Update pip and install python dependencies
run: |
python -m pip install --upgrade pip
pip install -r ./../requirements.txt
- name: Install Collections
run: |
ansible-galaxy collection install -r ./../requirements.yml
ansible-galaxy collection list
- name: Create cluster config
env:
VARS_FILE: "./vars-${{ steps.vars.outputs.cluster-name }}.yaml"
run: |
set -x
source config/${{ matrix.dist-version }}.env
envsubst < config/${{ matrix.test-env }}.vars > $VARS_FILE
cat $VARS_FILE
- name: Install client binaries (play install_clients)
env:
VARS_FILE: "./vars-${{ steps.vars.outputs.cluster-name }}.yaml"
run: |
ansible-playbook mtulio.okd_installer.install_clients -e @$VARS_FILE
tree ~/.ansible/okd-installer/bin || true
# step to run create_all in new environment
- name: Create cluster (play create_all/new)
env:
VARS_FILE: "./vars-${{ steps.vars.outputs.cluster-name }}.yaml"
run: |
set -x
echo "Running create_all new infrastructure..."
./run-play-steps.sh create_all
cat ~/.ansible/okd-installer/clusters/${{ steps.vars.outputs.cluster-name }}/cluster_state.json || true
cat ~/.ansible/okd-installer/clusters/${{ steps.vars.outputs.cluster-name }}install-config-bkp.yaml || true
# step to run create_all in existing environment (immutable)
- name: Create cluster (play create_all/existing)
env:
VARS_FILE: "./vars-${{ steps.vars.outputs.cluster-name }}.yaml"
run: |
set -x
echo "Running create_all in existing infrastructure..."
# TODO: target to idepotent execution, must check change==0
./run-play-steps.sh create_all
cat ~/.ansible/okd-installer/clusters/${{ steps.vars.outputs.cluster-name }}/cluster_state.json || true
cat ~/.ansible/okd-installer/clusters/${{ steps.vars.outputs.cluster-name }}install-config-bkp.yaml || true
- name: Destroy cluster (play destroy_cluster)
env:
VARS_FILE: "./vars-${{ steps.vars.outputs.cluster-name }}.yaml"
run: |
echo "Running destroy_cluster, the stdout will be suprised..."
./run-play-steps.sh destroy_cluster
- name: Saving artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.test-env }}-${{ matrix.dist-version }}-py${{ matrix.python-version }}
retention-days: 5
path: |
~/.ansible/okd-installer/clusters/${{ steps.vars.outputs.cluster-name }}/cluster_state.json
~/.ansible/okd-installer/clusters/${{ steps.vars.outputs.cluster-name }}/install-config-bkp.yaml
./tests/vars-${{ steps.vars.outputs.cluster-name }}.yaml