-
Notifications
You must be signed in to change notification settings - Fork 2
/
Vagrantfile-debian
115 lines (96 loc) · 4.4 KB
/
Vagrantfile-debian
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
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.define "aio" do |c|
c.vm.network "forwarded_port", guest: 80, host: 8080
c.vm.network "private_network", ip: "172.28.128.3"
c.vm.network "private_network", ip: "192.168.10.3"
c.vm.provider "virtualbox" do |vb|
vb.memory = "4096"
vb.cpus = 2
end
c.vm.provision "shell", privileged: true, inline: <<-SHELL
cat >> /etc/resolv.conf <<EOF
nameserver 8.8.8.8
EOF
apt install python-pip -y
apt install \
vim \
python-dev \
python-netaddr \
python-openstackclient \
python-neutronclient \
libffi-dev \
libssl-dev \
gcc \
ansible \
bridge-utils \
docker.io -y
apt-get purge lxc lxd -y
pip install -U pip
mkdir -p /etc/systemd/system/docker.service.d
tee /etc/systemd/system/docker.service.d/kolla.conf <<-EOF
[Service]
MountFlags=shared
EOF
systemctl daemon-reload
systemctl enable docker
systemctl restart docker
pip install ansible==1.9.6
pip install kolla
cp -r /usr/local/share/kolla/etc_examples/kolla /etc/
NETWORK_INTERFACE="enp0s8"
NEUTRON_INTERFACE="enp0s9"
GLOBALS_FILE="/etc/kolla/globals.yml"
ADDRESS="$(ip -4 addr show ${NETWORK_INTERFACE} | grep "inet" | awk '{print $2}' | cut -d/ -f1)"
BASE="$(echo $ADDRESS | cut -d. -f 1,2,3)"
VIP=$(echo "${BASE}.254")
PUB_ADDRESS="$(ip -4 addr show ${NEUTRON_INTERFACE} | grep "inet" | awk '{print $2}' | cut -d/ -f1)"
PUB_BASE="$(echo $PUB_ADDRESS | cut -d. -f 1,2,3)"
sed -i "s/^kolla_internal_vip_address:.*/kolla_internal_vip_address: ${VIP}/g" ${GLOBALS_FILE}
sed -i "s/^network_interface:.*/network_interface: ${NETWORK_INTERFACE}/g" ${GLOBALS_FILE}
sed -i "s/^neutron_external_interface:.*/neutron_external_interface: ${NEUTRON_INTERFACE}/g" ${GLOBALS_FILE}
echo "${ADDRESS} `hostname`" >> /etc/hosts
mkdir -p /etc/kolla/config/nova/
tee > /etc/kolla/config/nova/nova-compute.conf <<-EOF
[libvirt]
virt_type=qemu
EOF
kolla-genpwd
sed -i -e "s/^keystone_admin_password:.*/keystone_admin_password: Koll@0penst@ck/" /etc/kolla/passwords.yml
kolla-ansible prechecks
kolla-ansible pull
kolla-ansible deploy
tee > /root/open.rc <<-EOF
export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_NAME=admin
export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=$(cat /etc/kolla/passwords.yml | grep "keystone_admin_password" | awk '{print $2}')
export OS_AUTH_URL=http://${VIP}:35357/v3
export OS_IDENTITY_API_VERSION=3
EOF
tee > /root/net_start.sh <<-EOF
source /root/openrc.sh
tenant=\\`openstack project list -f csv --quote none | grep admin | cut -d, -f1\\`
neutron net-create public --tenant-id ${tenant} --router:external --provider:network_type flat --provider:physical_network physnet1 --shared
#if segmented network{vlan,vxlan,gre}: --provider:segmentation_id \${segment_id}
neutron subnet-create public ${PUB_BASE}.0/24 --tenant-id \${tenant} --allocation-pool start=${PUB_BASE}.80,end=${PUB_BASE}.99 --dns-nameserver 8.8.8.8 --disable-dhcp
# if you need a specific route to get "out" of your public network: --host-route destination=10.0.0.0/8,nexthop=10.1.10.254
neutron net-create private --tenant-id \${tenant}
neutron subnet-create private 192.168.100.0/24 --tenant-id \${tenant} --dns-nameserver 8.8.8.8 --name private
neutron router-create pub-router --tenant-id \${tenant}
neutron router-gateway-set pub-router public
neutron router-interface-add pub-router private
# Adjust the default security group. This is not good practice
default_group=\\`neutron security-group-list | awk '/ default / {print $2}' | tail -n 1\\`
neutron security-group-rule-create --direction ingress --port-range-min 22 --port-range-max 22 --protocol tcp --remote-ip-prefix 0.0.0.0/0 \${default_group}
neutron security-group-rule-create --direction ingress --port-range-min 80 --port-range-max 80 --protocol tcp --remote-ip-prefix 0.0.0.0/0 \${default_group}
neutron security-group-rule-create --direction ingress --port-range-min 443 --port-range-max 443 --protocol tcp --remote-ip-prefix 0.0.0.0/0 \${default_group}
EOF
echo "Login using http://${VIP}/ with default as domain, admin as username, and $(cat /etc/kolla/passwords.yml | grep "keystone_admin_password" | awk '{print $2}') as password"
SHELL
end
end