diff --git a/data/common/common.yaml b/data/common/common.yaml --- a/data/common/common.yaml +++ b/data/common/common.yaml @@ -2124,6 +2124,15 @@ http_compress: false sniffer_timeout: 60 +swh::deploy::scheduler::journal_client::config_file: "%{lookup('swh::deploy::scheduler::conf_dir')}/journal-client.yml" +swh::deploy::scheduler::journal_client::user: "%{alias('swh::deploy::scheduler::user')}" +swh::deploy::scheduler::journal_client::group: "%{alias('swh::deploy::scheduler::group')}" +swh::deploy::scheduler::journal_client::config: + <<: *swh_scheduler_local_config + journal: + brokers: "%{alias('swh::deploy::journal::brokers')}" + group_id: swh.scheduler.journal_client + # Main lister configuration swh::deploy::worker::lister::db::user: swh-lister swh::deploy::worker::lister::db::name: swh-lister diff --git a/manifests/site.pp b/manifests/site.pp --- a/manifests/site.pp +++ b/manifests/site.pp @@ -146,7 +146,7 @@ } node 'scheduler0.internal.staging.swh.network' { - include role::swh_scheduler + include role::swh_scheduler_with_journal_client include profile::postgresql::client } diff --git a/site-modules/profile/manifests/swh/deploy/scheduler/journal_client.pp b/site-modules/profile/manifests/swh/deploy/scheduler/journal_client.pp new file mode 100644 --- /dev/null +++ b/site-modules/profile/manifests/swh/deploy/scheduler/journal_client.pp @@ -0,0 +1,35 @@ +# Deployment of the swh.search.journal_client +class profile::swh::deploy::scheduler::journal_client { + include ::profile::swh::deploy::base_scheduler + include ::profile::swh::deploy::journal + + $config_file = lookup('swh::deploy::scheduler::journal_client::config_file') + $config = lookup('swh::deploy::scheduler::journal_client::config') + + $user = lookup('swh::deploy::scheduler::journal_client::user') + $group = lookup('swh::deploy::scheduler::journal_client::group') + + $service_name = 'swh-scheduler-journal-client' + $unit_name = "${service_name}.service" + + file {$config_file: + ensure => present, + owner => 'root', + group => $group, + mode => '0644', + content => inline_template("<%= @config.to_yaml %>\n"), + notify => Service[$service_name], + } + + # Template uses variables + # - $user + # - $group + # + ::systemd::unit_file {$unit_name: + ensure => present, + content => template("profile/swh/deploy/journal/${unit_name}.erb"), + } ~> service {$service_name: + ensure => running, + enable => true, + } +} diff --git a/site-modules/profile/templates/swh/deploy/journal/swh-scheduler-journal-client.service.erb b/site-modules/profile/templates/swh/deploy/journal/swh-scheduler-journal-client.service.erb new file mode 100644 --- /dev/null +++ b/site-modules/profile/templates/swh/deploy/journal/swh-scheduler-journal-client.service.erb @@ -0,0 +1,18 @@ +# Scheduler Journal Client unit file +# Managed by puppet class profile::swh::deploy::scheduler_journal_client +# Changes will be overwritten + +[Unit] +Description=Software Heritage Scheduler Journal Client +After=network.target + +[Service] +User=<%= @user %> +Group=<%= @group %> +Type=simple +ExecStart=/usr/bin/swh scheduler --config-file <%= @config_file %> journal-client +Restart=always +RestartSec=10 + +[Install] +WantedBy=multi-user.target diff --git a/site-modules/role/manifests/swh_scheduler_with_journal_client.pp b/site-modules/role/manifests/swh_scheduler_with_journal_client.pp new file mode 100644 --- /dev/null +++ b/site-modules/role/manifests/swh_scheduler_with_journal_client.pp @@ -0,0 +1,4 @@ +# Install the swh-scheduler stack + the scheduler's journal client +class role::swh_scheduler_with_journal_client inherits role::swh_scheduler { + include profile::swh::deploy::scheduler::journal_client +}