OSDN Git Service

adds the `platform_utils::wsl_conf` recipe. platform_utils-0.8.1
authorwhitestar <whitestar@users.osdn.me>
Mon, 8 Oct 2018 13:35:33 +0000 (22:35 +0900)
committerwhitestar <whitestar@users.osdn.me>
Mon, 8 Oct 2018 13:35:33 +0000 (22:35 +0900)
cookbooks/platform_utils/CHANGELOG.md
cookbooks/platform_utils/attributes/default.rb
cookbooks/platform_utils/libraries/virt_utils.rb
cookbooks/platform_utils/recipes/grub_default.rb
cookbooks/platform_utils/recipes/kernel_user_namespace.rb
cookbooks/platform_utils/recipes/ntpd.rb
cookbooks/platform_utils/recipes/sysctl.rb
cookbooks/platform_utils/recipes/wsl_conf.rb [new file with mode: 0644]
cookbooks/platform_utils/templates/default/etc/wsl.conf [new file with mode: 0644]
cookbooks/platform_utils/version

index fd98870..3b6d09e 100644 (file)
@@ -1,6 +1,11 @@
 platform_utils CHANGELOG
 ========================
 
+0.8.1
+-----
+- bug fix.
+- adds the `platform_utils::wsl_conf` recipe.
+
 0.8.0
 -----
 - adds the `platform_utils::grub_default` recipe.
index c37353e..43ea8e1 100644 (file)
@@ -111,3 +111,18 @@ default['platform_utils']['sysctl']['configs'] = {
 
 default['platform_utils']['tcp_wrappers']['hosts_allow'] = []
 default['platform_utils']['tcp_wrappers']['hosts_deny'] = []
+
+default['platform_utils']['wsl_conf'] = {
+=begin
+  'automount' => {
+    'enabled' => 'true',
+    'root' => '/mnt/',
+    'options' => '"metadata,umask=22,fmask=11"',
+    'mountFsTab' => 'true',
+  },
+  'network' => {
+    'generateHosts' => 'true',
+    'generateResolvConf' => 'true',
+  },
+=end
+}
index 47d34b2..aa3ab38 100644 (file)
@@ -52,5 +52,9 @@ module PlatformUtils
     def container_guest_node?
       container_system? && guest_node?
     end
+
+    def wsl?
+      node['os'] == 'linux' && node['os_version'].include?('Microsoft')
+    end
   end
 end
index dace997..7449b2a 100644 (file)
@@ -26,7 +26,7 @@ execute 'update-grub2' do
   user 'root'
   command 'update-grub2'
   action :nothing
-  only_if 'update-grub2 --version'
+  only_if 'which update-grub2'
 end
 
 dir = '/etc/default/grub.d'
index fb594de..e2d2b6d 100644 (file)
@@ -2,7 +2,7 @@
 # Cookbook Name:: platform_utils
 # Recipe:: kernel_user_namespace
 #
-# Copyright 2017, whitestar
+# Copyright 2017-2018, whitestar
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -19,6 +19,8 @@
 
 ::Chef::Recipe.send(:include, PlatformUtils::VirtUtils)
 
+return if wsl?
+
 reboot_msg = 'reboot_message'
 resources(log: reboot_msg) rescue log reboot_msg do
   message 'Please reboot this machine because of kernel boot option modified.'
index a36c145..5c70377 100644 (file)
@@ -2,7 +2,7 @@
 # Cookbook Name:: platform_utils
 # Recipe:: ntpd
 #
-# Copyright 2017, whitestar
+# Copyright 2017-2018, whitestar
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # limitations under the License.
 #
 
+::Chef::Recipe.send(:include, PlatformUtils::VirtUtils)
+
+return if wsl?
+
 pkg = 'ntp'
 resources(package: pkg) rescue package pkg do
   action :install
index 6058f9b..2abe61c 100644 (file)
@@ -2,7 +2,7 @@
 # Cookbook Name:: platform_utils
 # Recipe:: sysctl
 #
-# Copyright 2017, whitestar
+# Copyright 2017-2018, whitestar
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -19,6 +19,8 @@
 
 ::Chef::Recipe.send(:include, PlatformUtils::VirtUtils)
 
+return if wsl?
+
 unless container_guest_node?
   node['platform_utils']['sysctl']['configs'].each {|file_name, conf|
     file_path = "/etc/sysctl.d/#{file_name}.conf"
diff --git a/cookbooks/platform_utils/recipes/wsl_conf.rb b/cookbooks/platform_utils/recipes/wsl_conf.rb
new file mode 100644 (file)
index 0000000..e017dc7
--- /dev/null
@@ -0,0 +1,29 @@
+#
+# Cookbook Name:: platform_utils
+# Recipe:: wsl_conf
+#
+# 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.
+#
+
+::Chef::Recipe.send(:include, PlatformUtils::VirtUtils)
+
+return unless wsl?
+
+template '/etc/wsl.conf' do
+  source  'etc/wsl.conf'
+  owner 'root'
+  group 'root'
+  mode '0644'
+end
diff --git a/cookbooks/platform_utils/templates/default/etc/wsl.conf b/cookbooks/platform_utils/templates/default/etc/wsl.conf
new file mode 100644 (file)
index 0000000..4e575ea
--- /dev/null
@@ -0,0 +1,14 @@
+# This file is generated by Chef
+
+<%
+node['platform_utils']['wsl_conf'].each {|section, params|
+-%>
+[<%= section %>]
+<%
+  params.each {|key, value|
+-%>
+<%= key %> = <%= value %>
+<%
+  }
+}
+-%>