Skip to content

win #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 16, 2025
Merged

win #115

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"cidfile"
]
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## 3.10.2

- Fixed options param in tp::conf where use_v4 is false
- Windows improvements

## 3.10.1

- Changed CI containers used
Expand Down
3 changes: 3 additions & 0 deletions data/Linux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
tp::tp_owner: 'root'
tp::tp_group: 'root'
42 changes: 12 additions & 30 deletions data/windows.yaml
Original file line number Diff line number Diff line change
@@ -1,59 +1,41 @@
---
tp::tp_owner: 'Administrator'
tp::tp_group: 'Administrators'
tp::info_script_path: 'C:/ProgramData/PuppetLabs/bin/run_info.ps1'
tp::debug_script_path: 'C:/ProgramData/PuppetLabs/bin/run_debug.ps1'

tp::tp_owner: ~
tp::tp_group: ~
#tp::tp_owner: 'Administrator'
#tp::tp_group: 'Administrators'
tp::info_script_path: 'C:/ProgramData/PuppetLabs/tp/bin/run_info.ps1'
tp::debug_script_path: 'C:/ProgramData/PuppetLabs/tp/bin/run_debug.ps1'
#tp::cli::ensure: 'absent'
#tp::ensure: 'absent'
# tp 4 new entrypoints
## tp cli configurations
tp::tp_params:
global:
owner: ~
group: ~
mode: '0775'
tp:
path: 'C:/ProgramData/PuppetLabs/tp/bin/tp'
args:
owner: 'Administrator'
group: 'Administrators'
conf:
path: 'C:/ProgramData/PuppetLabs/tp'
args:
ensure: 'directory'
owner: 'Administrator'
group: 'Administrators'
data:
path: 'C:/ProgramData/PuppetLabs/tp/lib'
args:
ensure: 'directory'
owner: 'Administrator'
group: 'Administrators'
bin:
path: 'C:/ProgramData/PuppetLabs/tp/bin'
args:
ensure: 'directory'
owner: 'Administrator'
group: 'Administrators'
source: 'puppet:///modules/tp/bin'
source: 'puppet:///modules/tp/bin_windows'
destination:
path: 'C:/ProgramData/PuppetLabs/tp'
user:
tp:
path: '~/.tp/bin/tp'
args:
mode: '0755'
conf:
path: '~/.tp/etc'
args:
ensure: 'directory'
mode: '0755'
data:
path: '~/.tp/lib'
args:
ensure: 'directory'
mode: '0755'
bin:
path: '~/.tp/bin'
args:
ensure: 'directory'
mode: '0755'
source: 'puppet:///modules/tp/bin'
destination:
path: '~/.tp/bin'
Expand Down
4 changes: 2 additions & 2 deletions functions/get_version.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ function tp::get_version (
Hash $_settings = {},
Enum['full', 'major'] $_version_type = 'full',
) {
if $_version_type == 'major' {
$real_version = pick_default(getvar('_settings.release.latest_version_major'))
if $_version_type == 'major' and getvar('_settings.release.latest_version_major') {
$real_version = getvar('_settings.release.latest_version_major')
} elsif $_version != undef and $_ensure != 'absent' {
$real_version = $_version
} elsif $_ensure !~ /^present$|^latest$|^absent$/ {
Expand Down
148 changes: 73 additions & 75 deletions manifests/cli.pp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
$real_options = $options_defaults + $options

$real_ruby_path = $ruby_path ? {
undef => $facts['aio_agent_version'] ? {
undef => getvar('facts.aio_agent_version') ? {
undef => '/usr/bin/env ruby',
'' => '/usr/bin/env ruby',
default => $facts['os']['family'] ? {
Expand All @@ -61,92 +61,90 @@

File {
ensure => $file_ensure,
mode => $real_tp_params['mode'],
owner => $real_tp_params['owner'],
group => $real_tp_params['group'],
mode => $tp::tp_dirs_mode,
owner => $tp::tp_dirs_owner,
group => $tp::tp_dirs_group,
}

if $cli_enable {
$dirs = [$tp::tp_dir , "${tp::tp_dir}/app" , "${tp::tp_dir}/shellvars" , "${tp::tp_dir}/test", "${tp::tp_dir}/info", "${tp::tp_dir}/debug"]
$dirs.each | $d | {
file { $d:
ensure => $dir_ensure,
purge => $purge_dirs,
force => $purge_dirs,
recurse => $purge_dirs,
}
$dirs = [$tp::tp_dir , "${tp::tp_dir}/app" , "${tp::tp_dir}/shellvars" , "${tp::tp_dir}/test", "${tp::tp_dir}/info", "${tp::tp_dir}/debug"]
$dirs.each | $d | {
file { $d:
ensure => $dir_ensure,
purge => $purge_dirs,
force => $purge_dirs,
recurse => $purge_dirs,
}
$work_dirs = [$tp::data_dir, $tp::download_dir , $tp::extract_dir , $tp::flags_dir]
$work_dirs.each | $d | {
file { $d:
ensure => $dir_ensure,
}
$work_dirs = [$tp::data_dir, $tp::download_dir , $tp::extract_dir , $tp::flags_dir]
$work_dirs.each | $d | {
file { $d:
ensure => $dir_ensure,
# purge => $purge_dirs,
# force => $purge_dirs,
# recurse => $purge_dirs,
}
}
$epp_params = {
'real_ruby_path' => $real_ruby_path,
'options' => $real_options,
'suppress_tp_warnings' => $suppress_tp_warnings,
'suppress_tp_output' => $suppress_tp_output,
'tp_dir' => $tp::tp_dir,
}
file { $tp::tp_path:
path => $tp::tp_path,
content => epp('tp/tp.epp', $epp_params),
}

if $facts['os']['family'] == 'windows' {
file { "${tp::tp_path}.bat":
content => epp('tp/tp.bat.epp'),
}
} else {
file { '/usr/sbin/tp':
ensure => link,
target => $tp::tp_path,
}
}
}
$epp_params = {
'real_ruby_path' => $real_ruby_path,
'options' => $real_options,
'suppress_tp_warnings' => $suppress_tp_warnings,
'suppress_tp_output' => $suppress_tp_output,
'tp_dir' => $tp::tp_dir,
}
file { $tp::tp_path:
path => $tp::tp_path,
content => epp('tp/tp.epp', $epp_params),
}

file { 'bin dir':
ensure => $dir_ensure,
path => "${tp::tp_dir}/bin",
source => $real_tp_params['bin']['args']['source'],
recurse => true,
}
file { 'info scripts':
ensure => $dir_ensure,
path => "${tp::tp_dir}/bin/run_info",
source => $info_source,
recurse => true,
if $facts['os']['family'] == 'windows' {
file { "${tp::tp_path}.bat":
content => epp('tp/tp.bat.epp'),
}
file { 'package_info':
mode => '0755',
path => "${tp::tp_dir}/bin/run_info/package_info",
content => epp('tp/run_info/package_info.epp'),
} else {
file { '/usr/sbin/tp':
ensure => link,
target => $tp::tp_path,
}
}

file { $info_script_path:
mode => '0755',
path => $info_script_path,
content => epp($info_script_template, { 'options' => $real_options }),
}
file { 'bin dir':
ensure => $dir_ensure,
path => "${tp::tp_dir}/bin",
source => $real_tp_params['bin']['args']['source'],
recurse => true,
}
file { 'info scripts':
ensure => $dir_ensure,
path => "${tp::tp_dir}/bin/run_info",
source => $info_source,
recurse => true,
}
file { 'package_info':
mode => '0755',
path => "${tp::tp_dir}/bin/run_info/package_info",
content => epp('tp/run_info/package_info.epp'),
}

file { 'debug scripts':
ensure => $dir_ensure,
path => "${tp::tp_dir}/bin/run_debug",
source => $debug_source,
}
file { 'package_debug':
mode => '0755',
path => "${tp::tp_dir}/bin/run_debug/package_debug",
content => epp('tp/run_debug/package_debug.epp'),
}
file { $debug_script_path:
mode => '0755',
path => $debug_script_path,
content => epp($debug_script_template, { 'options' => $real_options }),
}
file { $info_script_path:
mode => '0755',
path => $info_script_path,
content => epp($info_script_template, { 'options' => $real_options }),
}

file { 'debug scripts':
ensure => $dir_ensure,
path => "${tp::tp_dir}/bin/run_debug",
source => $debug_source,
}
file { 'package_debug':
mode => '0755',
path => "${tp::tp_dir}/bin/run_debug/package_debug",
content => epp('tp/run_debug/package_debug.epp'),
}
file { $debug_script_path:
mode => '0755',
path => $debug_script_path,
content => epp($debug_script_template, { 'options' => $real_options }),
}
}
}
8 changes: 4 additions & 4 deletions manifests/conf.pp
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,14 @@
$default_validate_cmd = $validate_cmd ? {
'' => undef,
String => $validate_cmd,
Hash => pick_default(getvar("settings.validate_cmd.${base_dir}"), undef),
Hash => getvar("settings.validate_cmd.${base_dir}"),
Undef => undef,
}
$real_validate_cmd = $validate_syntax ? {
undef => $default_validate_cmd,
true => $default_validate_cmd,
false => undef,
}

# Resources
if $path_parent_create {
$path_parent = dirname($real_path)
Expand Down Expand Up @@ -446,7 +445,7 @@
$settings = $tp_settings + $settings_hash

$tp_options = tp_lookup($app,"options::${base_file}",$data_module,'merge')
$options = $tp_options + $options_hash
$options = deep_merge($tp_options,$options_hash,$my_options,)

if $file and $file != '' {
$prefix = $scope ? {
Expand Down Expand Up @@ -490,7 +489,7 @@

# If user doesn't provide a $content, $template or $epp but provides $options_hash we check
# if on tinydata is set config_file_format
if $content_params =~ Undef and $settings[config_file_format] and $options_hash != {} {
if $content_params =~ Undef and $settings[config_file_format] and $options != {} {
$manage_content = $settings[config_file_format] ? {
'yaml' => to_yaml($options_hash),
'json' => to_json($options_hash),
Expand Down Expand Up @@ -532,6 +531,7 @@
}

$default_validate_cmd = $settings['validate_cmd'] ? {
'' => undef,
String => $settings['validate_cmd'],
Hash => $settings['validate_cmd'][$base_dir],
Undef => undef,
Expand Down
4 changes: 3 additions & 1 deletion manifests/copy_file.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
if $overwrite {
$exec_creates = undef
$exec_unless = "diff ${source} ${path} >/dev/null"
$cp_force = '-f'
} else {
$exec_creates = $path
$exec_unless = undef
$cp_force = ''
}
if $ensure == 'present' {
exec { "tp::copy_file ${title}":
command => "cp ${source} ${path}",
command => "cp ${cp_force} ${source} ${path}",
path => $facts['path'],
creates => $exec_creates,
unless => $exec_unless,
Expand Down
13 changes: 7 additions & 6 deletions manifests/create_dir.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
define tp::create_dir (
Optional[String] $owner = undef,
Optional[String] $group = undef,
Optional[Stdlib::Filemode] $mode = undef,
Optional[Stdlib::Filemode] $mode = undef,
Stdlib::AbsolutePath $path = $title,
) {
$mkdir_command = $facts['os']['family'] ? {
Expand All @@ -23,10 +23,10 @@
}

exec { "Create directory ${title}":
command => $mkdir_command,
path => $facts['path'],
creates => $path,
provider => $command_provider,
command => $mkdir_command,
path => $facts['path'],
creates => $path,
# provider => $command_provider,
}

if $facts['os']['family'] != 'windows' {
Expand All @@ -45,10 +45,11 @@
}
}
if $mode {
$short_mode = regsubst($mode, '^0', '')
exec { "chmod ${mode} ${title}":
command => "chmod '${mode}' '${path}'",
path => '/bin:/sbin:/usr/sbin:/usr/bin',
onlyif => "[ 0\$(stat -c '%a' '${path}') != '${mode}' ]",
onlyif => "[ \$(stat -c '%a' '${path}') != '${short_mode}' ]",
}
}
}
Expand Down
Loading
Loading