Grid環境構築用のChefリポジトリです。
Revision | 6ccd9e54f5260fa061ce854cc726aeb9df24f7e1 (tree) |
---|---|
Zeit | 2017-11-30 22:12:27 |
Autor | whitestar <whitestar@user...> |
Commiter | whitestar |
bumps up hypercontainer version.
@@ -1,5 +1,10 @@ | ||
1 | 1 | # hypercontainer CHANGELOG |
2 | 2 | |
3 | +0.2.0 | |
4 | +----- | |
5 | +- bumps up hypercontainer version. | |
6 | +- adds the `['hypercontainer']['daemon_extra_options']` attribute. | |
7 | + | |
3 | 8 | 0.1.1 |
4 | 9 | ----- |
5 | 10 | - improves install method. |
@@ -32,12 +32,13 @@ This cookbook sets up a HyperContainer. | ||
32 | 32 | |:--|:--|:--|:--| |
33 | 33 | |`['hypercontainer']['install_flavor']`|String|`'script'` or `'direct_download'`|`'script'`| |
34 | 34 | |`['hypercontainer']['fallback_direct_download_install']`|Boolean|fallback from install via script to direct download install.|`true`| |
35 | -|`['hypercontainer']['package']['version']`|String||`'0.8.1-1'`| | |
35 | +|`['hypercontainer']['package']['version']`|String||`'1.0.0-1'`| | |
36 | 36 | |`['hypercontainer']['package']['download_url_context']`|String|URL context path for package download.|`"https://hypercontainer-download.s3-us-west-1.amazonaws.com/#{ver_ctx}/#{platform}"`| |
37 | 37 | |`['hypercontainer']['package']['hypercontainer']`|String|hypercontainer package file name.|See `attributes/default.rb`| |
38 | 38 | |`['hypercontainer']['package']['hyperstart']`|String|hyperstart package file name.|See `attributes/default.rb`| |
39 | 39 | |`['hypercontainer']['auto_upgrade']`|Boolean|enable auto upgrade by Chef.|`false`| |
40 | 40 | |`['hypercontainer']['hypervisor']`|String|`'qemu'` or `'xen'` for Debian family.|`'qemu'`| |
41 | +|`['hypercontainer']['daemon_extra_options']`|String||`'--log_dir=/var/log/hyper'`| | |
41 | 42 | |
42 | 43 | ## Usage |
43 | 44 |
@@ -24,11 +24,17 @@ platform = node['platform'] | ||
24 | 24 | |
25 | 25 | default['hypercontainer']['install_flavor'] = 'script' # 'script' or 'direct_download' |
26 | 26 | default['hypercontainer']['fallback_direct_download_install'] = true |
27 | -default['hypercontainer']['package']['version'] = '0.8.1-1' | |
27 | +default['hypercontainer']['package']['version'] = '1.0.0-1' | |
28 | 28 | ver = node['hypercontainer']['package']['version'] |
29 | 29 | ver_ctx = ver.slice(/^(\d+\.\d+)\./, 1) # e.g. '0.8' |
30 | +pf_ctx = \ | |
31 | + if ver_ctx >= '1.0' && (platform == 'debian' || platform == 'ubuntu') | |
32 | + 'debian_or_ubuntu' | |
33 | + else | |
34 | + platform | |
35 | + end | |
30 | 36 | default['hypercontainer']['package']['download_url_context'] \ |
31 | - = "https://hypercontainer-download.s3-us-west-1.amazonaws.com/#{ver_ctx}/#{platform}" | |
37 | + = "https://hypercontainer-download.s3-us-west-1.amazonaws.com/#{ver_ctx}/#{pf_ctx}" | |
32 | 38 | |
33 | 39 | case platform |
34 | 40 | when 'centos' |
@@ -41,3 +47,4 @@ end | ||
41 | 47 | |
42 | 48 | default['hypercontainer']['auto_upgrade'] = false |
43 | 49 | default['hypercontainer']['hypervisor'] = 'qemu' # 'qemu' or 'xen' for Debian family. |
50 | +default['hypercontainer']['daemon_extra_options'] = '--log_dir=/var/log/hyper' |
@@ -21,10 +21,18 @@ file_cache_path = Chef::Config['file_cache_path'] | ||
21 | 21 | platform_family = node['platform_family'] |
22 | 22 | install_flavor = node['hypercontainer']['install_flavor'] |
23 | 23 | fallback_direct_download_install = node['hypercontainer']['fallback_direct_download_install'] |
24 | -expected_ver = node['hypercontainer']['package']['version'].slice(/^(\d+\.\d+\.\d+)\./, 1) | |
24 | +expected_ver = node['hypercontainer']['package']['version'].slice(/^(\d+\.\d+\.\d+)-/, 1) | |
25 | 25 | download_url_context = node['hypercontainer']['package']['download_url_context'] |
26 | 26 | status_file = '/tmp/install_hypercontainer_status' |
27 | 27 | |
28 | +systemctl_daemon_reload = 'systemctl_daemon-reload' | |
29 | +resources(bash: systemctl_daemon_reload) rescue bash systemctl_daemon_reload do | |
30 | + code <<-EOH | |
31 | + systemctl daemon-reload | |
32 | + EOH | |
33 | + action :nothing | |
34 | +end | |
35 | + | |
28 | 36 | pkgs = [ |
29 | 37 | 'curl', |
30 | 38 | ] |
@@ -72,7 +80,7 @@ hc_pkgs.each {|pkg_name, pkg_file| | ||
72 | 80 | notifies :create, "remote_file[#{pkg_file_path}]", :before |
73 | 81 | if pkg_name == 'hyperstart' |
74 | 82 | notifies :enable, 'service[hyperd]', :delayed |
75 | - notifies :start, 'service[hyperd]', :delayed | |
83 | + notifies :restart, 'service[hyperd]', :delayed | |
76 | 84 | end |
77 | 85 | end |
78 | 86 | } |
@@ -81,13 +89,13 @@ hc_pkgs.each {|pkg_name, pkg_file| | ||
81 | 89 | log 'install_hypercontainer_packages.' do |
82 | 90 | action :nothing |
83 | 91 | not_if "hyperctl version | grep #{expected_ver}" |
84 | - notifies :install, 'package[hypercontainer]', :immediately | |
85 | - notifies :install, 'package[hyperstart]', :immediately | |
92 | + notifies :upgrade, 'package[hypercontainer]', :immediately | |
93 | + notifies :upgrade, 'package[hyperstart]', :immediately | |
86 | 94 | end |
87 | 95 | |
88 | 96 | if install_flavor == 'script' |
89 | 97 | execute 'install_hypercontainer_by_script' do |
90 | - # `echo $?` for notifies | |
98 | + # `echo $?` (always success) for notifies | |
91 | 99 | command "curl -sSL https://hypercontainer.io/install | bash; echo $? > #{status_file}" |
92 | 100 | action :run |
93 | 101 | not_if { File.exist?('/usr/bin/hyperctl') } unless node['hypercontainer']['auto_upgrade'] |
@@ -102,6 +110,29 @@ elsif install_flavor == 'direct_download' | ||
102 | 110 | end |
103 | 111 | end |
104 | 112 | |
113 | +hyperd_opts = [] | |
114 | +extra_options = node['hypercontainer']['daemon_extra_options'] | |
115 | +hyperd_opts.push(extra_options) if !extra_options.nil? && !extra_options.empty? | |
116 | + | |
117 | +directory '/etc/systemd/system/hyperd.service.d' do | |
118 | + owner 'root' | |
119 | + group 'root' | |
120 | + mode '0755' | |
121 | + action :create | |
122 | +end | |
123 | + | |
124 | +template '/etc/systemd/system/hyperd.service.d/override.conf' do | |
125 | + source 'etc/systemd/system/hyperd.service.d/override.conf' | |
126 | + owner 'root' | |
127 | + group 'root' | |
128 | + mode '0644' | |
129 | + variables( | |
130 | + hyperd_opts: hyperd_opts | |
131 | + ) | |
132 | + notifies :run, "bash[#{systemctl_daemon_reload}]", :immediately | |
133 | + notifies :restart, 'service[hyperd]' | |
134 | +end | |
135 | + | |
105 | 136 | srv = 'hyperd' |
106 | 137 | resources(service: srv) rescue service srv do |
107 | 138 | action [:enable, :start] |
@@ -0,0 +1,3 @@ | ||
1 | +[Service] | |
2 | +ExecStart= | |
3 | +ExecStart=/usr/bin/hyperd <%= @hyperd_opts.join(' ') %> |
@@ -1 +1 @@ | ||
1 | -0.1.1 | |
1 | +0.2.0 |