-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_openstack_aio.sh
More file actions
executable file
·131 lines (115 loc) · 4.12 KB
/
install_openstack_aio.sh
File metadata and controls
executable file
·131 lines (115 loc) · 4.12 KB
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
#!/bin/bash
# ==============================================================================
# Script installs openstack-ansible all-in-one.
# ==============================================================================
# Uncomment the following line to debug this script
set -o xtrace
#=================================================
# GLOBAL VARIABLES DEFINITION
#=================================================
_original_proxy=''
_proxy=''
_domain=',.intel.com'
_branch='master'
_apply_security_hardening=false
#=================================================
# GLOBAL FUNCTIONS
#=================================================
# Error Function
function PrintError {
echo "************************" >&2
echo "* $(date +"%F %T.%N") ERROR: $1" >&2
echo "************************" >&2
exit 1
}
function PrintHelp {
echo " "
echo "Script installs openstack ansible all-in-one. Optionally uses given proxy"
echo " "
echo "Usage:"
echo "./install_openstack_aio.sh [--branch | -b master] [--proxy | -x <http://proxyserver:port>]"
echo " "
echo " --branch | -b Uses the given branch name to deploy openstack-ansible aio. Defaults to master."
echo " --proxy | -x Uses the given proxy server to install the tools."
echo " --harden | -s Makes deployment install security hardening."
echo " --help Prints current help text. "
echo " "
exit 1
}
# Ensure script is run as root
if [ "$EUID" -ne "0" ]; then
PrintError "This script must be run as root."
fi
# Set locale
locale-gen en_US
update-locale
export HOME=/root
# ============================= Processes openstack-ansible installation options ============================
# Handle file sent as parameter - from where proxy info will be retrieved.
while [[ ${1} ]]; do
case "${1}" in
--branch|-b)
if [[ -z "${2}" || "${2}" == -* ]]; then
PrintError "Missing openstack-ansible branch to deploy."
else
_branch="${2}"
fi
shift
;;
--proxy|-x)
if [[ -z "${2}" || "${2}" == -* ]]; then
PrintError "Missing proxy data."
else
_original_proxy="${2}"
if [ -f /etc/apt/apt.conf ]; then
echo "Acquire::http::Proxy \"${2}\";" >> /etc/apt/apt.conf
elif [ -d /etc/apt/apt.conf.d ]; then
echo "Acquire::http::Proxy \"${2}\";" >> /etc/apt/apt.conf.d/70proxy.conf
fi
npx="127.0.0.0/8,localhost,10.0.0.0/8,192.168.0.0/16${_domain}"
_proxy="http_proxy=${2} https_proxy=${2} no_proxy=${npx}"
_proxy="$_proxy HTTP_PROXY=${2} HTTPS_PROXY=${2} NO_PROXY=${npx}"
fi
shift
;;
--harden|-s)
_apply_security_hardening=true
;;
--help|-h)
PrintHelp
;;
*)
PrintError "Invalid Argument."
esac
shift
done
# ============================================================================================
# ISTALL PRE-REQUISITES
eval $_proxy apt-get -y -qq update
eval $_proxy apt-get -y -qq install wget
eval $_proxy wget https://raw.githubusercontent.com/dlux/InstallScripts/master/install_devtools.sh tmp_devtools.sh
chmod +x tmp_devtools.sh
if [[ ! -z $_proxy ]]; then
./tmp_devtools.sh -x "${_proxy}"
else
./tmp_devtools.sh
fi
eval $_proxy git clone https://github.com/openstack/openstack-ansible.git -b $_branch /opt/openstack-ansible
cd /opt/openstack-ansible
# ============================================================================================
# INSTALL OPENSTACK-ANSIBLE AIO
export apply_security_hardening=$_apply_security_hardening
eval $_proxy scripts/bootstrap-ansible.sh
eval $_proxy scripts/bootstrap-aio.sh
eval $_proxy scripts/run-playbooks.sh
#cd playbooks/
#eval $_proxy openstack-ansible os-tempest-install.yml
# Cleanup _proxy from apt if added - first coincedence
if [[ ! -z "${_original_proxy}" ]]; then
scaped_str=$(echo $_original_proxy | sed -s 's/[\/&]/\\&/g')
if [ -f /etc/apt/apt.conf ]; then
sed -i "0,/$scaped_str/{/$scaped_str/d;}" /etc/apt/apt.conf
elif [ -d /etc/apt/apt.conf.d ]; then
sed -i "0,/$scaped_str/{/$scaped_str/d;}" /etc/apt/apt.conf.d/70proxy.conf
fi
fi