diff --git a/CHANGELOG.md b/CHANGELOG.md index 796b9a5d..3e36aa49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - More updates for Puppet 8 compatibility - Added psick::puppet::facter profile to manage facter.conf - pdk update +- Make psick::tools::create_dir windows compatible ## Release 1.0.4 diff --git a/manifests/hosts/file.pp b/manifests/hosts/file.pp index 45c40476..f5556cb4 100644 --- a/manifests/hosts/file.pp +++ b/manifests/hosts/file.pp @@ -10,7 +10,7 @@ class psick::hosts::file ( String $template = 'psick/hosts/file/hosts.erb', - Optional[Stdlib::Compat::Ip_address] $ipaddress = $psick::primary_ip, + Optional[Stdlib::IP::Address] $ipaddress = $psick::primary_ip, Variant[Undef,String] $domain = $facts['networking']['domain'], String $hostname = $facts['networking']['hostname'], Array $extra_hosts = [], diff --git a/manifests/init.pp b/manifests/init.pp index 0e11c6c8..13991a55 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -115,7 +115,7 @@ Boolean $noop_value = false, # General network settings - Optional[Stdlib::Compat::Ip_address] $primary_ip = fact('networking.ip'), + Optional[Stdlib::IP::Address] $primary_ip = fact('networking.ip'), Optional[String] $mgmt_interface = fact('networking.primary'), Optional[String] $timezone = undef, Hash $interfaces_hash = {}, diff --git a/manifests/network/netplan/interface.pp b/manifests/network/netplan/interface.pp index 2ca0ce06..aca5e16b 100644 --- a/manifests/network/netplan/interface.pp +++ b/manifests/network/netplan/interface.pp @@ -22,8 +22,8 @@ Optional[Stdlib::MAC] $macaddress = getvar("networking.interfaces.${interface_name}.mac"), Variant[Undef,Psick::Network::NetplanAddresses] $addresses = undef, Variant[Undef,Array] $routes = undef, - Optional[Stdlib::Compat::Ipv4] $gateway4 = undef, - Optional[Stdlib::Compat::Ipv6] $gateway6 = undef, + Optional[Stdlib::IP::Address::V4] $gateway4 = undef, + Optional[Stdlib::IP::Address::V6] $gateway6 = undef, Optional[Hash] $nameservers = undef, Optional[Hash] $parameters = undef, diff --git a/manifests/tools/create_dir.pp b/manifests/tools/create_dir.pp index 437b7407..4f6bca3d 100644 --- a/manifests/tools/create_dir.pp +++ b/manifests/tools/create_dir.pp @@ -13,31 +13,45 @@ Optional[String] $mode = undef, Stdlib::AbsolutePath $path = $title, ) { - exec { "mkdir -p ${title}": - command => "mkdir -p ${path}", - path => '/bin:/sbin:/usr/sbin:/usr/bin', - creates => $path, + + $mkdir_command = $facts['os']['family'] ? { + 'windows' => "New-Item -ItemType Directory -Force -Path '${path}'", + default => "mkdir -p '${path}'", } - if $owner { - exec { "chown ${owner} ${title}": - command => "chown ${owner} ${path}", - path => '/bin:/sbin:/usr/sbin:/usr/bin', - onlyif => "[ $(ls -ld ${path} | awk '{ print \$3 }') != ${owner} ]", - } + $command_provider = $facts['os']['family'] ? { + 'windows' => 'powershell', + default => undef, } - if $group { - exec { "chgrp ${group} ${title}": - command => "chgrp ${group} ${path}", - path => '/bin:/sbin:/usr/sbin:/usr/bin', - onlyif => "[ $(ls -ld ${path} | awk '{ print \$4 }') != ${group} ]", - } + + exec { "Create directory ${title}": + command => $mkdir_command, + path => $facts['path'], + creates => $path, + provider => $command_provider, } - if $mode { - exec { "chmod ${mode} ${title}": - command => "chmod ${mode} ${path}", - path => '/bin:/sbin:/usr/sbin:/usr/bin', - subscribe => Exec["mkdir -p ${title}"], - refreshonly => true, + + if $facts['os']['family'] != 'windows' { + if $owner { + exec { "chown ${owner} ${title}": + command => "chown '${owner}' '${path}'", + path => $facts['path'], + onlyif => "[ stat -c '%U' '${path}' != '${owner}' ]", + } + } + if $group { + exec { "chgrp ${group} ${title}": + command => "chgrp '${group}' '${path}'", + path => $facts['path'], + onlyif => "[ stat -c '%G' '${path}' != '${group}' ]", + } + } + if $mode { + exec { "chmod ${mode} ${title}": + command => "chmod '${mode}' '${path}'", + path => '/bin:/sbin:/usr/sbin:/usr/bin', + subscribe => Exec["Create directory ${title}"], + refreshonly => true, + } } } }