-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup-region-via-ssh.bash
117 lines (100 loc) · 3.7 KB
/
setup-region-via-ssh.bash
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/bash
#
# This script is executed inside the maas-region-controller container
# once it is setup by setup-dev-env.sh
#
# stop execution/exit on error
set -e
container_ip=$(hostname -I | cut -d' ' -f1)
gateway_ip=$(hostname -I | cut -d' ' -f1)
control_network_prefix=${MAAS_CONTROL_IP_RANGE%.*}
kvm_network_prefix=${MAAS_MANAGEMENT_IP_RANGE%.*}
echo "${container_ip} ${gateway_ip} ${control_network_prefix} ${kvm_network_prefix}"
echo
echo "######################################"
echo "Installing make and MAAS dependencies."
sudo apt-get install make
cd /work
make install-dependencies
echo
echo "##########################################################"
echo "Setting up the second interface (no dhcp one) to talk home"
sudo tee /etc/netplan/99-maas-kvm-net.yaml <<EOF
network:
version: 2
ethernets:
eth1:
addresses:
- ${kvm_network_prefix}.2/24
EOF
sudo netplan apply
echo
echo "############################################"
echo "Disabling postgres, nginx and dhcp services."
sudo systemctl stop named postgresql nginx isc-dhcp-server
sudo systemctl disable named postgresql nginx isc-dhcp-server
echo
echo "#################################"
echo "Installing the MAAS test database"
sudo snap install maas-test-db --channel=latest/edge
echo
echo "#######################"
echo "Unpacking the snap tree"
sudo snap try dev-snap/tree
echo
echo "##########################"
echo "Connecting snap interfaces"
./utilities/connect-snap-interfaces
echo
echo "####################################"
echo "Installing and running the MAAS snap"
make
make snap-tree-sync
sudo snap restart maas
echo
echo "#######################"
echo "Generating offline docs"
make doc
echo
echo "#####################"
echo "Starting the database"
sudo maas init region+rack --maas-url="http://${container_ip}:5240/MAAS" --database-uri maas-test-db:///
echo
echo "##########################"
echo "Creating a MAAS admin user"
sudo maas createadmin --username maas --password maas --email maas@example.com
echo
echo "###########################"
echo "Login using admin profile"
maas login admin "http://${container_ip}:5240/MAAS/api/2.0/" $(sudo maas apikey --username=maas)
echo
echo "###############################"
echo "Starting DHCP on second network"
rack_controllers=$(maas admin rack-controllers read)
target_rack_controller=$(echo $rack_controllers | jq --raw-output .[].system_id)
target_fabric_id=$(echo $rack_controllers | jq '.[].interface_set[].links[] | select(.subnet.name | startswith('\"$kvm_network_prefix.\"')) | .subnet.vlan.fabric_id')
maas admin subnet update ${kvm_network_prefix}.0/24 gateway_ip=${kvm_network_prefix}.1
export ip_range=$(maas admin ipranges create type=dynamic start_ip=${kvm_network_prefix}.99 end_ip=${kvm_network_prefix}.254 comment='To enable dhcp')
maas admin vlan update $target_fabric_id untagged dhcp_on=True primary_rack=$target_rack_controller
echo
echo "#############################"
echo "Adding your hosts lxd to MAAS"
maas admin vm-hosts create type=lxd power_address=${control_network_prefix}.1 project=maas name=maas-host
echo
echo "#################################################################"
echo "We are done! You should have a running MAAS installation!"
echo
echo " please go to http://${container_ip}:5240 and finish the setup"
echo " username: maas"
echo " password: maas"
echo
echo "To complete the setup point your browser to"
echo " http://${container_ip}:5240/MAAS/r/kvm/lxd"
echo "and do to maas-host -> KVM host settings -> Download certificate."
echo "Install the certificate to your local lxd with:"
echo " lxc config trust add <path/to/maas-host@...>"
echo "Go back to your browser and click 'Refresh host'"
echo
echo "Have fun developing MAAS"
echo
echo