Skip to content

Commit

Permalink
3.7.0 (#103)
Browse files Browse the repository at this point in the history
* Various fixes

* fix tests

* Preparing 3.7.0

* Tests

* Shall we ignore broken tests for old data?

* tp-desktop repo renamed to tp_desktop
  • Loading branch information
alvagante authored Dec 13, 2022
1 parent 44673a3 commit 3e65339
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 45 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# CHANGELOG

## 3.7.0

- tp desktop noapply command renamed to tp desktop preview
- Added /usr/sbin/tp symbolic link to avoid errors due to incorrect PATH
- Fixed tp::repo with setting repo_file_url
- Fixed tp test with packages using pip3
- Do not clone locally tp module when using tp desktop command
- Added new settings: website_url, winget_package_name, choco_package_name, docker_image

## 3.6.2

- Added tp debug command, define and task. Added debug_commands tinydata key.
Expand Down
2 changes: 1 addition & 1 deletion files/run_debug/pid
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if [ "${pid_file_path}" != '' ]; then
pid=$(cat "${pid_file_path}")
pid=$(cat "${pid_file_path}" | xargs)
echo_title "$HOSTNAME - $app - pid: ${pid}"
if [ $(which lsof) ]; then
show_command "lsof | grep ${pid} "
Expand Down
1 change: 1 addition & 0 deletions manifests/conf.pp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@
$manage_content = $settings[config_file_format] ? {
'yaml' => to_yaml($options_hash),
'json' => to_json($options_hash),
'hcl' => to_hcl($options_hash),
'inifile' => template('tp/inifile.erb'),
'inifile_with_stanzas' => template('tp/inifile_with_stanzas.erb'),
'spaced' => template('tp/spaced.erb'),
Expand Down
17 changes: 7 additions & 10 deletions manifests/dir.pp
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@
Variant[Boolean,String] $config_dir_notify = true,
Variant[Boolean,String] $config_dir_require = true,

Variant[Undef,Boolean] $purge = undef,
Variant[Undef,Boolean] $recurse = undef,
Variant[Undef,Boolean] $force = undef,
Variant[Undef,Boolean] $purge = undef,
Variant[Undef,Boolean,Enum['remote']] $recurse = undef,
Variant[Undef,Boolean] $force = undef,

Hash $settings_hash = {},

Expand All @@ -174,8 +174,7 @@
}

if $title =~ /^\/.*$/ {
# If title is an absolute path do a safe lookup to
# a dummy app
# If title is an absolute path do a safe lookup to a dummy app
$tp_settings = tp_lookup('test','settings','tinydata','merge')
$title_path = $title
} else {
Expand All @@ -196,8 +195,7 @@
$manage_group = pick($group, $settings[config_dir_group])

# Set require if package_name is present and title is not a abs path
if $settings[package_name] and $settings[package_name] != ''
and $title !~ /^\/.*$/ {
if $settings[package_name] and $settings[package_name] != '' {
$package_ref = "Package[${settings[package_name]}]"
} else {
$package_ref = undef
Expand All @@ -209,9 +207,8 @@
default => $config_dir_require,
}

# Set notify if service_name is present and title is not a abs path
if $settings[service_name] and $settings[package_name] != ''
and $title !~ /^\/.*$/ {
# Set notify if service_name is present
if $settings[service_name] and $settings[service_name] != '' {
$service_ref = "Service[${settings[service_name]}]"
} else {
$service_ref = undef
Expand Down
5 changes: 5 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@
mode => $tp_mode,
content => template('tp/tp.bat.erb'),
}
} else {
file { '/usr/sbin/tp':
ensure => link,
target => $tp_path,
}
}

if $info_enable {
Expand Down
11 changes: 4 additions & 7 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,10 @@
'RedHat' => undef,
'Suse' => 'Exec["zypper refresh"]',
}
file { $repo_file_path:
ensure => $ensure,
path => $repo_file_path,
owner => root,
group => root,
mode => '0644',
source => $repo_file_url,
exec { "Download repo file for ${title}":
command => "wget ${settings[repo_file_url]} -q -O ${repo_file_path}",
creates => $repo_file_path,
path => $facts['path'],
notify => $repo_file_notify,
}
}
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "example42-tp",
"version": "3.6.2",
"version": "3.7.0",
"author": "example42",
"summary": "Tiny Puppet",
"license": "Apache-2.0",
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/tp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
on_supported_os(facterversion: '2.4').each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }
file_resource_count = 14
file_resource_count = file_resource_count + 1 if os == 'windows-2008 R2-x64' or os == 'windows-2012 R2-x64'
file_resource_count = 15
file_resource_count = file_resource_count if os == 'windows-2008 R2-x64' or os == 'windows-2012 R2-x64'
resource_count = file_resource_count + 0

context 'with default params' do
Expand Down
4 changes: 2 additions & 2 deletions spec/defines/info_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
}

# Resource counts with normal tp::info
total_count = 15 # tp::info + file + tp
total_count = 16 # tp::info + file + tp
package_count = 0
service_count = 0
exec_count = 0
file_count = 14 # Includes files from tp
file_count = 15 # Includes files from tp

# Define if there's a service to check
if appdata['service_name']
Expand Down
4 changes: 2 additions & 2 deletions spec/defines/test_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
}

