-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
159 lines (141 loc) · 6.24 KB
/
.gitlab-ci.yml
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
155
156
157
158
159
---
.script-git-submodule: &script-git-submodule
- |
git submodule sync --recursive
git submodule update --init --recursive
.script-linters: &script-linters
- |
flake8
yamllint .
ansible-lint
.script-bootstrap-python: &script-bootstrap-python
- |
if ! [[ -x "$(command -v pipx)" ]]; then
export DEBIAN_FRONTEND="noninteractive"
echo "deb http://downloadcontent.opensuse.org/repositories/home:/alvistack/xUbuntu_24.04/ /" | sudo tee /etc/apt/sources.list.d/home:alvistack.list
curl -fsSL https://downloadcontent.opensuse.org/repositories/home:alvistack/xUbuntu_24.04/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_alvistack.gpg > /dev/null
sudo -E apt-get update
sudo -E apt-get install -y bzip2 ca-certificates curl flake8 gcc gnupg gzip iproute2 pipx procps python3 python3-apt python3-cryptography python3-flake8 python3-jmespath python3-lxml python3-netaddr python3-pip python3-setuptools python3-venv python3-virtualenv python3-wheel sudo tar unzip xz-utils yamllint zip
fi
sh -x -c "python3 --version"
sh -x -c "pipx --version"
sh -x -c "flake8 --version"
sh -x -c "yamllint --version"
.script-bootstrap-ansible: &script-bootstrap-ansible
- |
if ! [[ -x "$(command -v ansible)" ]]; then
export DEBIAN_FRONTEND="noninteractive"
echo "deb http://downloadcontent.opensuse.org/repositories/home:/alvistack/xUbuntu_24.04/ /" | sudo tee /etc/apt/sources.list.d/home:alvistack.list
curl -fsSL https://downloadcontent.opensuse.org/repositories/home:alvistack/xUbuntu_24.04/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_alvistack.gpg > /dev/null
sudo -E apt-get update
sudo -E apt-get install -y ansible ansible-lint python3-docker python3-netaddr python3-vagrant
fi
sh -x -c "ansible --version"
sh -x -c "ansible-lint --version"
.script-bootstrap-molecule: &script-bootstrap-molecule
- |
if ! [[ -x "$(command -v molecule)" ]]; then
export DEBIAN_FRONTEND="noninteractive"
echo "deb http://downloadcontent.opensuse.org/repositories/home:/alvistack/xUbuntu_24.04/ /" | sudo tee /etc/apt/sources.list.d/home:alvistack.list
curl -fsSL https://downloadcontent.opensuse.org/repositories/home:alvistack/xUbuntu_24.04/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_alvistack.gpg > /dev/null
sudo -E apt-get update
sudo -E apt-get install -y python3-molecule python3-molecule-plugins
fi
sh -x -c "molecule --version"
.script-bootstrap-libvirt: &script-bootstrap-libvirt
- |
if ! [[ -x "$(command -v qemu-system-x86_64)" ]]; then
export DEBIAN_FRONTEND="noninteractive"
echo "deb http://downloadcontent.opensuse.org/repositories/home:/alvistack/xUbuntu_24.04/ /" | sudo tee /etc/apt/sources.list.d/home:alvistack.list
curl -fsSL https://downloadcontent.opensuse.org/repositories/home:alvistack/xUbuntu_24.04/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_alvistack.gpg > /dev/null
sudo -E apt-get update
sudo -E apt-get install -y binutils bridge-utils dnsmasq-base ebtables gcc libarchive-tools libguestfs-tools libvirt-clients libvirt-daemon-system libvirt-dev make qemu-system qemu-utils ruby-dev virt-manager
fi
sudo systemctl start libvirtd.service
sh -x -c "sudo systemctl status --no-pager libvirtd.service"
sh -x -c "qemu-system-x86_64 --version"
sh -x -c "virsh --version"
.script-bootstrap-vagrant: &script-bootstrap-vagrant
- |
if ! [[ -x "$(command -v vagrant)" ]]; then
export DEBIAN_FRONTEND="noninteractive"
echo "deb http://downloadcontent.opensuse.org/repositories/home:/alvistack/xUbuntu_24.04/ /" | sudo tee /etc/apt/sources.list.d/home:alvistack.list
curl -fsSL https://downloadcontent.opensuse.org/repositories/home:alvistack/xUbuntu_24.04/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_alvistack.gpg > /dev/null
sudo -E apt-get update
sudo -E apt-get install -y vagrant
vagrant plugin install vagrant-libvirt
fi
sh -x -c "vagrant --version"
sh -x -c "vagrant plugin list"
.script-symlink-ansible-role: &script-symlink-ansible-role
- |
export _ROLE="$(echo $CI_PROJECT_NAME | sed 's/^ansible-role-//g')"
mkdir -p $HOME/.ansible/roles
ln -s $CI_PROJECT_DIR $HOME/.ansible/roles/alvistack.$_ROLE
.script-molecule-test: &script-molecule-test
- |
export _MOLECULE_INSTANCE_NAME="$(pwgen -1AB 12)"
sudo -E molecule test -s $_BOX-$_PROVIDER
.script-ansible-galaxy-role-import: &script-ansible-galaxy-role-import
- |
if [[ -n "$CI_COMMIT_TAG" ]] && [[ "$CI_COMMIT_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
export _USER="$CI_PROJECT_NAMESPACE"
export _REPO="$CI_PROJECT_NAME"
elif [[ -n "$CI_COMMIT_BRANCH" ]] && [[ "$CI_COMMIT_BRANCH" =~ master ]]; then
export _USER="$CI_PROJECT_NAMESPACE"
export _REPO="$CI_PROJECT_NAME"
else
exit 0
fi
ansible-galaxy role import --token $ANSIBLE_GALAXY_TOKEN $_USER $_REPO
.job-molecule-test: &job-molecule-test
script:
- *script-bootstrap-python
- *script-bootstrap-ansible
- *script-bootstrap-molecule
- *script-bootstrap-libvirt
- *script-bootstrap-vagrant
- *script-symlink-ansible-role
- *script-molecule-test
.job-ansible-galaxy-role-import: &job-ansible-galaxy-role-import
script:
- *script-bootstrap-python
- *script-bootstrap-ansible
- *script-ansible-galaxy-role-import
default:
before_script:
- *script-git-submodule
- *script-linters
retry: 2
build:kubernetes-1.32-libvirt:
<<: *job-molecule-test
stage: build
variables:
_BOX: kubernetes-1.32
_PROVIDER: libvirt
build:kubernetes-1.31-libvirt:
<<: *job-molecule-test
stage: build
variables:
_BOX: kubernetes-1.31
_PROVIDER: libvirt
build:kubernetes-1.30-libvirt:
<<: *job-molecule-test
stage: build
variables:
_BOX: kubernetes-1.30
_PROVIDER: libvirt
build:kubernetes-1.29-libvirt:
<<: *job-molecule-test
stage: build
variables:
_BOX: kubernetes-1.29
_PROVIDER: libvirt
deploy:ansible-galaxy:
<<: *job-ansible-galaxy-role-import
stage: deploy
needs:
- build:kubernetes-1.32-libvirt
- build:kubernetes-1.31-libvirt
- build:kubernetes-1.30-libvirt
- build:kubernetes-1.29-libvirt