-
Notifications
You must be signed in to change notification settings - Fork 4
/
bootstrap.sh
executable file
·140 lines (101 loc) · 4.41 KB
/
bootstrap.sh
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
#!/usr/bin/env bash
BASE_DIR="$(dirname $(readlink -f $0))"
source $BASE_DIR/include.sh
trap "set +x; add_status 'error' 'BOOTSTRAP FAILED'; sleep 90" TERM INT EXIT
set -e
set -x
export INTERACTIVE=false
if [[ -e /etc/cloud-in-a-box.env ]]; then
source /etc/cloud-in-a-box.env
else
CLOUD_IN_A_BOX_TYPE=${1:-sandbox}
echo "CLOUD_IN_A_BOX_TYPE=$CLOUD_IN_A_BOX_TYPE" | sudo tee /etc/cloud-in-a-box.env
fi
wait_for_uplink_connection "https://scs.community"
apt-get update
apt-get install -y python3-virtualenv python3-venv sshpass jq
default_gateway_interface="$(get_ethernet_interface_of_default_gateway)"
get_default_gateway_settings
cp /opt/cloud-in-a-box/environments/kolla/certificates/ca/cloud-in-a-box.crt /usr/local/share/ca-certificates/
update-ca-certificates
find /opt/cloud-in-a-box -type f -not -name "*.sh" -exec sed -i "s/eno1/${default_gateway_interface}/g" {} +
pushd /opt/cloud-in-a-box/environments/manager
./run.sh operator \
-e ansible_ssh_pass=password \
-e ansible_ssh_user=osism \
-e ansible_become_password=password
export INSTALL_ANSIBLE_ROLES=false
./run.sh network
# Apply network changes without rebooting
netplan apply
# Ensure the APT cache is always up to date
apt-get update
./run.sh bootstrap
# Hackish workaround for initial permission denied issues
chmod o+rw /var/run/docker.sock
./run.sh configuration
find /opt/configuration -type f -exec sed -i "s/eno1/${default_gateway_interface}/g" {} +
if [[ $CLOUD_IN_A_BOX_TYPE == "sandbox" ]]; then
# Deploy netbox service
./run.sh netbox
# Deploy traefik service
./run.sh traefik
elif [[ $CLOUD_IN_A_BOX_TYPE == "edge" ]]; then
# Disable netbox integration
./disable-netbox.sh
# Deploy traefik service
./run.sh traefik
elif [[ $CLOUD_IN_A_BOX_TYPE == "kubernetes" ]]; then
# Disable netbox integration
./disable-netbox.sh
# Disable ara service
./disable-ara.sh
# Disable openstack integration
echo "manager_enable_openstack: false" >> /opt/cloud-in-a-box/environments/manager/configuration.yml
echo "manager_enable_openstack: false" >> /opt/configuration/environments/manager/configuration.yml
# Disable flower service
sed -i "/flower_enable:/d" /opt/cloud-in-a-box/environments/manager/configuration.yml
sed -i "/flower_enable:/d" /opt/configuration/environments/manager/configuration.yml
# Disable ceph & kolla ansible containers for the initial deployment
echo "enable_ceph_ansible: false" >> /opt/cloud-in-a-box/environments/manager/configuration.yml
echo "enable_kolla_ansible: false" >> /opt/cloud-in-a-box/environments/manager/configuration.yml
# Disable ceph & kolla ansible containers for upgrades
echo "enable_ceph_ansible: false" >> /opt/configuration/environments/manager/configuration.yml
echo "enable_kolla_ansible: false" >> /opt/configuration/environments/manager/configuration.yml
# Use latest manager
sed -i "s/manager_version: .*/manager_version: latest/g" /opt/cloud-in-a-box/environments/manager/configuration.yml
sed -i "s/manager_version: .*/manager_version: latest/g" /opt/configuration/environments/manager/configuration.yml
pushd /opt/cloud-in-a-box
make sync
cp /opt/cloud-in-a-box/environments/manager/images.yml /opt/configuration/environments/manager/images.yml
chown dragon:dragon /opt/configuration/environments/manager/images.yml
popd
fi
./run.sh pull
./run.sh manager
popd
# In some configurations, the manager service is currently not coming up properly.
# We therefore perform another explicit restart of the manager service here.
systemctl restart docker-compose@manager
# Wait for the osism-ansible service
wait_for_container_healthy 60 osism-ansible
if [[ $CLOUD_IN_A_BOX_TYPE != "kubernetes" ]]; then
# Wait for the ceph-ansible service
wait_for_container_healthy 60 ceph-ansible
# Wait for the kolla-ansible service
wait_for_container_healthy 60 kolla-ansible
fi
# wait for the osismclient service
wait_for_container_running 60 osismclient
# Gather facts to ensure that the addresses of the new VLAN devices
# are in the facts cache
osism apply facts
osism apply bootstrap
# Restart the manager services to update the /etc/hosts file
docker compose -f /opt/manager/docker-compose.yml restart
if [[ $CLOUD_IN_A_BOX_TYPE != "kubernetes" ]]; then
# Wait for the manager service
wait_for_container_healthy 60 manager-ara-server-1
fi
trap "" TERM INT EXIT
add_status "info" "BOOTSTRAP COMPLETE"