diff --git a/manifests/main/config.pp b/manifests/main/config.pp index e2b9c4b..ba71eba 100644 --- a/manifests/main/config.pp +++ b/manifests/main/config.pp @@ -7,4 +7,9 @@ class confdroid_gitea::main::config ( ) inherits confdroid_gitea::params { include confdroid_gitea::main::service + + exec { 'systemd-daemon-reload': + command => '/bin/systemctl daemon-reload', + refreshonly => true, + } } diff --git a/manifests/main/files.pp b/manifests/main/files.pp index 5ad8ea4..fecedb2 100644 --- a/manifests/main/files.pp +++ b/manifests/main/files.pp @@ -31,5 +31,14 @@ class confdroid_gitea::main::files ( mode => '0640', content => template($ga_config_erb), } + + file { $ga_service_file: + ensure => 'file', + owner => 'root', + group => 'root', + mode => '0644', + content => template($ga_service_erb), + notify => Exec['systemd-daemon-reload'], + } } } diff --git a/manifests/main/service.pp b/manifests/main/service.pp index aa9782b..81dd4d8 100644 --- a/manifests/main/service.pp +++ b/manifests/main/service.pp @@ -9,5 +9,14 @@ class confdroid_gitea::main::service ( if $ga_host_fqdn == $fqdn { require confdroid_gitea::firewall::iptables require confdroid_gitea::main::files + + service { $ga_service_name: + ensure => 'running', + enable => true, + hasrestart => true, + hasstatus => true, + require => File[$ga_service_file], + subscribe => File[$ga_config_file], + } } } diff --git a/manifests/params.pp b/manifests/params.pp index ac490fd..cf23557 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -133,6 +133,11 @@ class confdroid_gitea::params ( # files $ga_config_file = "${ga_conf_dir}/app.ini" $ga_config_erb = 'confdroid_gitea/app.ini.erb' + $ga_service_file = '/etc/systemd/system/gitea.service' + $ga_service_erb = 'confdroid_gitea/gitea_service.erb' + +# Service + $ga_service_name = 'gitea' # includes must be last include confdroid_gitea::main::config diff --git a/templates/gitea_service.erb b/templates/gitea_service.erb new file mode 100644 index 0000000..d3a516a --- /dev/null +++ b/templates/gitea_service.erb @@ -0,0 +1,26 @@ +### File created by Puppet ### +### manual changes will be lost ### +### reference https://github.com/go-gitea/gitea/blob/release/v1.25/contrib/systemd/gitea.service ### +########################################################################################################### + +[Unit] +Description=Gitea (Git with a cup of tea) +After=network.target + +Wants=<%= @ga_db_type %>.service +After=<%= @ga_db_type %>.service + +[Service] +# Uncomment the next line if you have repos with lots of files and get a HTTP 500 error because of that +# LimitNOFILE=524288:524288 +RestartSec=2s +Type=simple +User=<%= @ga_user %> +Group=<%= @ga_user %> +WorkingDirectory=<%= @ga_working_dir %> +ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini +Restart=always +Environment=USER=<%= @ga_user %> HOME=/home/<%= @ga_user %> GITEA_WORK_DIR=<%= @ga_working_dir %> + +[Install] +WantedBy=multi-user.target \ No newline at end of file