OSDN Git Service

add berkshelf-api-server-ya cookbook.
authorwhitestar <whitestar@gaea.test>
Sat, 10 Oct 2015 08:16:41 +0000 (17:16 +0900)
committerwhitestar <whitestar@gaea.test>
Sat, 10 Oct 2015 08:16:41 +0000 (17:16 +0900)
12 files changed:
cookbooks/berkshelf-api-server-ya/CHANGELOG.md [new file with mode: 0644]
cookbooks/berkshelf-api-server-ya/README.md [new file with mode: 0644]
cookbooks/berkshelf-api-server-ya/attributes/default.rb [new file with mode: 0644]
cookbooks/berkshelf-api-server-ya/metadata.rb [new file with mode: 0644]
cookbooks/berkshelf-api-server-ya/recipes/app.rb [new file with mode: 0644]
cookbooks/berkshelf-api-server-ya/recipes/default.rb [new file with mode: 0644]
cookbooks/berkshelf-api-server-ya/recipes/http_proxy.rb [new file with mode: 0644]
cookbooks/berkshelf-api-server-ya/templates/default/berks-api-nginx.erb [new file with mode: 0644]
cookbooks/berkshelf-api-server-ya/templates/default/sv-berks-api-log-run.erb [new file with mode: 0644]
cookbooks/berkshelf-api-server-ya/templates/default/sv-berks-api-run.erb [new file with mode: 0644]
roles/berkshelf-api-server.rb
roles/grid-gpm.rb

