Skip to content

Commit

Permalink
Merge branch 'testing'
Browse files Browse the repository at this point in the history
  • Loading branch information
richir-sunet committed Jan 30, 2025
2 parents f3ee774 + c017a1d commit 08c4869
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
44 changes: 28 additions & 16 deletions manifests/invent/client.pp
Original file line number Diff line number Diff line change
@@ -1,30 +1,42 @@
# SUNET Inventory Service
class sunet::invent::client(
String $invent_dir = '/opt/invent',
String $export_endpoint = '',
String $export_endpoint = '',
Integer $invent_retention_days = 30,
String $repo_path = '/var/cache/invent/repo',
String $repo_url = 'https://github.com/SUNET/invent.git',
) {
$host_os = String($facts['os']['name'], '%d')
$awk = $host_os ? {
alpine => 'gawk',
default => 'awk',
}
$script_dir = "${invent_dir}/scripts"

file { $invent_dir:
ensure => directory,
include sunet::packages::curl
include sunet::packages::git
include sunet::packages::jq

exec {'create_repo_path':
command => "mkdir -p ${repo_path}",
unless => "test -d ${repo_path}",
}
-> file { $script_dir:
ensure => directory,
exec { 'clone_invent_repo':
command => "git clone ${repo_url} ${repo_path}",
unless => "test -d ${repo_path}/.git"
}
-> file { "${script_dir}/invent.sh":
content => template('sunet/invent/invent.sh.erb'),
mode => '0700',
exec { 'update_invent_repo':
command => "sh -c 'cd ${repo_path} && git pull'"
}
-> sunet::scriptherder::cronjob { 'inventory':
cmd => "${script_dir}/invent.sh",
file { '/etc/default/invent-client':
ensure => 'file',
mode => '0644',
content => template('sunet/invent/invent-client.erb'),
}
sunet::scriptherder::cronjob { 'inventory':
cmd => "${repo_path}/client/invent.sh",
job_name => 'gather_inventory',
minute => '*/10',
user => 'root',
minute => '*/10',
}
# remove old script path to not get confused over what script is running
file { "${invent_dir}/scripts":
ensure => 'absent',
force => 'true',
}
}
4 changes: 4 additions & 0 deletions templates/invent/invent-client.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
INVENT_DIR="<%= @invent_dir%>"
INVENT_EXPORT_ENDPOINT="<%= @export_endpoint %>"
INVENT_HOST_OS="<%= @host_os %>"
INVENT_RETENTION_DAYS="<%= @invent_retention_days%>"

0 comments on commit 08c4869

Please sign in to comment.