forked from juju4/ansible-ipv6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
217 lines (208 loc) · 15.2 KB
/
.travis.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
---
dist: xenial
sudo: required
rvm:
- 2.6
env:
- distribution: centos
version: 8
suite: default
ansible_version: 2.9.1
- distribution: centos
version: 7
suite: default
ansible_version: 2.9.1
# - distribution: centos
# version: 6
# suite: default
- distribution: ubuntu
version: 18.04
suite: default
ansible_version: 2.9.1
- distribution: ubuntu
version: 16.04
suite: default
ansible_version: 2.9.1
- distribution: alpine
version: edge
suite: default
ansible_version: 2.9.1
- distribution: debian
version: 10
suite: default
ansible_version: 2.9.1
# past ansible version
- distribution: ubuntu
version: 18.04
suite: default
ansible_version: 2.8.7
before_install:
- env
- pwd
- find -ls
## use appropriate role path and not github name
- "[ -f get-dependencies.sh ] && sh -x get-dependencies.sh"
- echo "deb http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse" | sudo tee /etc/apt/sources.list.d/xenial-backports.list
- sudo apt-get update -qq
- sudo apt -t xenial-backports -y install lxd acl dnsmasq-base zfsutils-linux rng-tools -q
## change of group implies logout+login to apply... can't do with travis = run as root (sic) = use 'newgrp lxd' ? = travis stalling all ...
## https://github.com/travis-ci/travis-ci/issues/1839 or chain: sudo -E su $USER -c "..."
- sudo usermod -G lxd travis
# - newgrp lxd
# Pull container
- sudo -E su $USER -c "lxc remote list"
- sudo -E su $USER -c "lxc image list"
## pre-download base images
- 'sudo -E su $USER -c "[ ${distribution} == ubuntu ] || lxc image copy images:${distribution}/${version}/amd64 local: --alias=${distribution}-${version}-nossh"'
- 'sudo -E su $USER -c "[ ${distribution} == alpine ] && lxc image copy images:${distribution}/${version}/amd64 local: --alias=${distribution}-${version}" || true'
- 'sudo -E su $USER -c "[ ${distribution} == debian ] && lxc image copy images:${distribution}/${version}/amd64 local: --alias=${distribution}-${version}" || true'
- 'sudo -E su $USER -c "[ ${distribution} == ubuntu ] && lxc image copy ubuntu:${version} local: --alias=${distribution}-${version}" || true'
- sudo -E su $USER -c "lxc image list"
## configure network
- ifconfig -a
- 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
- ps ax | grep dnsmasq
- systemctl status -l --no-pager lxd || true
- cat /etc/network/interfaces.d/50-cloud-init.cfg
- 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
## ssh key for lxd_cli ?
- ls ~/.ssh
- ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa -P ""
- ssh-agent
## sudo/su get us a non-usual PATH ...
- '[ "X${distribution}" == "Xcentos" ] && sudo -E su $USER -c "sh -x ./test/lxd/centos-ssh-image.sh ${version}" || true'
- sudo -E su $USER -c "lxc launch ${distribution}-${version} run-${distribution}-${version//./}"
# - sudo -E su $USER -c "lxc start run-${distribution}-${version//./}"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- env"
- '[ "X${distribution}" != "Xalpine" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- dhclient eth0" || true'
# - echo "iface eth0 inet dhcp" > /tmp/interfaces
# - '[ "X${distribution}" == "Xalpine" ] && sudo -E su $USER -c "lxc file push /tmp/interfaces run-${distribution}-${version//./}/etc/network/interfaces" || true'
- '[ "X${distribution}" == "Xalpine" -o "X${distribution}" == "Xdebian" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- /etc/init.d/networking restart" || true'
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- /sbin/ip addr || true"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- /sbin/route -n || true"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ping -c 1 8.8.8.8 || true"
- '[ "X${distribution}" == "Xubuntu" -o "X${distribution}" == "Xdebian" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- apt-get update" || true'
- '[ "X${distribution}" == "Xubuntu" -o "X${distribution}" == "Xdebian" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- apt-get -y install python python-apt aptitude python-pip libssl-dev python-dev libffi-dev iputils-ping curl" || true'
- '[ "X${distribution}" == "Xcentos" -a "X${version}" == "X6" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- rpm -iUvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm" || true'
- '[ "X${distribution}" == "Xcentos" -a "X${version}" == "X7" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- rpm -iUvh https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-12.noarch.rpm" || true'
- '[ "X${distribution}" == "Xcentos" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- yum update" || true'
- '[ "X${distribution}" == "Xcentos" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- yum -y install python python2-pip openssl-devel python-devel libffi-devel \"@Development tools\"" || true'
- '[ "X${distribution}" == "Xcentos" -a "X${version}" == "X8" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- dnf -y install python3 python3-pip openssl-devel python36-devel libffi-devel \"@Development tools\"" || true'
- '[ "X${distribution}" == "Xcentos" -a "X${version}" == "X8" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ln -s /usr/bin/pip3 /usr/bin/pip" || true'
- '[ "X${distribution}" == "Xalpine" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- apk update" || true'
- '[ "X${distribution}" == "Xalpine" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- apk add python3 python3-dev openssl openssl-dev libffi-dev alpine-sdk ansible bash" || true'
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- pip install --upgrade pip" || true
- '[ "X${distribution}" == "Xalpine" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- pip3 install ansible-lint" || true'
- '[ "X${distribution}" == "Xalpine" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- install -d -m 777 /dev/shm" || true'
- '[ "X${distribution}" == "Xalpine" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- mount -t tmpfs shm /dev/shm -o mode=1777,nosuid,nodev" || true'
- '[ "X${distribution}" == "Xalpine" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ln -s /usr/bin/python3 /usr/bin/python" || true'
# - sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- pip --version"
- '[ "X${distribution}" != "Xalpine" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- pip install ansible==${ansible_version}" || true'
- '[ "X${distribution}" != "Xalpine" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- pip install ansible-lint" || true'
# - sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ansible --version"
- "echo localhost > inventory"
## enable ansible profiling (https://github.com/jlafon/ansible-profile)
- head -2 ./test/vagrant/ansible.cfg > /tmp/ansible.cfg
- sudo -E su $USER -c "lxc file push /tmp/ansible.cfg run-${distribution}-${version//./}/root/"
- sudo -E su $USER -c "lxc file push inventory run-${distribution}-${version//./}/root/"
## these lines are necessary so lxc mount is read-write, https://github.com/lxc/lxd/issues/1879
- chmod -R go+w $PWD
## OR
- sudo -E su $USER -c "lxc config show run-${distribution}-${version//./}"
## FIXME! awk extraction is working in shell but not in travis... relying on global chmod as test ephemeral environment. DON'T USE IN PRODUCTION!
- sudo -E su $USER -c "lxc config show run-${distribution}-${version//./} | awk -F'[\":,]' '/Hostid/ { print $13 }'"
- sudo -E su $USER -c "lxc config show run-${distribution}-${version//./} | sed -ne '/idmap.next/ s/.*\"Hostid\":\([0-9]*\),.*/\1/p'"
# - CUID=`sudo -E su $USER -c "lxc config show run-${distribution}-${version//./} | awk -F'[\":,]' '/idmap.next.*Hostid/ { print $13 }'"`
- CUID=`sudo -E su $USER -c "lxc config show run-${distribution}-${version//./} | sed -ne '/idmap.next/ s/.*\"Hostid\":\([0-9]*\),.*/\1/p'"`
- "echo setfacl -Rm user:$CUID:rwx ${PWD%/*}"
- "setfacl -Rm \"user:$CUID:rwx\" ${PWD%/*} || true"
- sudo -E su $USER -c "lxc config device add run-${distribution}-${version//./} sharedroles disk path=/etc/ansible/roles source=${PWD%/*}"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- mount"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- pwd"
# - sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- systemctl -l --no-pager status networking"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ip addr"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ip route"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- cat /etc/resolv.conf"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ping -c 1 8.8.8.8"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ping -c 1 www.google.com"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- curl -v https://packages.chef.io/"
script:
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ansible-playbook -i inventory --syntax-check /etc/ansible/roles/juju4.ipv6/test/integration/${suite}/default.yml"
- '[ "X${distribution}" != "Xalpine" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ansible-lint /etc/ansible/roles/juju4.ipv6/tasks/main.yml" || true'
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ansible-playbook -i inventory --connection=local --become -vv /etc/ansible/roles/juju4.ipv6/test/integration/${suite}/default.yml ${ansible_extra_vars}"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ansible-playbook -i inventory --connection=local --become /etc/ansible/roles/juju4.ipv6/test/integration/${suite}/default.yml ${ansible_extra_vars}" > /tmp/idempotency.log
## known fail
- "grep -q 'changed=0.*failed=0' /tmp/idempotency.log && (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && cat /tmp/idempotency.log && exit 0)"
- '[ "X${distribution}" != "Xalpine" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- /etc/ansible/roles/juju4.ipv6/test/integration/${suite}/serverspec/run-local-tests.sh" || true'
after_failure:
# Check what happened on systemd systems.
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- systemctl -l --no-pager status"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- systemctl -l --no-pager --failed"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- journalctl -xe --no-pager"
- sudo -E su $USER -c "lxc list"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ls -l /usr/bin/ | egrep '(python|pip|ansible)'"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- pip freeze"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- pip3 freeze"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- systemctl -l --no-pager status networking"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ip addr"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ip route"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- cat /etc/resolv.conf"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ping -c 1 8.8.8.8"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ping -c 1 www.google.com"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- curl -v https://packages.chef.io/"
- ip addr
- ip route
- cat /etc/resolv.conf
- host www.google.com
- ping -c 1 www.google.com
- ping -c 1 8.8.8.8
- curl -v https://packages.chef.io/
after_script:
# - sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- /opt/inspec/bin/inspec exec /etc/ansible/roles/juju4.ipv6/test/integration/${suite}/inspec --attrs /etc/ansible/roles/juju4.ipv6/test/integration/${suite}/inspec/profile-attributes.yml | tee /tmp/inspec.log"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- systemctl -l --no-pager status iptables"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- systemctl -l --no-pager status netfilter-persistent"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- cat /etc/iptables/rules.v4 /etc/sysconfig/iptables /etc/iptables.conf"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- iptables -L -vn"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- iptables-save"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ip6tables -L -vn"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ip6tables-save"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- cat /proc/cmdline"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- sysctl -a |grep ipv6"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- cat /etc/modprobe.d/blacklist.conf"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- cat /etc/modprobe.conf"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- cat /etc/sysconfig/network"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ls /etc/init.d/"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ls /usr/lib/systemd/system/"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ps axuw"
- '[ "X${distribution}" == "Xalpine" ] && sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- rc-status" || true'
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ansible -i inventory --connection=local -m setup localhost"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ip addr"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ip route"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- cat /etc/resolv.conf"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ping -c 1 8.8.8.8"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- ping -c 1 www.google.com"
- sudo -E su $USER -c "lxc exec run-${distribution}-${version//./} -- curl -v https://packages.chef.io/"
- ip addr
- ip route
- cat /etc/resolv.conf
- host www.google.com
- ping -c 1 www.google.com
- ping -c 1 8.8.8.8
- curl -v https://packages.chef.io/
# Clean up
- sudo -E su $USER -c "lxc stop run-${distribution}-${version//./} --force"
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/