Skip to content
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

win #115

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

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.
Jump to
Jump to file
Failed to load files.
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"
]
}
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 }),
}
}
}
4 changes: 2 additions & 2 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 @@ -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