forked from redhat-cip/edeploy-roles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chef-server.install
executable file
·132 lines (120 loc) · 3.27 KB
/
chef-server.install
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
#!/bin/bash
#
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
#
# Author: Pierre Rognant <emilien.macchi@enovance.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
src="$1"
dir="$2"
version="$3"
ROLE=chef-server
ORIG=$(cd $(dirname $0); pwd)
. ${ORIG}/functions
PACKAGES="wget"
update_repositories $dir
install_packages $dir "$PACKAGES"
clear_packages_cache $dir
configure_cloudinit () {
mkdir -p ${dir}/etc/cloud/cloud.cfg.d
rm -f ${dir}/etc/cloud/cloud.cfg
PACKAGES="cloud-init"
update_repositories $dir
install_packages $dir "$PACKAGES"
clear_packages_cache $dir
cat > ${dir}/etc/cloud/cloud.cfg.d/90_dpkg.cfg << EOF
# to update this file, run dpkg-reconfigure cloud-init
datasource_list: [ NoCloud ]
EOF
cat > ${dir}/etc/cloud/cloud.cfg <<EOF
user: root
disable_root: 0
preserve_hostname: False
cloud_init_modules:
- bootcmd
- resizefs
- set_hostname
- update_hostname
- update_etc_hosts
- ca-certs
- rsyslog
- ssh
- users-groups
cloud_config_modules:
- mounts
- ssh-import-id
- locale
- set-passwords
- grub-dpkg
- apt-pipelining
- apt-update-upgrade
- landscape
- timezone
- puppet
- chef
- salt-minion
- mcollective
- disable-ec2-metadata
- runcmd
- byobu
cloud_final_modules:
- rightscale_userdata
- scripts-per-once
- scripts-per-boot
- scripts-per-instance
- scripts-user
- keys-to-console
- phone-home
- final-message
EOF
}
case $OS in
"Ubuntu")
configure_cloudinit
do_chroot ${dir} wget --no-verbose "http://www.opscode.com/chef/download-server?p=ubuntu&pv=${RELEASE}&m=x86_64&v=latest" -O /tmp/chef-server.deb
do_chroot ${dir} dpkg -i /tmp/chef-server.deb
mkdir -p ${dir}/etc/chef-server
cat > ${dir}/etc/chef-server/chef-server.rb <<EOF
server_name = node['ipaddress']
api_fqdn = server_name
nginx['url'] = "https://#{server_name}"
nginx['server_name'] = server_name
bookshelf['listen'] = '127.0.0.1'
bookshelf['vip'] = server_name
bookshelf['url'] = "https://#{server_name}"
erchef['listen'] = '127.0.0.1'
erchef['vip'] = '127.0.0.1'
lb['fqdn'] = server_name
postgresql['listen_address'] = '127.0.0.1'
postgresql['vip'] = '127.0.0.1'
chef_server_webui['vip'] = '127.0.0.1'
chef_server_webui['listen'] = '127.0.0.1'
EOF
cat > ${dir}/etc/first-boot.d/99-chef-server <<EOF
#!/bin/bash
# ensure local hostname if not stick hostname to 127.0.0.1
HOSTNAME=\`hostname -s\`
if ! \`python -c 'import socket; print socket.gethostbyname("\$HOSTNAME")' 2> /dev/null 1> /dev/null\`; then
LINE=\`cat /etc/hosts | grep ^127.0.0.1\`
NEWLINE="\$LINE \$HOSTNAME"
sed "s/\${LINE}/\${NEWLINE}/g" -i /etc/hosts
fi
# login shell required
su - -c '/usr/bin/chef-server-ctl reconfigure'
EOF
chmod 755 ${dir}/etc/rc.local ${dir}/etc/first-boot.d/99-chef-server
;;
*)
fatal_error "OS ($OS) or Release ($RELEASE) not supported"
;;
esac