diff options
Diffstat (limited to '')
-rw-r--r-- | manifests/init.pp | 197 |
1 files changed, 98 insertions, 99 deletions
diff --git a/manifests/init.pp b/manifests/init.pp index 6599301..9af59a4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -51,115 +51,114 @@ # CGIT filters to be managed. # @see cgit::filter class cgit ( - String $root_title, - String $root_desc, - String $scan_path, - Array[String] $clone_url = [], - String $root = '/var/www/cgit', - String $filterpath = '/usr/lib/cgit/puppet-controlled-filters', - String $root_readme_source = "puppet:///modules/${module_name}/root_readme", - Optional[String] $root_readme_content = undef, - Optional[String] $root_readme_sha256 = undef, - String $root_readme_extension = '', - Boolean $enable_http_clone = false, - Array[String] $public_repos = [], - Array[Struct[{ - name => String, - pass => String }]] $users = [], - Variant[Boolean, Enum['nginx']] $manage_server = false, - Optional[String] $server_name = undef, - Optional[String] $certname = undef, - String $htpasswd = '/var/lib/nginx/cgit-htpasswd', - String $cgitrc = '/etc/cgitrc', - Hash[String, Hash] $filters = {}, + String $root_title, + String $root_desc, + String $scan_path, + Array[String] $clone_url = [], + String $root = '/var/www/cgit', + String $filterpath = '/usr/lib/cgit/puppet-controlled-filters', + String $root_readme_source = "puppet:///modules/${module_name}/root_readme", + Optional[String] $root_readme_content = undef, + Optional[String] $root_readme_sha256 = undef, + String $root_readme_extension = '', # lint:ignore:params_empty_string_assignment + Boolean $enable_http_clone = false, + Array[String] $public_repos = [], + Array[Struct[{ + name => String, + pass => String, + }]] $users = [], + Variant[Boolean, Enum['nginx']] $manage_server = false, + Optional[String] $server_name = undef, + Optional[String] $certname = undef, + String $htpasswd = '/var/lib/nginx/cgit-htpasswd', + String $cgitrc = '/etc/cgitrc', + Hash[String, Hash] $filters = {}, ) { - - # TODO figure out where CSS comes from - - ensure_packages([ - 'git', - 'cgit', - ], { ensure => installed }) - - Cgit::Filter <| |> -> Concat[$cgitrc] - - concat { $cgitrc: - ensure => present, - } - - concat::fragment { 'cgit config upper half': - order => 0, - content => epp('cgit/upper.epp'), - target => $::cgit::cgitrc, - } - - concat::fragment { 'cgit config lower half': - order => 99, - content => epp('cgit/lower.epp'), - target => $::cgit::cgitrc, - } - - create_resources(cgit::filter, $filters) - - file { "${root}/logo": - ensure => directory, - } - - file { "${root}/logo/logo.png": - ensure => file, - source => 'puppet:///modules/cgit/logo.png', + # TODO figure out where CSS comes from + + ensure_packages([ + 'git', + 'cgit', + ], { ensure => installed }) + + Cgit::Filter <| |> -> Concat[$cgitrc] + + concat { $cgitrc: + ensure => present, + } + + concat::fragment { 'cgit config upper half': + order => 0, + content => epp('cgit/upper.epp'), + target => $cgitrc, + } + + concat::fragment { 'cgit config lower half': + order => 99, + content => epp('cgit/lower.epp'), + target => $cgitrc, + } + + create_resources(cgit::filter, $filters) + + file { "${root}/logo": + ensure => directory, + } + + file { "${root}/logo/logo.png": + ensure => file, + source => 'puppet:///modules/cgit/logo.png', + } + + file { "${root}/logo/logo_large.png": + ensure => file, + source => 'puppet:///modules/cgit/logo_large.png', + } + + $chksum = if $root_readme_sha256 != undef { + { + 'checksum' => 'sha256', + 'checksum_value' => $root_readme_sha256, } + } else { + {} + } - file { "${root}/logo/logo_large.png": - ensure => file, - source => 'puppet:///modules/cgit/logo_large.png', + $readme = "${root}/README${root_readme_extension}" + if $root_readme_content { + file { $readme: + ensure => file, + content => $root_readme_content, + * => $chksum, } - - $chksum = if $root_readme_sha256 != undef { - { - 'checksum' => 'sha256', - 'checksum_value' => $root_readme_sha256, - } - } else { - { } + } else { + file { $readme: + ensure => file, + source => $root_readme_source, + * => $chksum, } + } - $readme = "${root}/README${root_readme_extension}" - if $root_readme_content { - file { $readme: - ensure => file, - content => $root_readme_content, - * => $chksum, - } - } else { - file { $readme: - ensure => file, - source => $root_readme_source, - * => $chksum, - } - } + file { ['/usr/local', '/usr/local/var']: + ensure => directory, + } - file { ['/usr/local', '/usr/local/var']: - ensure => directory, - } + file { '/usr/local/var/public-repos': + ensure => file, + content => ($public_repos << '').join("\n"), + } - file { '/usr/local/var/public-repos': - ensure => file, - content => ($public_repos << '').join("\n"), + if $manage_server { + if $server_name == undef { + fail('server_name must be set if manage_server is set') } + } - - if $manage_server { - if $server_name == undef { - fail('server_name must be set if manage_server is set') - } + case $manage_server { + 'nginx': { + include cgit::nginx } - - case $manage_server { - 'nginx': { - include ::cgit::nginx - } - default: { - } + default: { } + } } |