-
Notifications
You must be signed in to change notification settings - Fork 0
/
ospdirectorinstall.sh
166 lines (149 loc) · 9.15 KB
/
ospdirectorinstall.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
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
#!/bin/bash
######## RHN CONFIG ######################################################
RHNUSER=YOURUSER
RHNPASSWORD=YOURPASSWORD
POOLID=YOURPOOLID
######## HOSTNAME CONFIG #################################################
MGMT_IP=192.168.1.34
FQDN=ospdirector.local.domb.com
SHORT=ospdirector
######## Stack User Password #############################################
PASSWD=redhat
######## undercloud.conf #################################################
# IP information for the interface on the Undercloud that will be
# handling the PXE boots and DHCP for Overcloud instances. The IP
# portion of the value will be assigned to the network interface
# defined by local_interface, with the netmask defined by the prefix
# portion of the value. (string value)
LOCAL_IP=192.168.2.2/24
# Network gateway for the Neutron-managed network for Overcloud
# instances. This should match the local_ip above when using
# masquerading. (string value)
NETWORK_GATEWAY=192.168.2.1
# Virtual IP address to use for the public endpoints of Undercloud
# services. Only used if undercloud_service_certficate is set.
UNDERCLOUD_PUBLIC_VIP=192.168.2.3
# Virtual IP address to use for the admin endpoints of Undercloud
# services. Only used if undercloud_service_certficate is set.
UNDERCLOUD_ADMIN_VIP=192.168.2.4
# Certificate file to use for OpenStack service SSL connections.
# Setting this enables SSL for the OpenStack API endpoints, leaving it
UNDERCLOUD_SERVICE_CERTIFICATE=undercloud.pem
# Network interface on the Undercloud that will be handling the PXE
# boots and DHCP for Overcloud instances. (string value)
LOCAL_IFACE=enp2s4
# Virtual IP address to use for the public endpoints of Undercloud
# Network CIDR for the Neutron-managed network for Overcloud
# instances. This should be the subnet used for PXE booting.
NETWORK_CIDR=192.168.2.0/24
# Network that will be masqueraded for external access, if required.
# This should be the subnet used for PXE booting. (string value)
MASQUERADE_NETWORK=192.168.2.0/24
# Start of DHCP allocation range for PXE and DHCP of Overcloud
# instances. (string value)
DHCP_START=192.168.2.80
# End of DHCP allocation range for PXE and DHCP of Overcloud
# instances. (string value)
DHCP_END=192.168.2.104
# Network interface on which discovery dnsmasq will listen. If in
# doubt, use the default value. (string value)
INSPECTION_INTERFACE=br-ctlplane
# Temporary IP range that will be given to nodes during the discovery
# process. Should not overlap with the range defined by dhcp_start
# and dhcp_end, but should be in the same network. (string value)
INSPECTION_IP_START=192.168.2.200
INSPECTION_IP_END=192.168.2.220
# Whether to enable extra hardware collection during the inspection
# process. Requires python-hardware or python-hardware-detect package
# on the introspection image.
INSPECTION_EXTRAS=true
# Whether to run benchmarks when discovering nodes. (boolean value)
INSPECTION_RUNBENCH_BOOL=false
# Whether to enable the debug log level for Undercloud OpenStack
# services. (boolean value)
UNDERCLOUD_DEBUG_BOOL=true
# Whether to install Tempest in the Undercloud. (boolean value)
ENABLE_TEMPEST=false
# Whether to use iPXE for deploy by default. (boolean value)
IPXE_DEPLOY=true
# Whether to store events in the Undercloud Ceilometer. (boolean
# value)
STORE_EVENTS=false
# Maximum number of attempts the scheduler will make when deploying
# the instance. You should keep it greater or equal to the number of
# bare metal nodes you expect to deploy at once to work around
# potential race condition when scheduling. (integer value)
# Minimum value: 1
SCHEDULER_MAX_ATTEMPTS=30
############################################################################
echo $"
___ ____ ____ _ _ _ ___
/ _ \/ ___|| _ \ __| (_)_ __ ___ ___| |_ ___ _ __ ( _ )
| | | \___ \| |_) / _ | | __/ _ \/ __| __/ _ \| __| / _ \
| |_| |___) | __/ (_| | | | | __/ (__| || (_) | | | (_) |
\___/|____/|_| \__ _|_|_| \___|\___|\__\___/|_| \___/
_ _ _ _
(_)_ __ ___| |_ __ _| | | ___ _ __
| | _ \/ __| __/ _ | | |/ _ \ __|
| | | | \__ \ || (_| | | | __/ |
|_|_| |_|___/\__\__ _|_|_|\___|_|
+-+-+ +-+-+-+-+-+-+-+ +-+-+-+-+
|b|y| |L|a|u|r|e|n|t| |D|o|m|b|
+-+-+ +-+-+-+-+-+-+-+ +-+-+-+-+
"
echo "Creating user stack"
useradd stack
echo $PASSWD | passwd stack --stdin
echo "stack ALL=(root) NOPASSWD:ALL" | tee -a /etc/sudoers.d/stack
chmod 0440 /etc/sudoers.d/stack
echo -e "$MGMT_IP\t\t$FQDN\t$SHORT" >> /etc/hosts
hostnamectl set-hostname $FQDN
hostnamectl set-hostname --transient $FQDN
echo "net.ipv4.ip_forward = 1" > /etc/sysctl.d/99-ipforward.conf
sysctl -p /etc/sysctl.d/99-ipforward.conf
echo "Registering System"
subscription-manager register --username=$RHNUSER --password=$RHNPASSWORD
subscription-manager attach --pool=$POOLID
subscription-manager repos --disable='*'
subscription-manager repos --enable=rhel-7-server-rpms --enable=rhel-7-server-extras-rpms --enable=rhel-7-server-openstack-8-rpms --enable=rhel-7-server-openstack-8-director-rpms --enable rhel-7-server-rh-common-rpms
echo "Updating system"
yum install screen libguestfs-tools-c -y && update -y
mkdir -p /home/stack/{images,templates}
chown -R stack.stack /home/stack
echo "Installing yum install -y python-tripleoclient python-hardware python-hardware-detect screen"
sudo -H -u stack bash -c 'sudo yum install -y python-tripleoclient python-hardware python-hardware-detect screen'
sudo -H -u stack bash -c 'sudo cp /usr/share/instack-undercloud/undercloud.conf.sample ~/undercloud.conf'
chown -R stack.stack /home/stack/undercloud.conf
cd /home/stack
#echo "Create Certs"
#openssl genrsa -out privkey.pem 2048
#sudo openssl req -new -x509 -key privkey.pem -out cacert.pem -days 365
#cat /home/stack/cacert.pem privkey.pem > /home/stack/undercloud.pem
#chown stack.stack /home/stack/{undercloud.pem,cacert.pem,privkey.pem}
#cp /home/stack/undercloud.pem /etc/pki/instack-certs/
#semanage fcontext -a -t haproxy_exec_t "/etc/pki/instack-certs(/.*)?"
#restorecon -Rv /etc/pki/instack-certs
echo "Modifying undercloud.conf"
sudo -H -u stack bash -c "sed -i 's|#image_path = \.|image_path = /home/stack/images|g' /home/stack/undercloud.conf"
sudo -H -u stack bash -c "sed -i 's|#local_ip = 192.0.2.1/24|local_ip = $LOCAL_IP|g' /home/stack/undercloud.conf"
#sudo -H -u stack bash -c "sed -i 's|#undercloud_public_vip = 192.0.2.2|undercloud_public_vip = $UNDERCLOUD_PUBLIC_VIP|g' /home/stack/undercloud.conf"
#sudo -H -u stack bash -c "sed -i 's|#undercloud_admin_vip = 192.0.2.3|undercloud_admin_vip = $UNDERCLOUD_ADMIN_VIP|g' /home/stack/undercloud.conf"
#sudo -H -u stack bash -c "sed -i 's|#undercloud_service_certificate =|undercloud_service_certificate = $UNDERCLOUD_SERVICE_CERTIFICATE|g' /home/stack/undercloud.conf"
sudo -H -u stack bash -c "sed -i 's|#local_interface = eth1|local_interface = $LOCAL_IFACE|g' /home/stack/undercloud.conf"
sudo -H -u stack bash -c "sed -i 's|#masquerade_network = 192.0.2.0/24|masquerade_network = $MASQUERADE_NETWORK|g' /home/stack/undercloud.conf"
sudo -H -u stack bash -c "sed -i 's|#dhcp_start = 192.0.2.5|dhcp_start = $DHCP_START|g' /home/stack/undercloud.conf"
sudo -H -u stack bash -c "sed -i 's|#dhcp_end = 192.0.2.24|dhcp_end = $DHCP_END|g' /home/stack/undercloud.conf"
sudo -H -u stack bash -c "sed -i 's|#network_cidr = 192.0.2.0/24|network_cidr = $NETWORK_CIDR|g' /home/stack/undercloud.conf"
sudo -H -u stack bash -c "sed -i 's|#network_gateway = 192.0.2.1|network_gateway = $NETWORK_GATEWAY|g' /home/stack/undercloud.conf"
sudo -H -u stack bash -c "sed -i 's|#inspection_interface = br-ctlplane|inspection_interface = $INSPECTION_INTERFACE|g' /home/stack/undercloud.conf"
sudo -H -u stack bash -c "sed -i 's|#inspection_iprange = 192.0.2.100,192.0.2.120|inspection_iprange = $INSPECTION_IP_START,$INSPECTION_IP_END|g' /home/stack/undercloud.conf"
sudo -H -u stack bash -c "sed -i 's|#inspection_extras = true|inspection_extras = $INSPECTION_EXTRAS|g' /home/stack/undercloud.conf"
sudo -H -u stack bash -c "sed -i 's|#inspection_runbench = false|inspection_runbench = $INSPECTION_RUNBENCH_BOOL|g' /home/stack/undercloud.conf"
sudo -H -u stack bash -c "sed -i 's|#undercloud_debug = true|undercloud_debug = $UNDERCLOUD_DEBUG_BOOL|g' /home/stack/undercloud.conf"
sudo -H -u stack bash -c "sed -i 's|#enable_tempest = false|enable_tempest = $ENABLE_TEMPEST|g' /home/stack/undercloud.conf"
sudo -H -u stack bash -c "sed -i 's|#ipxe_deploy = true|ipxe_deploy = $IPXE_DEPLOY|g' /home/stack/undercloud.conf"
sudo -H -u stack bash -c "sed -i 's|#store_events = false|store_events = $STORE_EVENTS|g' /home/stack/undercloud.conf"
sudo -H -u stack bash -c "sed -i 's|#scheduler_max_attempts = 30|scheduler_max_attempts = $SCHEDULER_MAX_ATTEMPTS|g' /home/stack/undercloud.conf"
su - stack
screen -S ospinstaller -dmS openstack undercloud install
screen -list