diff --git a/data/common/common.yaml b/data/common/common.yaml --- a/data/common/common.yaml +++ b/data/common/common.yaml @@ -2057,7 +2057,8 @@ swh::deploy::scheduler::sentry_swh_package: swh.scheduler swh::deploy::scheduler::sentry_environment: "%{alias('swh::deploy::environment')}" swh::deploy::scheduler::sentry_dsn: "https://%{lookup('swh::deploy::scheduler::sentry_token')}@sentry.softwareheritage.org/7" -swh::deploy::scheduler::conf_file: "%{hiera('swh::conf_directory')}/scheduler.yml" +swh::deploy::scheduler::conf_dir: "%{lookup('swh::conf_directory')}/scheduler" +swh::deploy::scheduler::conf_file: "%{hiera('swh::deploy::scheduler::conf_dir')}/listener-runner.yml" swh::deploy::scheduler::user: swhscheduler swh::deploy::scheduler::group: swhscheduler swh::deploy::scheduler::db::host: db.internal.softwareheritage.org @@ -2073,12 +2074,14 @@ <<: *swh_scheduler_local_config celery: task_broker: "%{alias('swh::deploy::scheduler::task_broker')}" +swh::deploy::scheduler::packages: + - python3-swh.scheduler swh::deploy::scheduler::remote::sentry_swh_package: swh.scheduler swh::deploy::scheduler::remote::sentry_environment: "%{alias('swh::deploy::environment')}" swh::deploy::scheduler::remote::sentry_dsn: "%{alias('swh::deploy::scheduler::sentry_dsn')}" -swh::deploy::scheduler::remote::conf_dir: "%{hiera('swh::conf_directory')}/backend" -swh::deploy::scheduler::remote::conf_file: "%{hiera('swh::deploy::scheduler::remote::conf_dir')}/scheduler.yml" +swh::deploy::scheduler::remote::conf_dir: "%{alias('swh::deploy::scheduler::conf_dir')}" +swh::deploy::scheduler::remote::conf_file: "%{hiera('swh::deploy::scheduler::remote::conf_dir')}/backend.yml" swh::deploy::scheduler::remote::user: swhscheduler swh::deploy::scheduler::remote::group: swhscheduler swh::deploy::scheduler::remote::backend::listen::host: 127.0.0.1 @@ -2105,8 +2108,7 @@ - host: esnode1.internal.softwareheritage.org port: 9200 -swh::deploy::scheduler::archive::conf_dir: "%{hiera('swh::conf_directory')}/backend" -swh::deploy::scheduler::archive::conf_file: "%{hiera('swh::deploy::scheduler::archive::conf_dir')}/elastic.yml" +swh::deploy::scheduler::archive::conf_file: "%{lookup('swh::deploy::scheduler::conf_dir')}/elastic.yml" swh::deploy::scheduler::archive::user: "%{hiera('swh::deploy::scheduler::user')}" swh::deploy::scheduler::archive::config: scheduler: "%{alias('swh::remote_service::scheduler::config::writable')}" diff --git a/site-modules/profile/manifests/swh/deploy/base_scheduler.pp b/site-modules/profile/manifests/swh/deploy/base_scheduler.pp new file mode 100644 --- /dev/null +++ b/site-modules/profile/manifests/swh/deploy/base_scheduler.pp @@ -0,0 +1,21 @@ +# Base class for scheduler related manifests +class profile::swh::deploy::base_scheduler { + $config_directory = lookup('swh::deploy::scheduler::conf_dir') + $user = lookup('swh::deploy::scheduler::user') + $group = lookup('swh::deploy::scheduler::group') + $config = lookup('swh::deploy::scheduler::config') + + $packages = lookup('swh::deploy::scheduler::packages') + + file {$config_directory: + ensure => 'directory', + owner => $user, + group => $group, + mode => '0755', + } + + package {$packages: + ensure => installed, + } + +} diff --git a/site-modules/profile/manifests/swh/deploy/scheduler.pp b/site-modules/profile/manifests/swh/deploy/scheduler.pp --- a/site-modules/profile/manifests/swh/deploy/scheduler.pp +++ b/site-modules/profile/manifests/swh/deploy/scheduler.pp @@ -1,5 +1,6 @@ # Deployment of swh-scheduler related utilities class profile::swh::deploy::scheduler { + $config_dir = lookup('swh::deploy::scheduler::conf_dir') $config_file = lookup('swh::deploy::scheduler::conf_file') $user = lookup('swh::deploy::scheduler::user') $group = lookup('swh::deploy::scheduler::group') @@ -22,13 +23,10 @@ $runner_unit_name = "${runner_service_name}.service" $runner_unit_template = "profile/swh/deploy/scheduler/${runner_service_name}.service.erb" - $packages = ['python3-swh.scheduler'] + $packages = lookup('swh::deploy::scheduler::packages') $services = [$listener_service_name, $runner_service_name] - package {$packages: - ensure => installed, - notify => Service[$services], - } + include profile::swh::deploy::base_scheduler file {$config_file: ensure => present, @@ -37,12 +35,17 @@ mode => '0640', content => inline_template("<%= @config.to_yaml %>\n"), notify => Service[$services], + require => File[$config_dir], } # purge legacy config file - $worker_conf_file = '/etc/softwareheritage/worker.ini' - file {$worker_conf_file: - ensure => absent, + $to_purge_legacy_files = [ '/etc/softwareheritage/scheduler.yml', '/etc/softwareheritage/backend'] + each($to_purge_legacy_files) | $to_purge| { + file {$to_purge: + ensure => absent, + recurse => true, + force => true, + } } # Template uses variables @@ -68,23 +71,25 @@ } service {$runner_service_name: - ensure => running, - enable => true, - require => [ + ensure => running, + enable => true, + require => [ Package[$packages], File[$config_file], Systemd::Unit_File[$runner_unit_name], ], + subscribe => Package[$packages], } service {$listener_service_name: - ensure => running, - enable => true, - require => [ + ensure => running, + enable => true, + require => [ Package[$packages], File[$config_file], Systemd::Unit_File[$listener_unit_name], ], + subscribe => Package[$packages], } # scheduler rpc server @@ -97,31 +102,21 @@ # task archival cron - $archive_config_dir = lookup('swh::deploy::scheduler::archive::conf_dir') $archive_config_file = lookup('swh::deploy::scheduler::archive::conf_file') $archive_config = lookup('swh::deploy::scheduler::archive::config') - file {$archive_config_dir: - ensure => 'directory', - owner => $user, - group => 'swhscheduler', - mode => '0644', - } - file {$archive_config_file: ensure => present, owner => 'root', group => $group, mode => '0640', content => inline_template("<%= @archive_config.to_yaml %>\n"), - require => [ - File[$archive_config_dir], - ], + require => File[$config_dir], } cron {'archive_completed_oneshot_and_disabled_recurring_tasks': - ensure => absent, - user => $user, + ensure => absent, + user => $user, } profile::cron::d {'scheduler_archive_tasks':