# hypercontainer CHANGELOG
+0.1.1
+-----
+- improves install method.
+
0.1.0
-----
- Initial release of hypercontainer
## Contents
+- [Requirements](#requirements)
+ - [platforms](#platforms)
+ - [packages](#packages)
+- [Attributes](#attributes)
+- [Usage](#usage)
+ - [Recipes](#recipes)
+ - [hypercontainer::default](#hypercontainerdefault)
+ - [Role Examples](#role-examples)
+- [License and Authors](#license-and-authors)
## Requirements
|Key|Type|Description, example|Default|
|:--|:--|:--|:--|
+|`['hypercontainer']['install_flavor']`|String|`'script'` or `'direct_download'`|`'script'`|
+|`['hypercontainer']['fallback_direct_download_install']`|Boolean|fallback from install via script to direct download install.|`true`|
+|`['hypercontainer']['package']['version']`|String||`'0.8.1-1'`|
+|`['hypercontainer']['package']['download_url_context']`|String|URL context path for package download.|`"https://hypercontainer-download.s3-us-west-1.amazonaws.com/#{ver_ctx}/#{platform}"`|
+|`['hypercontainer']['package']['hypercontainer']`|String|hypercontainer package file name.|See `attributes/default.rb`|
+|`['hypercontainer']['package']['hyperstart']`|String|hyperstart package file name.|See `attributes/default.rb`|
|`['hypercontainer']['auto_upgrade']`|Boolean|enable auto upgrade by Chef.|`false`|
|`['hypercontainer']['hypervisor']`|String|`'qemu'` or `'xen'` for Debian family.|`'qemu'`|
# limitations under the License.
#
+platform = node['platform']
+
#default['hypercontainer']['with_ssl_cert_cookbook'] = false
#default['hypercontainer']['ssl_cert']['common_name'] = node['fqdn']
-force_override['hypercontainer']['install_flavor'] = 'script' # 'script'
+default['hypercontainer']['install_flavor'] = 'script' # 'script' or 'direct_download'
+default['hypercontainer']['fallback_direct_download_install'] = true
+default['hypercontainer']['package']['version'] = '0.8.1-1'
+ver = node['hypercontainer']['package']['version']
+ver_ctx = ver.slice(/^(\d+\.\d+)\./, 1) # e.g. '0.8'
+default['hypercontainer']['package']['download_url_context'] \
+ = "https://hypercontainer-download.s3-us-west-1.amazonaws.com/#{ver_ctx}/#{platform}"
+
+case platform
+when 'centos'
+ default['hypercontainer']['package']['hypercontainer'] = "hyper-container-#{ver}.el7.centos.x86_64.rpm"
+ default['hypercontainer']['package']['hyperstart'] = "hyperstart-#{ver}.el7.centos.x86_64.rpm"
+when 'debian', 'ubuntu'
+ default['hypercontainer']['package']['hypercontainer'] = "hypercontainer_#{ver}_amd64.deb"
+ default['hypercontainer']['package']['hyperstart'] = "hyperstart_#{ver}_amd64.deb"
+end
+
default['hypercontainer']['auto_upgrade'] = false
default['hypercontainer']['hypervisor'] = 'qemu' # 'qemu' or 'xen' for Debian family.
# limitations under the License.
#
+file_cache_path = Chef::Config['file_cache_path']
+platform_family = node['platform_family']
+install_flavor = node['hypercontainer']['install_flavor']
+fallback_direct_download_install = node['hypercontainer']['fallback_direct_download_install']
+expected_ver = node['hypercontainer']['package']['version'].slice(/^(\d+\.\d+\.\d+)\./, 1)
+download_url_context = node['hypercontainer']['package']['download_url_context']
+status_file = '/tmp/install_hypercontainer_status'
+
pkgs = []
-case node['platform_family']
+case platform_family
#when 'rhel'
# do nothing.
when 'debian'
end
}
-if node['hypercontainer']['install_flavor'] == 'script'
+hc_pkgs = {
+ 'hypercontainer' => node['hypercontainer']['package']['hypercontainer'],
+ 'hyperstart' => node['hypercontainer']['package']['hyperstart'],
+}
+hc_pkgs.each {|pkg_name, pkg_file|
+ pkg_file_path = "#{file_cache_path}/#{pkg_file}"
+
+ remote_file pkg_file_path do
+ source "#{download_url_context}/#{pkg_file}"
+ owner 'root'
+ group 'root'
+ mode '0644'
+ action :nothing
+ end
+
+ package pkg_name do
+ provider Chef::Provider::Package::Rpm if platform_family == 'rhel'
+ provider Chef::Provider::Package::Dpkg if platform_family == 'debian'
+ source pkg_file_path
+ action :nothing
+ notifies :create, "remote_file[#{pkg_file_path}]", :before
+ if pkg_name == 'hyperstart'
+ notifies :enable, 'service[hyperd]', :delayed
+ notifies :start, 'service[hyperd]', :delayed
+ end
+ end
+}
+
+# install trigger
+log 'install_hypercontainer_packages.' do
+ action :nothing
+ not_if "hyperctl version | grep #{expected_ver}"
+ notifies :install, 'package[hypercontainer]', :immediately
+ notifies :install, 'package[hyperstart]', :immediately
+end
+
+if install_flavor == 'script'
execute 'install_hypercontainer_by_script' do
- command 'curl -sSL https://hypercontainer.io/install | bash'
+ # `echo $?` for notifies
+ command "curl -sSL https://hypercontainer.io/install | bash; echo $? > #{status_file}"
action :run
not_if { File.exist?('/usr/bin/hyperctl') } unless node['hypercontainer']['auto_upgrade']
+ if fallback_direct_download_install
+ ignore_failure true
+ notifies :write, 'log[install_hypercontainer_packages.]', :immediately
+ end
+ end
+elsif install_flavor == 'direct_download'
+ log 'do_install_hypercontainer_packages.' do
+ notifies :write, 'log[install_hypercontainer_packages.]', :immediately
end
end
srv = 'hyperd'
resources(service: srv) rescue service srv do
action [:enable, :start]
+ # waiting fallback installation.
+ only_if { File.exist?('/usr/bin/hyperctl') }
end
--- /dev/null
+{
+ "run_list": [
+ "role[hypercontainer]"
+ ]
+}
--- /dev/null
+#
+# Copyright 2017, 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.
+#
+
+name 'hypercontainer'
+description 'HyperContainer'
+
+run_list(
+ 'recipe[hypercontainer::default]',
+)
+
+#env_run_lists()
+
+#default_attributes()
+
+override_attributes(
+ 'hypercontainer' => {
+ 'auto_upgrade' => false,
+ 'hypervisor' => 'qemu', # 'qemu' or 'xen' for Debian family.
+ },
+)