Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
Joris VAN ACOLEYEN committed Aug 2, 2024
1 parent 79be90f commit 60c9a1a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 52 deletions.
75 changes: 26 additions & 49 deletions manifests/config/project.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
# The group permission that rundeck is installed as.
# @param projects_dir
# Directory where some project config will be stored.
# @param scm_import_config
# A hash of name value pairs representing properties for the scm-import.json file.
# @param scm_export_config
# A hash of name value pairs representing properties for the scm-export.json file
# @param scm_config
# A hash of name value pairs representing properties for the scm.json file.
#
define rundeck::config::project (
Enum['absent', 'present'] $ensure = 'present',
Expand All @@ -47,8 +45,7 @@
String[1] $owner = 'rundeck',
String[1] $group = 'rundeck',
Stdlib::Absolutepath $projects_dir = '/var/lib/rundeck/projects',
Optional[Rundeck::Scm] $scm_import_config = undef,
Optional[Rundeck::Scm] $scm_export_config = undef,
Optional[Rundeck::Scm] $scm_config = undef,
) {
include rundeck::cli

Expand Down Expand Up @@ -108,7 +105,7 @@
}
}

if $scm_import_config {
if $scm_config {
ensure_resource('file', "${projects_dir}/${name}",
{
'ensure' => 'directory',
Expand All @@ -118,51 +115,31 @@
}
)

file { "${projects_dir}/${name}/scm-import.json":
ensure => file,
owner => $owner,
group => $group,
mode => '0644',
content => stdlib::to_json($scm_import_config),
}

$_command = "rd projects scm setup -p '${name}' -i import -t ${scm_import_config['type']} -f ${projects_dir}/${name}/scm-import.json"

exec { "Setup/update SCM import config for ${name}":
command => "env RD_FORMAT=default ${_command}",
path => ['/bin', '/usr/bin', '/usr/local/bin'],
environment => $rundeck::cli::environment,
unless => "rd_scm_diff.sh ${projects_dir} '${name}' import",
require => File["${projects_dir}/${name}/scm-import.json"],
}
}

if $scm_export_config {
ensure_resource('file', "${projects_dir}/${name}",
{
'ensure' => 'directory',
'owner' => $owner,
'group' => $group,
'mode' => '0755'
$scm_config.each |$integration, $type, $config| {
file { "${projects_dir}/${name}/scm-${integration}.json":
ensure => file,
owner => $owner,
group => $group,
mode => '0644',
content => stdlib::to_json($config),
}
)

file { "${projects_dir}/${name}/scm-export.json":
ensure => file,
owner => $owner,
group => $group,
mode => '0644',
content => stdlib::to_json($scm_export_config),
}

$_command = "rd projects scm setup -p '${name}' -i export -t ${scm_export_config['type']} -f ${projects_dir}/${name}/scm-export.json"
$_command = [
'env RD_FORMAT=default',
'rd projects scm setup',
"-p '${name}'",
"-i ${integration}",
"-t ${type}",
"-f ${projects_dir}/${name}/scm-${integration}.json",
].join(' ')

exec { "Setup/update SCM export config for ${name}":
command => "env RD_FORMAT=default ${_command}",
path => ['/bin', '/usr/bin', '/usr/local/bin'],
environment => $rundeck::cli::environment,
unless => "rd_scm_diff.sh ${projects_dir} '${name}' export",
require => File["${projects_dir}/${name}/scm-export.json"],
exec { "Setup/update SCM ${integration} config for ${name}":
command => $_command,
path => ['/bin', '/usr/bin', '/usr/local/bin'],
environment => $rundeck::cli::environment,
unless => "rd_scm_diff.sh ${projects_dir} '${name}' ${integration}",
require => File["${projects_dir}/${name}/scm-${integration}.json"],
}
}
}
}
Expand Down
12 changes: 9 additions & 3 deletions types/scm.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @summary Rundeck project type.
# @summary Rundeck scm type.
type Rundeck::Scm = Struct[{
'type' => String[1],
'config' => Hash[String[1], String],
'import' => Struct[{
'type' => String[1],
'config' => Hash[String[1], String],
}],
'export' => Struct[{
'type' => String[1],
'config' => Hash[String[1], String],
}],
}]

0 comments on commit 60c9a1a

Please sign in to comment.