-
Notifications
You must be signed in to change notification settings - Fork 21
265 lines (261 loc) · 12 KB
/
default-lxd.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
---
name: default-lxd
on:
push:
pull_request:
workflow_dispatch:
schedule: # run weekly, every Thursday 06:00
- cron: '0 6 * * 4'
permissions: {}
jobs:
build:
permissions:
contents: read
runs-on: ubuntu-22.04
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
max-parallel: 4
matrix:
include:
- distribution: centos
version: 9-Stream
version2: 9-Stream
suite: default
experimental: true
- distribution: centos
version: 8-Stream
version2: 8-Stream
suite: default
experimental: true
- distribution: debian
version: bullseye
version2: bullseye
suite: default
experimental: true
- distribution: ubuntu
version: '22.04'
version2: 2204
suite: default
experimental: true
- distribution: ubuntu
version: '20.04'
version2: 2004
suite: default
experimental: false
- distribution: ubuntu
version: '20.04'
version2: 2004
suite: default-nosnuffle
experimental: false
env:
ANSIBLE_CALLBACKS_ENABLED: profile_tasks
ANSIBLE_ROLE: juju4.misp
LXDIMAGE: "${{ matrix.distribution }}-${{ matrix.version }}"
LXDGUEST: "default-${{ matrix.distribution }}-${{ matrix.version2 }}"
steps:
- uses: actions/checkout@v3
with:
path: ${{ env.ANSIBLE_ROLE }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Environment
run: |
set -x
pwd
env
find . -ls
- name: Install lxd requirements
run: |
set -x
sudo apt-get update -qq
sudo apt-get -y install acl dnsmasq-base zfsutils-linux -q
sudo snap install lxd
whoami
grep lxd /etc/group
echo "# remote list"
sudo lxc remote list
echo "# image list"
sudo lxc image list
echo "# download image"
[ ${{ matrix.distribution }} == ubuntu ] || sudo lxc image copy images:${{ matrix.distribution }}/${{ matrix.version }}/amd64 local: --alias=${{ matrix.distribution }}-${{ matrix.version }}-nossh || true
[ ${{ matrix.distribution }} == ubuntu ] && sudo lxc image copy ubuntu:${{ matrix.version }} local: --alias=${{ matrix.distribution }}-${{ matrix.version }} || true
echo "# image list"
sudo lxc image list
## configure network
ifconfig -a || true
ip addr || true
sudo lxc info
sudo lxc network list
sudo lxc network create lxdbr0
sudo lxc network show lxdbr0
sudo lxc network attach-profile lxdbr0 default ens4
sudo lxc profile device get default ens4 nictype || true
sudo service lxd restart || true
ps ax | grep dnsmasq
systemctl status -l --no-pager lxd || true
cat /etc/network/interfaces.d/50-cloud-init.cfg || true
sudo lxc network list
# configure storage pool
sudo lxc storage list
sudo lxc storage create pool1 zfs
sudo lxc storage list
sudo zpool list
sudo lxc profile device add default root disk path=/ pool=pool1
sudo lxc profile show default
[ "X${{ matrix.distribution }}" == "Xcentos" ] && cd $GITHUB_WORKSPACE/$ANSIBLE_ROLE && sudo sh -x ./test/lxd/centos-ssh-image.sh ${{ matrix.version }} || true
[ "X${{ matrix.distribution }}" == "Xdebian" ] && cd $GITHUB_WORKSPACE/$ANSIBLE_ROLE && sudo sh -x ./test/lxd/debian-ssh-image.sh ${{ matrix.version }} || true
- name: Start lxd instance
run: |
set -x
sudo lxc init $LXDIMAGE $LXDGUEST
sudo lxc start $LXDGUEST
- name: Mount GITHUB_WORKSPACE in lxd
run: |
set -x
sudo lxc exec $LXDGUEST -- install -d -m 755 /tmp/workspace
sudo lxc config device add $LXDGUEST sharedworkspace disk source=$GITHUB_WORKSPACE/ path=/tmp/workspace
- name: Ansible dependencies in lxd
run: |
cd $GITHUB_WORKSPACE/$ANSIBLE_ROLE
[ -f get-dependencies.sh ] && sh -x get-dependencies.sh
sudo lxc exec $LXDGUEST -- "{ echo '[defaults]'; echo 'callbacks_enabled = profile_tasks, timer'; echo 'roles_path = ../'; echo 'ansible_python_interpreter: /usr/bin/python3'; } >> ansible.cfg"
- name: Converge
run: |
sudo lxc exec $LXDGUEST -- ansible-playbook -i localhost, --connection=local --become -vvv /tmp/workspace/$ANSIBLE_ROLE/test/integration/default/default.yml ${ANSIBLE_EXTRA_VARS}
env:
TERM: xterm-256color
- name: Idempotency run
run: |
sudo lxc exec $LXDGUEST -- "ansible-playbook -i localhost, --connection=local --become -vvv /tmp/workspace/$ANSIBLE_ROLE/test/integration/default/default.yml ${ANSIBLE_EXTRA_VARS} | tee /tmp/idempotency.log | grep -q 'changed=0.*failed=0' && (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && cat /tmp/idempotency.log && exit 0)"
- name: On failure
run: |
set -x
sudo lxc exec $LXDGUEST -- 'ansible -i inventory --connection=local -m setup localhost' || true
sudo lxc exec $LXDGUEST -- 'systemctl -l --no-pager status' || true
sudo lxc exec $LXDGUEST -- 'systemctl -l --no-pager --failed' || true
sudo lxc exec $LXDGUEST -- 'ls -l /usr/bin/ | egrep "(python|pip|ansible)"' || true
sudo lxc exec $LXDGUEST -- 'pip freeze' || true
sudo lxc exec $LXDGUEST -- 'pip3 freeze' || true
sudo lxc exec $LXDGUEST -- 'ip addr' || true
sudo lxc exec $LXDGUEST -- 'cat /etc/resolv.conf' || true
sudo lxc exec $LXDGUEST -- 'host www.google.com' || true
sudo lxc exec $LXDGUEST -- 'ping -c 1 www.google.com' || true
sudo lxc exec $LXDGUEST -- 'ping -c 1 8.8.8.8' || true
sudo lxc exec $LXDGUEST -- 'ls -l /usr/bin/php* /usr/local/bin/php*' || true
sudo lxc exec $LXDGUEST -- 'php --version' || true
sudo lxc exec $LXDGUEST -- 'ls /etc/apache2/mods-enabled/' || true
sudo lxc exec $LXDGUEST -- 'ls -l /var/www/_MISP/MISP/tests/' || true
sudo lxc exec $LXDGUEST -- 'cat /var/log/apache2/misp.local_error.log' || true
sudo lxc exec $LXDGUEST -- 'cat /var/www/_MISP/MISP/app/tmp/logs/error.log' || true
sudo lxc exec $LXDGUEST -- 'ls -lA /etc/yum.repos.d/' || true
sudo lxc exec $LXDGUEST -- 'cat /etc/yum.repos.d/CentOS-PowerTools.repo' || true
if: ${{ failure() }}
continue-on-error: true
- name: After script - python
run: |
set -x
sudo lxc exec $LXDGUEST -- 'which pip'
sudo lxc exec $LXDGUEST -- 'pip freeze'
sudo lxc exec $LXDGUEST -- 'which pip3'
sudo lxc exec $LXDGUEST -- 'pip3 install pipdeptree'
sudo lxc exec $LXDGUEST -- 'pip3 freeze'
sudo lxc exec $LXDGUEST -- 'pipdeptree -r'
sudo lxc exec $LXDGUEST -- '/var/www/_MISP/venv/bin/python --version'
sudo lxc exec $LXDGUEST -- '/var/www/_MISP/venv/bin/pip install pipdeptree'
sudo lxc exec $LXDGUEST -- '/var/www/_MISP/venv/bin/pipdeptree -r'
if: ${{ always() }}
continue-on-error: true
- name: After script - MISP files
run: |
set -x
sudo lxc exec $LXDGUEST -- 'find /var/www/_MISP/venv/ -type f | tail -500'
sudo lxc exec $LXDGUEST -- 'cat /opt/misp-modules/REQUIREMENTS'
sudo lxc exec $LXDGUEST -- '/var/www/_MISP/venv/bin/misp-modules -t'
sudo lxc exec $LXDGUEST -- 'ls -la /var/www/_MISP/MISP/'
sudo lxc exec $LXDGUEST -- 'ls -la /var/www/.cache/pip/http/'
sudo lxc exec $LXDGUEST -- 'cat /var/www/_MISP/MISP/app/Config/bootstrap.php'
sudo lxc exec $LXDGUEST -- 'ls -la /var/www/_MISP/MISP/app/tmp/cache/models/'
sudo lxc exec $LXDGUEST -- 'getfacl /var/www/_MISP/MISP/app/tmp/cache/models'
sudo lxc exec $LXDGUEST -- 'find /usr -iname "*libyara*.so"'
if: ${{ always() }}
continue-on-error: true
- name: After script - MISP error logs
run: |
set -x
sudo lxc exec $LXDGUEST -- 'cat /var/log/apache2/misp.local_access.log' || true
sudo lxc exec $LXDGUEST -- 'cat /var/log/apache2/misp.local_error.log' || true
sudo lxc exec $LXDGUEST -- 'cat /var/log/httpd/misp.local_access.log' || true
sudo lxc exec $LXDGUEST -- 'cat /var/log/httpd/misp.local_error.log' || true
sudo lxc exec $LXDGUEST -- 'cat /var/www/_MISP/MISP/app/tmp/logs/error.log' || true
sudo lxc exec $LXDGUEST -- 'cat /var/www/_MISP/MISP/app/tmp/logs/debug.log' || true
if: ${{ always() }}
continue-on-error: true
- name: After script - redis logs
run: |
set -x
sudo lxc exec $LXDGUEST -- 'ls -lA /var/log/redis/' || true
sudo lxc exec $LXDGUEST -- 'cat /var/log/redis/redis.log' || true
sudo lxc exec $LXDGUEST -- 'cat /var/log/redis/redis-server.log' || true
if: ${{ always() }}
continue-on-error: true
- name: After script - curl
run: |
sudo lxc exec $LXDGUEST -- 'curl -vk http://localhost:6666'
if: ${{ always() }}
continue-on-error: true
- name: After script - PyMISP
run: |
sudo lxc exec $LXDGUEST -- 'cd /var/www/_MISP/MISP/PyMISP/examples && /var/www/_MISP/venv/bin/python /var/www/_MISP/MISP/PyMISP/examples/users_list.py'
if: ${{ always() }}
continue-on-error: true
- name: After script - system
run: |
set -x
sudo lxc exec $LXDGUEST -- 'netstat -anp' || true
sudo lxc exec $LXDGUEST -- 'ss -nlp' || true
sudo lxc exec $LXDGUEST -- 'systemctl -l --no-pager status apache2' || true
sudo lxc exec $LXDGUEST -- 'systemctl -l --no-pager status redis' || true
sudo lxc exec $LXDGUEST -- 'systemctl -l --no-pager status httpd' || true
sudo lxc exec $LXDGUEST -- 'systemctl -l --no-pager status httpd-init' || true
sudo lxc exec $LXDGUEST -- 'systemctl -l --no-pager status' || true
if: ${{ always() }}
continue-on-error: true
- name: After script - journalctl
run: |
sudo lxc exec $LXDGUEST -- 'journalctl -xe --no-pager' || true
if: ${{ always() }}
continue-on-error: true
- name: After script - redhat
run: |
sudo lxc exec $LXDGUEST -- 'sudo dnf repolist' || true
sudo lxc exec $LXDGUEST -- 'find /etc/yum.repos.d/ -exec cat {} \;' || true
if: ${{ always() }}
continue-on-error: true
- name: After script - mysql
run: |
sudo lxc exec $LXDGUEST -- 'mysql -e "SHOW TABLES" misp' || true
sudo lxc exec $LXDGUEST -- 'mysql -e "SELECT * from users;" misp' || true
if: ${{ always() }}
continue-on-error: true
- name: After script - php
run: |
set -x
sudo lxc exec $LXDGUEST -- 'which php' || true
sudo lxc exec $LXDGUEST -- '`which php` --version' || true
sudo lxc exec $LXDGUEST -- 'which php7.4' || true
sudo lxc exec $LXDGUEST -- 'ls -lF /usr/bin/php* /usr/local/bin/php*' || true
sudo lxc exec $LXDGUEST -- 'dpkg -L php' || true
sudo lxc exec $LXDGUEST -- 'dpkg -L php7.4' || true
if: ${{ always() }}
continue-on-error: true
- name: After script - misp
run: |
set -x
sudo lxc exec $LXDGUEST -- 'sudo -u www-data /var/www/_MISP/MISP/app/Console/cake Admin securityAudit' || true
sudo lxc exec $LXDGUEST -- 'sudo -u www-data /var/www/_MISP/MISP/app/Console/cake Admin configLint' || true
sudo lxc exec $LXDGUEST -- 'sudo -u www-data /var/www/_MISP/MISP/app/Console/cake Admin live' || true
if: ${{ always() }}
continue-on-error: true