From ac1951dbd2fa9d28d0dbfcf81d7432768c4614e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Oct 2022 01:37:14 +0200 Subject: general cleanup. --- manifests/filter.pp | 17 +++-------------- manifests/init.pp | 13 +++++++------ manifests/nginx.pp | 34 +++++++++++++++++----------------- 3 files changed, 27 insertions(+), 37 deletions(-) diff --git a/manifests/filter.pp b/manifests/filter.pp index 2dda015..686acc3 100644 --- a/manifests/filter.pp +++ b/manifests/filter.pp @@ -25,8 +25,8 @@ define cgit::filter ( $dest = "${cgit::filterpath}/${filtername}-filter" file { $dest: - ensure => file, - mode => type ? { + ensure => file, + mode => $type ? { 'lua' => '0444', 'exec' => '0555', } @@ -35,19 +35,8 @@ define cgit::filter ( * => $file_props, } - concat::fragment { "cgit config ${}": + concat::fragment { "cgit config filter ${filtername}": target => $::cgit::cgitrc, content => "${filter_name}-filter=${type}:${dest}\n", } - - [$about_filter, $source_filter].each |$f| { - file { "${filterpath}/${f}": - ensure => file, - source => "puppet:///modules/cgit/filters/${f}", - mode => stdlib::extname($f) ? { - '.lua' => '0444', - default => '0555', - }, - } - } } diff --git a/manifests/init.pp b/manifests/init.pp index 451efe0..a5dd09c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,14 +1,14 @@ class cgit ( - String $root = '/var/www/cgit', - String $filterpath = '/usr/lib/cgit/puppet-controlled-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 = '', - String $scan_path, - Array[String] $clone_url, Boolean $enable_http_clone = false, Array[String] $public_repos = [], Array[Struct[{ @@ -40,7 +40,7 @@ class cgit ( } concat::fragment { 'cgit config lower half': - order => 99, + order => 99, content => epp('cgit/lower.epp'), target => $::cgit::cgitrc, } @@ -94,9 +94,10 @@ class cgit ( } case $manage_server { - false: {} 'nginx': { include ::cgit::nginx } + default: { + } } } diff --git a/manifests/nginx.pp b/manifests/nginx.pp index d62229f..7146e05 100644 --- a/manifests/nginx.pp +++ b/manifests/nginx.pp @@ -2,7 +2,7 @@ class cgit::nginx { if ($cgit::certname == undef) { nginx::resource::server { 'cgit': - server_name => [ $cgit::server_name, ], + server_name => [ $cgit::server_name, ], access_log => 'absent', error_log => 'absent', index_files => [], @@ -13,7 +13,7 @@ class cgit::nginx { } } else { nginx::resource::server { 'cgit': - server_name => [ $cgit::server_name, ], + server_name => [ $cgit::server_name, ], access_log => 'absent', error_log => 'absent', index_files => [], @@ -29,23 +29,23 @@ class cgit::nginx { nginx::resource::location { '@cgit': fastcgi_params => 'fastcgi_params', - fastcgi_param => { + fastcgi_param => { 'SCRIPT_FILENAME' => '/usr/lib/cgit/cgit.cgi', - 'PATH_INFO' => '$fastcgi_script_name', - 'QUERY_STRING' => '$args', + 'PATH_INFO' => '$fastcgi_script_name', + 'QUERY_STRING' => '$args', }, - ssl_only => $cgit::certname != undef, - fastcgi => 'unix:/run/fcgiwrap.socket', - server => [ + ssl_only => $cgit::certname != undef, + fastcgi => 'unix:/run/fcgiwrap.socket', + server => [ 'cgit', - ], + ], } file { $cgit::htpasswd: ensure => file, content => $cgit::users.map |$user| { [$user['name'], $user['pass']].join(':') - }.join("\n") + }.join("\n") } # TODO each repo name should be regex-escaped @@ -57,7 +57,7 @@ class cgit::nginx { priority => 450, fastcgi => 'unix:/run/fcgiwrap.socket', fastcgi_params => 'fastcgi_params', - fastcgi_param => { + fastcgi_param => { 'SCRIPT_FILENAME' => '/usr/lib/git-core/git-http-backend', 'GIT_PROJECT_ROOT' => $cgit::scan_path, 'GIT_HTTP_EXPORT_ALL' => '""', @@ -67,15 +67,15 @@ class cgit::nginx { nginx::resource::location { '~ (.*\.git/.*)': - server => 'cgit', - ssl_only => $cgit::certname != undef, - location_cfg_append => { + server => 'cgit', + ssl_only => $cgit::certname != undef, + location_cfg_append => { auth_basic => '"CGit login"', auth_basic_user_file => $cgit::htpasswd, }, - fastcgi => 'unix:/run/fcgiwrap.socket', - fastcgi_params => 'fastcgi_params', - fastcgi_param => { + fastcgi => 'unix:/run/fcgiwrap.socket', + fastcgi_params => 'fastcgi_params', + fastcgi_param => { 'SCRIPT_FILENAME' => '/usr/lib/git-core/git-http-backend', 'GIT_PROJECT_ROOT' => $cgit::scan_path, 'GIT_HTTP_EXPORT_ALL' => '""', -- cgit v1.2.3