diff --git a/manifests/config/project.pp b/manifests/config/project.pp index 4db6f63f..5f4f4fe0 100644 --- a/manifests/config/project.pp +++ b/manifests/config/project.pp @@ -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', @@ -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 @@ -108,7 +105,7 @@ } } - if $scm_import_config { + if $scm_config { ensure_resource('file', "${projects_dir}/${name}", { 'ensure' => 'directory', @@ -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"], + } } } } diff --git a/types/scm.pp b/types/scm.pp index 49d29629..23b45620 100644 --- a/types/scm.pp +++ b/types/scm.pp @@ -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], + }], }]