OSDN Git Service

add repository update flag. kata-containers-0.3.0
authorwhitestar <whitestar@users.osdn.me>
Thu, 19 Jul 2018 08:46:28 +0000 (17:46 +0900)
committerwhitestar <whitestar@users.osdn.me>
Thu, 19 Jul 2018 08:46:28 +0000 (17:46 +0900)
cookbooks/kata-containers/CHANGELOG.md
cookbooks/kata-containers/README.md
cookbooks/kata-containers/attributes/default.rb [new file with mode: 0644]
cookbooks/kata-containers/recipes/default.rb
cookbooks/kata-containers/version
nodes/local-kata-containers.json [new file with mode: 0644]
roles/kata-containers.rb [new file with mode: 0644]

index 1e220c4..720ab3c 100644 (file)
@@ -1,5 +1,9 @@
 # kata-containers CHANGELOG
 
+0.3.0
+-----
+- add repository update flag
+
 0.2.1
 -----
 - update documents.
index 54d0ce1..b37be75 100644 (file)
@@ -29,6 +29,7 @@ This cookbook installs Kata Containers.
 
 |Key|Type|Description, example|Default|
 |:--|:--|:--|:--|
+|`['kata-containers']['repo']['update']`|Boolean|Repository update flag.|`false`|
 
 ## Usage
 
diff --git a/cookbooks/kata-containers/attributes/default.rb b/cookbooks/kata-containers/attributes/default.rb
new file mode 100644 (file)
index 0000000..cd6904e
--- /dev/null
@@ -0,0 +1,20 @@
+#
+# Cookbook Name:: kata-containers
+# Attributes:: default
+#
+# Copyright 2018, 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['kata-containers']['repo']['update'] = false
index 6439de0..6ba707f 100644 (file)
@@ -32,10 +32,13 @@ when 'centos', 'redhat'
   bash 'add_kata-containers_repo' do
     code <<-"EOH"
       source /etc/os-release
+      if [ -f /etc/yum.repos.d/*katacontainers*.repo ]; then
+        rm /etc/yum.repos.d/*katacontainers*.repo
+      fi
       yum-config-manager --add-repo "http://download.opensuse.org/repositories/home:/katacontainers:/release/CentOS_${VERSION_ID}/home:katacontainers:release.repo"
     EOH
     action :nothing
-    not_if "yum repolist | grep 'katacontainers'"
+    not_if "yum repolist | grep 'katacontainers'" unless node['kata-containers']['repo']['update']
   end
 
   [
@@ -49,6 +52,14 @@ when 'centos', 'redhat'
     end
   }
 when 'ubuntu'
+  [
+    'curl',
+  ].each {|pkg_name|
+    resources(package: pkg_name) rescue package pkg_name do
+      action :install
+    end
+  }
+
   apt_get_update = 'apt-get_update'
   resources(execute: apt_get_update) rescue execute apt_get_update do
     command 'apt-get update'
@@ -68,7 +79,7 @@ when 'ubuntu'
       echo "deb http://download.opensuse.org/repositories/home:/katacontainers:/release/xUbuntu_$(lsb_release -rs)/ /" > /etc/apt/sources.list.d/kata-containers.list
     EOH
     action :nothing
-    not_if { File.exist?('/etc/apt/sources.list.d/kata-containers.list') }
+    not_if { File.exist?('/etc/apt/sources.list.d/kata-containers.list') } unless node['kata-containers']['repo']['update']
     notifies :run, 'bash[add_kata-containers_apt_key]', :before
     notifies :run, "execute[#{apt_get_update}]", :immediately
   end
diff --git a/nodes/local-kata-containers.json b/nodes/local-kata-containers.json
new file mode 100644 (file)
index 0000000..0e12e20
--- /dev/null
@@ -0,0 +1,5 @@
+{
+  "run_list": [
+    "role[kata-containers]"
+  ]
+}
diff --git a/roles/kata-containers.rb b/roles/kata-containers.rb
new file mode 100644 (file)
index 0000000..0cb8cdf
--- /dev/null
@@ -0,0 +1,41 @@
+#
+# Copyright 2018, 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 'kata-containers'
+description 'Kata Containers'
+
+run_list(
+  'recipe[kata-containers::default]',
+  # with docker-grid cookbook
+  #'recipe[docker-grid::engine]',
+)
+
+#env_run_lists
+
+default_attributes(
+)
+
+override_attributes(
+  # with docker-grid cookbook
+  'docker-grid' => {
+    'engine' => {
+      'daemon_extra_options' => [
+        '--add-runtime kata-runtime=/usr/bin/kata-runtime',
+        '--default-runtime=kata-runtime',
+      ].join(' '),
+    },
+  },
+)