diff --git a/cookbooks/berkshelf-api-server-ya/CHANGELOG.md b/cookbooks/berkshelf-api-server-ya/CHANGELOG.md
new file mode 100644 (file)
index 0000000..0311b10
--- /dev/null
@@ -0,0 +1,13 @@
+berkshelf-api-server-ya CHANGELOG
+=================================
+
+This file is used to list changes made in each version of the berkshelf-api-server-ya cookbook.
+
+0.1.0
+-----
+- [your_name] - Initial release of berkshelf-api-server-ya
+
+- - -
+Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.
+
+The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.
diff --git a/cookbooks/berkshelf-api-server-ya/README.md b/cookbooks/berkshelf-api-server-ya/README.md
new file mode 100644 (file)
index 0000000..ef32553
--- /dev/null
@@ -0,0 +1,68 @@
+berkshelf-api-server-ya Cookbook
+================================
+TODO: Enter the cookbook description here.
+
+e.g.
+This cookbook makes your favorite breakfast sandwich.
+
+Requirements
+------------
+TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.
+
+e.g.
+#### packages
+- `toaster` - berkshelf-api-server-ya needs toaster to brown your bagel.
+
+Attributes
+----------
+TODO: List your cookbook attributes here.
+
+e.g.
+#### berkshelf-api-server-ya::default
+<table>
+  <tr>
+    <th>Key</th>
+    <th>Type</th>
+    <th>Description</th>
+    <th>Default</th>
+  </tr>
+  <tr>
+    <td><tt>['berkshelf-api-server-ya']['bacon']</tt></td>
+    <td>Boolean</td>
+    <td>whether to include bacon</td>
+    <td><tt>true</tt></td>
+  </tr>
+</table>
+
+Usage
+-----
+#### berkshelf-api-server-ya::default
+TODO: Write usage instructions for each cookbook.
+
+e.g.
+Just include `berkshelf-api-server-ya` in your node's `run_list`:
+
+```json
+{
+  "name":"my_node",
+  "run_list": [
+    "recipe[berkshelf-api-server-ya]"
+  ]
+}
+```
+
+Contributing
+------------
+TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.
+
+e.g.
+1. Fork the repository on Github
+2. Create a named feature branch (like `add_component_x`)
+3. Write your change
+4. Write tests for your change (if applicable)
+5. Run the tests, ensuring they all pass
+6. Submit a Pull Request using Github
+
+License and Authors
+-------------------
+Authors: TODO: List authors
diff --git a/cookbooks/berkshelf-api-server-ya/attributes/default.rb b/cookbooks/berkshelf-api-server-ya/attributes/default.rb
new file mode 100644 (file)
index 0000000..d81e0bb
--- /dev/null
@@ -0,0 +1,24 @@
+#
+# Cookbook Name:: berkshelf-api-server
+# Attributes:: default
+#
+# Copyright 2015, whitestar
+#
+# 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.
+#
+
+default[:berkshelf_api][:app_host] = '0.0.0.0'
+default[:berkshelf_api][:proxy][:ssl] = false
+default[:berkshelf_api][:proxy][:ssl_certificate] = ''
+default[:berkshelf_api][:proxy][:ssl_certificate_key] = ''
+
diff --git a/cookbooks/berkshelf-api-server-ya/metadata.rb b/cookbooks/berkshelf-api-server-ya/metadata.rb
new file mode 100644 (file)
index 0000000..cfd7b49
--- /dev/null
@@ -0,0 +1,10 @@
+name             'berkshelf-api-server-ya'
+maintainer       'whitestar'
+maintainer_email ''
+license          'Apache 2.0'
+description      'Installs/Configures berkshelf-api-server-ya'
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
+version          '0.1.0'
+
+depends 'berkshelf-api-server', '>=2.1.1'
+
diff --git a/cookbooks/berkshelf-api-server-ya/recipes/app.rb b/cookbooks/berkshelf-api-server-ya/recipes/app.rb
new file mode 100644 (file)
index 0000000..f2dc6b5
--- /dev/null
@@ -0,0 +1,26 @@
+#
+# Cookbook Name:: berkshelf-api-server-ya
+# Recipe:: default
+#
+# Copyright 2015, whitestar
+#
+# 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.
+#
+
+include_recipe 'berkshelf-api-server::app'
+
+begin
+    r = resources(:runit_service => 'berks-api')
+    r.cookbook 'berkshelf-api-server-ya'
+end
+
diff --git a/cookbooks/berkshelf-api-server-ya/recipes/default.rb b/cookbooks/berkshelf-api-server-ya/recipes/default.rb
new file mode 100644 (file)
index 0000000..48be0f6
--- /dev/null
@@ -0,0 +1,22 @@
+#
+# Cookbook Name:: berkshelf-api-server-ya
+# Recipe:: default
+#
+# Copyright 2015, whitestar
+#
+# 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.
+#
+
+include_recipe "berkshelf-api-server-ya::app"
+include_recipe "berkshelf-api-server-ya::http_proxy"
+
diff --git a/cookbooks/berkshelf-api-server-ya/recipes/http_proxy.rb b/cookbooks/berkshelf-api-server-ya/recipes/http_proxy.rb
new file mode 100644 (file)
index 0000000..e648114
--- /dev/null
@@ -0,0 +1,26 @@
+#
+# Cookbook Name:: berkshelf-api-server-ya
+# Recipe:: default
+#
+# Copyright 2015, whitestar
+#
+# 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.
+#
+
+include_recipe 'berkshelf-api-server::http_proxy'
+
+begin
+  res = resources(:template => "#{node[:nginx][:dir]}/sites-available/berks-api")
+  res.cookbook 'berkshelf-api-server-ya'
+end
+
diff --git a/cookbooks/berkshelf-api-server-ya/templates/default/berks-api-nginx.erb b/cookbooks/berkshelf-api-server-ya/templates/default/berks-api-nginx.erb
new file mode 100644 (file)
index 0000000..0e3ce2e
--- /dev/null
@@ -0,0 +1,24 @@
+upstream berks_api {
+  server <%= node[:berkshelf_api][:app_host] %>:<%= node[:berkshelf_api][:port] %> fail_timeout=0;
+}
+
+server {
+  listen <%= node[:berkshelf_api][:proxy_port] %>;
+  server_name <%= node[:berkshelf_api][:host] %>;
+
+<% if node[:berkshelf_api][:proxy][:ssl] then -%>
+  ssl on;
+  ssl_certificate <%= node[:berkshelf_api][:proxy][:ssl_certificate] %>;
+  ssl_certificate_key <%= node[:berkshelf_api][:proxy][:ssl_certificate_key] %>;
+
+<% end -%>
+  location / {
+    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    proxy_set_header Host $http_host;
+    proxy_redirect off;
+    if (!-f $request_filename) {
+      proxy_pass http://berks_api;
+      break;
+    }
+  }
+}
diff --git a/cookbooks/berkshelf-api-server-ya/templates/default/sv-berks-api-log-run.erb b/cookbooks/berkshelf-api-server-ya/templates/default/sv-berks-api-log-run.erb
new file mode 100644 (file)
index 0000000..a79a518
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec svlogd -tt ./main
diff --git a/cookbooks/berkshelf-api-server-ya/templates/default/sv-berks-api-run.erb b/cookbooks/berkshelf-api-server-ya/templates/default/sv-berks-api-run.erb
new file mode 100644 (file)
index 0000000..ea6af33
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+export PATH=/opt/chef/embedded/bin:$PATH
+export HOME=<%= node[:berkshelf_api][:deploy_path] %>
+cd $HOME
+
+exec 2>&1
+exec chpst -u <%= node[:berkshelf_api][:owner] %> bundle exec bin/berks-api -h <%= node[:berkshelf_api][:app_host] %> -p <%= node[:berkshelf_api][:port] %> -c <%= node[:berkshelf_api][:config_path] %>
index 6b213e3..ede8399 100644 (file)
@@ -18,7 +18,7 @@ name 'berkshelf-api-server'
 description 'Berkshelf dependency API server'
 
 run_list(
-  'recipe[berkshelf-api-server::default]',
+  'recipe[berkshelf-api-server-ya::default]',
 )
 
 #env_run_lists()
index 45bd811..a3c738d 100644 (file)
@@ -67,9 +67,15 @@ override_attributes(
       ],
       'build_interval' => 180.0
     },
+    'app_host' => '127.0.0.1',
     'host' => "gpm00.#{Grid::DOMAIN}",
     'port' => 26200,
     'proxy_port' => 6280,
+    'proxy' => {
+      'ssl' => true,
+      'ssl_certificate'     => '/etc/pki/tls/certs/01gpm00_server.crt',
+      'ssl_certificate_key' => '/etc/pki/tls/private/01gpm00_server.key',
+    } 
   },
   'ganglia' => {
     # gmond