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.
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
+}
def container_guest_node?
container_system? && guest_node?
end
+
+ def wsl?
+ node['os'] == 'linux' && node['os_version'].include?('Microsoft')
+ end
end
end
user 'root'
command 'update-grub2'
action :nothing
- only_if 'update-grub2 --version'
+ only_if 'which update-grub2'
end
dir = '/etc/default/grub.d'
# 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.
::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.'
# 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
# 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.
::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"
--- /dev/null
+#
+# 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
--- /dev/null
+# This file is generated by Chef
+
+<%
+node['platform_utils']['wsl_conf'].each {|section, params|
+-%>
+[<%= section %>]
+<%
+ params.each {|key, value|
+-%>
+<%= key %> = <%= value %>
+<%
+ }
+}
+-%>