forked from kronosnet/ci-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci-setup-anvil-bm
executable file
·117 lines (105 loc) · 3.13 KB
/
ci-setup-anvil-bm
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
#!/bin/sh
set -e
cat <<EOF> /etc/yum.repos.d/anvil-ci-tools.repo
[anvil-ci-tools]
name=Anvil CI Tools
baseurl=http://anvil-ci-repo.ci.alteeve.com/ci-repo/
enabled=1
module_hotfixes=1
gpgcheck=0
EOF
yum clean all
yum install -y java-11-openjdk-headless
yum install -y qemu-img qemu-kvm libvirt virt-install lftp fence-virtd-libvirt fence-virtd-tcp postgresql ansible cloud-utils cloud-utils-growpart neo4j simengine-core
systemctl stop neo4j
systemctl enable neo4j
systemctl start neo4j
systemctl enable simengine-core
## VIRT SETUP
# enable nested virt
if [ ! -f /etc/modprobe.d/netsted_virt.conf ]; then
systemctl stop libvirtd
rmmod kvm-intel
echo 'options kvm-intel nested=y' > /etc/modprobe.d/netsted_virt.conf
modprobe kvm-intel
fi
if [ "$(cat /sys/module/kvm_intel/parameters/nested)" != Y ]; then
echo "WARNING!!! FAILED TO ENABLE NESTED VIRTUALIZATION!"
fi
# setup networking
systemctl start libvirtd
systemctl enable libvirtd
if [ -n "$(virsh net-list --all --name | grep default)" ]; then
virsh net-destroy default || true
virsh net-undefine default || true
fi
tmpfile=$(mktemp)
macbase=0
ifnbase=122
for i in ifn1 ifn2 bcn1 bcn2 sn1 sn2; do
if [ -z "$(virsh net-list --all --name | grep ${i}_bridge1)" ]; then
echo "Creating libvirt network interface ${i}_bridge1"
uuid=$(uuidgen)
cat > $tmpfile << EOF
<network>
<name>${i}_bridge1</name>
<uuid>${uuid}</uuid>
<bridge name='${i}_bridge1' stp='on' delay='0'/>
<domain name='${i}_bridge1'/>
<mac address='52:54:${macbase}:e1:ac:a2'/>
EOF
case ${i} in
ifn*)
cat >> $tmpfile << EOF
<forward mode='nat'/>
<ip address='192.168.$ifnbase.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.$ifnbase.128' end='192.168.$ifnbase.254'/>
</dhcp>
</ip>
EOF
;;
bcn1)
cat >> $tmpfile << EOF
<ip address='10.201.2.1' netmask='255.255.0.0'/>
<ip address='10.201.2.2' netmask='255.255.0.0'/>
<ip address='10.201.3.1' netmask='255.255.0.0'/>
<ip address='10.201.3.2' netmask='255.255.0.0'/>
<ip address='10.201.3.3' netmask='255.255.0.0'/>
<ip address='10.201.11.1' netmask='255.255.0.0'/>
<ip address='10.201.11.2' netmask='255.255.0.0'/>
<ip address='10.201.11.3' netmask='255.255.0.0'/>
EOF
;;
esac
echo "</network>" >> $tmpfile
virsh net-define $tmpfile
virsh net-autostart ${i}_bridge1
virsh net-start ${i}_bridge1
fi
macbase=$((macbase + 1))
ifnbase=$((ifnbase + 100))
done
rm -f $tmpfile
# fence_virtd
firewall-cmd --zone=libvirt --add-port=1229/tcp
firewall-cmd --zone=libvirt --permanent --add-port=1229/tcp
# required by simengine to access UPS/PDU and BMCs
firewall-cmd --zone=libvirt --add-port=161/udp
firewall-cmd --zone=libvirt --permanent --add-port=161/udp
firewall-cmd --zone=libvirt --add-port=623/udp
firewall-cmd --zone=libvirt --permanent --add-port=623/udp
firewall-cmd --reload
if ! grep -q ifn1 /etc/fence_virt.conf; then
sed -i \
-e 's#virbr0#ifn1_bridge1#g' \
-e 's#multicast#tcp#g' \
-e 's#225.0.0.12#192.168.122.1#g' \
/etc/fence_virt.conf
fi
if [ ! -f /etc/cluster/fence_xvm.key ]; then
mkdir -p /etc/cluster/
dd if=/dev/zero of=/etc/cluster/fence_xvm.key bs=4096 count=1
fi
systemctl start fence_virtd
systemctl enable fence_virtd