-
Notifications
You must be signed in to change notification settings - Fork 0
/
manageiq.yaml
125 lines (110 loc) · 4.49 KB
/
manageiq.yaml
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
heat_template_version: 2013-05-23
description: >
This template will provision the minimum number of required nodes, as well
it will setup all of the required lbaas vips.
#parameters:
# ceilometer_api_port:
# description: The port ceilometer-api is listening on.
# type: number
# default: 8777
# constraints:
# - range:
# min: 1025
# max: 65535
# description: Must be an integer between 1025 and 65535.
resources:
miqbuilder_pass:
type: "OS::Heat::RandomString"
manageiq_server:
type: "Rackspace::Cloud::Server"
properties:
flavor: 8 GB Performance
image: CentOS 6.5
key_name: shep
user_data:
str_replace:
template: |
#!/bin/bash
# Add the miqbuilder user
useradd miqbuilder
echo "%pgsql_pass%" | passwd miqbuilder --stdin
# Install EPEL
# yum install -y epel-release
# Install required packages
yum install -y git libxml2-devel libxslt libxslt-devel sudo postgresql-server postgresql-devel memcached ruby-devel
# Start memcached
service memcached start
chkconfig memcached on
# Configure postgresql
service postgresql initdb
echo "local all all trust" > /var/lib/pgsql/data/pg_hba.conf
sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" /var/lib/pgsql/data/postgresql.conf
service postgresql start
# Create databases
tee /tmp/bootstrap_pgsql.sh <<EOF
for i in test production development;do createdb vmdb_\$i;done
psql -c "create role root login password 'smartvm'"
psql -c "alter database vmdb_development owner to root"
EOF
su -l postgres -c 'sh /tmp/bootstrap_pgsql.sh'
#rm /tmp/bootstrap_pgsql.sh
# Install rvm and bundler
yum install -y libyaml-devel libffi-devel autoconf gcc-c++ readline-devel openssl-devel automake libtool bison
tee /tmp/bootstrap_miqbuilder.sh <<EOF
curl -sSL https://get.rvm.io | bash -s stable
source /home/miqbuilder/.rvm/scripts/rvm
rvm install 1.9.3
rvm --default use 1.9.3
gem install bundler -v '1.3.5'
gem uninstall --force -i \${GEM_HOME}@global bundler -v '1.6.2'
EOF
su -l miqbuilder -c 'bash /tmp/bootstrap_miqbuilder.sh'
#rm /tmp/bootstrap_miqbuilder.sh
# Install ManageIQ
tee /tmp/bootstrap_manageiq.sh <<EOF
git clone https://github.com/ManageIQ/manageiq
pushd manageiq/vmdb
bundle install --without qpid
popd
pushd manageiq
vmdb/bin/rake build:shared_objects
popd
pushd manageiq/vmdb
bundle install --without qpid
cp config/database.pg.yml config/database.yml
bin/rake db:migrate
bin/rake evm:start
popd
EOF
su -l miqbuilder -c 'sh /tmp/bootstrap_manageiq.sh'
#rm /tmp/bootstrap_manageiq.sh
# Install and configure nginx to proxy to manageiq
yum install -y nginx
# drop a manageiq config
tee /etc/nginx/conf.d/manageiq.conf <<EOF
server {
listen 80 default_server;
server_name _;
access_log /var/log/nginx/manageiq.access.log main;
error_log /var/log/nginx/manageiq.error.log;
location / {
proxy_pass http://0.0.0.0:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Client-Verify SUCCESS;
proxy_read_timeout 1800;
proxy_connect_timeout 1800;
}
}
EOF
rm /etc/nginx/conf.d/default.conf
service nginx restart
chkconfig nginx on
# Add iptables rule for nginx
iptables -I INPUT 5 -p tcp -m conntrack --ctstate NEW -m tcp --dport 80 -j ACCEPT
params:
"%miqbuilder_pass%": { get_attr: [miqbuilder_pass, value] }
outputs:
miqbuilder_pass:
value: { get_attr: [miqbuilder_pass, value] }