# Resource counts with normal tp::test
total_count = 15 # tp::test + file + tp
total_count = 16 # tp::test + file + tp
package_count = 0
service_count = 0
exec_count = 0
file_count = 14 # Includes files from tp
file_count = 15 # Includes files from tp

# Define if there's a service to check
if appdata['service_name']
Expand Down
42 changes: 23 additions & 19 deletions templates/tp.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ NODENAME = %x{hostname}.gsub("\n",'')
REPO_DIR = %x{pwd}.gsub("\n",'')
GIT_COMMAND = %x{which git}.gsub("\n",'')
PUPPET_COMMAND = %x{which puppet}.gsub("\n",'')
PIP_COMMAND = %x{which pip}.size.>(0) ? %x{which pip}.gsub("\n",'') : %x{which pip3}.gsub("\n",'')

<% if @suppress_tp_warnings -%>
suppress_warnings = " 2>&1 | grep -v 'Warning'"
Expand Down Expand Up @@ -145,8 +146,8 @@ def tp_test(app)
run_command("gem list | grep " + s + " " + COMMAND_REDIR , "#{NODENAME} - #{app} - package: #{s}")
elsif settings['package_provider'] == 'puppet_gem'
run_command("/opt/puppetlabs/puppet/bin/gem list | grep " + s + " " + COMMAND_REDIR , "#{NODENAME} - #{app} - package: #{s}")
elsif settings['package_provider'] == 'pip'
run_command("pip list | grep " + s + " " + COMMAND_REDIR , "#{NODENAME} - #{app} - package: #{s}")
elsif settings['package_provider'] == 'pip' or settings['package_provider'] == 'pip3'
run_command(PIP_COMMAND + " list --format=columns | grep " + s + " " + COMMAND_REDIR , "#{NODENAME} - #{app} - package: #{s}")
else
run_command("<%= @options['check_package_command'] %> #{s} #{COMMAND_REDIR}" , "#{NODENAME} - #{app} - package: #{s}")
end
Expand Down Expand Up @@ -252,8 +253,13 @@ def desktop_apply(desktop_name,extra_options)
begin
repo_dir=REPO_DIR
repo_dirname=File.basename(repo_dir)
local_modulepath=`puppet config print modulepath`.strip
if File.exists?("#{repo_dir}/environment.conf")
modulepath="--modulepath #{repo_dir}/site:#{repo_dir}/modules:/etc/puppetlabs/code/modules"
<% if @osfamily == 'windows' -%>
modulepath="--modulepath #{repo_dir}/site:#{local_modulepath}:C:/ProgramData/PuppetLabs/code/environments/production/modules"
<% else -%>
modulepath="--modulepath #{repo_dir}/site:#{local_modulepath}:/etc/puppetlabs/code/environments/production/modules"
<% end -%>
environmentpath="--environmentpath #{repo_dir}/.. --environment #{repo_dirname}"
hiera_config="--hiera_config #{repo_dir}/hiera.yaml"
verbose_options="--verbose --report --show_diff --summarize --detailed-exitcodes"
Expand All @@ -273,7 +279,7 @@ def desktop_apply(desktop_name,extra_options)
exit 1
end
end
def desktop_noapply(desktop_name,extra_options)
def desktop_preview(desktop_name,extra_options)
desktop_apply(desktop_name,['--noop'] + extra_options)
end

