|
1 | 1 | #!/bin/bash -xe |
2 | 2 | sysctl -w kernel.shmmax=17179869184 |
3 | | -/opt/chef-server/embedded/bin/runsvdir-start & |
4 | | -/usr/local/bin/reconfigure_chef.sh |
5 | | -hostname=`hostname` |
6 | | -cat > /var/opt/chef-server/nginx/etc/chef_https_lb.conf << EOL |
7 | | -server { |
8 | | - listen $CHEF_PORT; |
9 | | - server_name $hostname; |
10 | | - access_log /var/log/chef-server/nginx/access.log opscode; |
11 | | -
|
12 | | - ssl on; |
13 | | - ssl_certificate /var/opt/chef-server/nginx/ca/${hostname}.crt; |
14 | | - ssl_certificate_key /var/opt/chef-server/nginx/ca/${hostname}.key; |
15 | | -
|
16 | | - ssl_session_timeout 5m; |
17 | | -
|
18 | | - ssl_protocols SSLv3 TLSv1; |
19 | | - ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA; |
20 | | - ssl_prefer_server_ciphers on; |
21 | | -
|
22 | | - root /var/opt/chef-server/nginx/html; |
23 | | -
|
24 | | - client_max_body_size 250m; |
25 | | -
|
26 | | - proxy_set_header Host \$host:\$server_port; |
27 | | - proxy_set_header X-Real-IP \$remote_addr; |
28 | | - proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; |
29 | | - proxy_set_header X-Forwarded-Proto https; |
30 | | - proxy_pass_request_headers on; |
31 | | - proxy_connect_timeout 1; |
32 | | - proxy_send_timeout 300; |
33 | | - proxy_read_timeout 300; |
34 | | -
|
35 | | - error_page 404 =404 /404.html; |
36 | | - error_page 503 =503 /503.json; |
37 | | -
|
38 | | - location /nginx_status { |
39 | | - stub_status on; |
40 | | - access_log off; |
41 | | - allow 127.0.0.1; |
42 | | - deny all; |
43 | | - } |
44 | | -
|
45 | | - location /knife_admin_key.tar.gz { |
46 | | - default_type application/zip; |
47 | | - alias /etc/chef-server/knife_admin_key.tar.gz; |
48 | | - } |
49 | | -
|
50 | | - location /version { |
51 | | - types { } |
52 | | - default_type text/plain; |
53 | | - alias /opt/chef-server/version-manifest.txt; |
54 | | - } |
55 | | -
|
56 | | - location /docs { |
57 | | - index index.html ; |
58 | | - alias /opt/chef-server/docs; |
59 | | - } |
60 | | -
|
61 | | - # bookshelf |
62 | | - location ~ "/bookshelf/{0,1}.*$" { |
63 | | - proxy_pass http://bookshelf; |
64 | | - } |
65 | | -
|
66 | | - location ~ "^/(?:stylesheets|javascripts|images|facebox|css|favicon|robots|humans)/{0,1}.*$" { |
67 | | - if (\$http_x_chef_version ~* "^(\d+\.\d+?)\..+$") { |
68 | | - error_page 400 =400 /400-chef_client_manage.json; |
69 | | - return 400; |
70 | | - } |
71 | | - proxy_pass http://chef_server_webui; |
72 | | - proxy_pass_request_headers off; |
73 | | - proxy_cache webui-cache; |
74 | | - proxy_cache_valid 200 302 300m; |
75 | | - proxy_cache_valid 404 1m; |
76 | | - } |
77 | | -
|
78 | | - location = /_status { |
79 | | - proxy_pass http://erchef/_status; |
80 | | - } |
81 | | -
|
82 | | - location = /_status/ { |
83 | | - proxy_pass http://erchef/_status; |
84 | | - } |
85 | | -
|
86 | | - location / { |
87 | | - set \$my_upstream erchef; |
88 | | - if (\$http_x_ops_userid = "") { |
89 | | - set \$my_upstream chef_server_webui; |
90 | | - } |
91 | | - proxy_redirect http://\$my_upstream /; |
92 | | - proxy_pass http://\$my_upstream; |
93 | | - } |
94 | | -} |
95 | | -EOL |
96 | | -cd /etc/chef-server/ && tar -cvzf knife_admin_key.tar.gz admin.pem chef-validator.pem |
97 | | -cat > /etc/chef-server/chef-server.rb << EOL |
98 | | -nginx['ssl_port'] = $CHEF_PORT |
99 | | -EOL |
100 | | -chef-server-ctl restart nginx |
101 | | -chef-server-ctl status >> /root/out.txt |
102 | | -echo "Done!" >> /root/out.txt |
103 | | -tail -F /opt/chef-server/embedded/service/*/log/current |
| 3 | +/opt/opscode/embedded/bin/runsvdir-start & |
| 4 | +if [ -f "/root/chef_configured" ] |
| 5 | + then |
| 6 | + echo -e "\nChef Server already configured!\n" |tee -a /root/out.txt |
| 7 | + chef-server-ctl status |tee -a /root/out.txt |
| 8 | + else |
| 9 | + /usr/local/bin/configure_chef.sh |
| 10 | + sed -i "s, listen 443;, listen $CHEF_PORT;,g" /var/opt/opscode/nginx/etc/chef_https_lb.conf |
| 11 | + sed -i '$i\ location /knife_admin_key.tar.gz {\n default_type application/zip;\n alias /etc/chef/knife_admin_key.tar.gz;\n }' /var/opt/opscode/nginx/etc/chef_https_lb.conf |
| 12 | + echo -e "\nCreating tar file with the Knife keys" |tee -a /root/out.txt |
| 13 | + cd /etc/chef/ && tar -cvzf knife_admin_key.tar.gz admin.pem admin-validator.pem |
| 14 | + echo -e "\nRestart Nginx..." |tee -a /root/out.txt |
| 15 | + chef-server-ctl restart nginx |
| 16 | + chef-server-ctl status |tee -a /root/out.txt |
| 17 | + touch /root/chef_configured |
| 18 | + echo -e "\n\nDone!\n" |tee -a /root/out.txt |
| 19 | +fi |
| 20 | +tail -F /opt/opscode/embedded/service/*/log/current |
0 commit comments