Expand Down Expand Up @@ -324,15 +330,13 @@ def desktop_init(url,repo_dir)
begin
%x[git clone #{url} #{repo_dir}/tp_desktop]
puts
begin
puts "Cloning done! Now we are going to install the tp module in #{repo_dir}/tp_desktop/modules"
#exec(puppet module install example42/tp --modulepath "#{repo_dir}/tp_desktop/modules")
# %x[puppet module install example42/tp --modulepath #{repo_dir}/tp_desktop/modules]
show_command("puppet module install example42/tp --modulepath #{repo_dir}/tp_desktop/modules", "#{NODENAME} - Installing tp module")
show_command("puppet module install puppetlabs/vcsrepo --modulepath #{repo_dir}/tp_desktop/modules", "#{NODENAME} - Installing vcsrepo module")
rescue
puts "Failed to install the tp module! "
end
# begin
# puts "Cloning done! Now we are going to install the tp module in #{repo_dir}/tp_desktop/modules"
# show_command("puppet module install example42/tp --modulepath #{repo_dir}/tp_desktop/modules", "#{NODENAME} - Installing tp module")
# show_command("puppet module install puppetlabs/vcsrepo --modulepath #{repo_dir}/tp_desktop/modules", "#{NODENAME} - Installing vcsrepo module")
# rescue
# puts "Failed to install the tp module! "
# end
puts
puts "You can now move into the created dir (cd #{repo_dir}/tp_desktop) and run tp desktop commands."
rescue
Expand Down Expand Up @@ -467,13 +471,13 @@ when 'desktop'
echo_title "Initializing a new tp desktop environment"
case infoblock
when 'tp'
url='https://github.com/example42/tp-desktop.git'
url='https://github.com/example42/tp_desktop.git'
when 'advanced'
url='https://github.com/example42/tp-desktop-advanced.git'
url='https://github.com/example42/tp_desktop-advanced.git'
when 'psick'
url='https://github.com/example42/psick.git'
when 'all'
url='https://github.com/example42/tp-desktop.git'
url='https://github.com/example42/tp_desktop.git'
else
url=infoblock
end
Expand All @@ -483,9 +487,9 @@ when 'desktop'
echo_title "Applying desktop #{infoblock}"
desktop_apply(infoblock,ARGV[3..-1])
exit
when 'noapply'
when 'preview'
echo_title "Applying in noop mode (no real changes done) desktop #{infoblock}"
desktop_noapply(infoblock,ARGV[3..-1])
desktop_preview(infoblock,ARGV[3..-1])
exit
when 'list'
echo_title "Listing desktops under #{REPO_DIR}/data/desktops"
Expand All @@ -503,7 +507,7 @@ Available tp desktop actions (some may have extra args):
init: Initialise a tp desktop Puppet environment
list: List the available desktops (yaml files under data/desktops/)
show: Show the configurations of a desktop to apply
noapply: Apply in noop mode: do a safe run without changes of the specified desktop
preview: Preview the changes to apply, running puppet apply in noop mode
apply: Apply the specified desktop. If no desktop is specified, the default one is applied
EOF
end
Expand Down
7 changes: 6 additions & 1 deletion types/settings.pp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

Optional[nodaemon_args] => String,
Optional[dockerfile_prerequisites] => String,
Optional[docker_image] => String,

Optional[package_prerequisites] => Array,
Optional[tp_prerequisites] => Array,
Expand Down Expand Up @@ -97,5 +98,9 @@
Optional[user_config_file_mode] => String,
Optional[user_conf_dir_path] => Stdlib::Absolutepath,
Optional[user_data_dir_path] => Stdlib::Absolutepath,
Optional[home_dir_path] => Stdlib::Absolutepath,

Optional[website_url] => String,

Optional[winget_package_name] => String,
Optional[choco_package_name] => String,
}]

0 comments on commit 3e65339

Please sign in to comment.