diff --git a/data/defaults.yaml b/data/defaults.yaml --- a/data/defaults.yaml +++ b/data/defaults.yaml @@ -1708,16 +1708,29 @@ - /api/1/entity/ - /api/1/provenance/ -swh::deploy::scheduler::conf_file: "%{hiera('swh::conf_directory')}/scheduler.ini" +# local configuration for the scheduler +swh::deploy::scheduler::config::local: &swh_scheduler_local_config + cls: local + args: + db: "host=%{hiera('swh::deploy::scheduler::db::host')} dbname=%{hiera('swh::deploy::scheduler::db::dbname')} user=%{hiera('swh::deploy::scheduler::db::user')} password=%{hiera('swh::deploy::scheduler::db::password')}" + +swh::deploy::scheduler::conf_file: "%{hiera('swh::conf_directory')}/scheduler.yml" swh::deploy::scheduler::user: swhscheduler swh::deploy::scheduler::group: swhscheduler swh::deploy::scheduler::db::host: db swh::deploy::scheduler::db::dbname: softwareheritage-scheduler swh::deploy::scheduler::db::user: swhscheduler # swh::deploy::scheduler::db::password in private data -swh::deploy::scheduler::database: "host=%{hiera('swh::deploy::scheduler::db::host')} dbname=%{hiera('swh::deploy::scheduler::db::dbname')} user=%{hiera('swh::deploy::scheduler::db::user')} password=%{hiera('swh::deploy::scheduler::db::password')}" # swh::deploy::scheduler::task_broker::password in private data swh::deploy::scheduler::task_broker: "amqp://swhproducer:%{hiera('swh::deploy::scheduler::task_broker::password')}@rabbitmq:5672//" +swh::deploy::scheduler::listener::log_level: INFO +swh::deploy::scheduler::runner::log_level: INFO +swh::deploy::scheduler::config: + scheduler: + <<: *swh_scheduler_local_config + celery: + task_broker: "%{alias('swh::deploy::scheduler::task_broker')}" + swh::deploy::scheduler::task_packages: - python3-swh.lister - python3-swh.loader.debian diff --git a/data/hostname/saatchi.internal.softwareheritage.org.yaml b/data/hostname/saatchi.internal.softwareheritage.org.yaml --- a/data/hostname/saatchi.internal.softwareheritage.org.yaml +++ b/data/hostname/saatchi.internal.softwareheritage.org.yaml @@ -3,8 +3,4 @@ swh::deploy::scheduler::remote::backend::listen::host: 0.0.0.0 -swh::deploy::scheduler::remote::config: - scheduler: - cls: local - args: - scheduling_db: "%{hiera('swh::deploy::scheduler::database')}" +swh::deploy::scheduler::remote::config: "%{alias('swh::deploy::scheduler::config::local')}" 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,9 +1,12 @@ # Deployment of swh-scheduler related utilities class profile::swh::deploy::scheduler { - $conf_file = lookup('swh::deploy::scheduler::conf_file') + $config_file = lookup('swh::deploy::scheduler::conf_file') $user = lookup('swh::deploy::scheduler::user') $group = lookup('swh::deploy::scheduler::group') - $database = lookup('swh::deploy::scheduler::database') + $config = lookup('swh::deploy::scheduler::config') + + $listener_log_level = lookup('swh::deploy::scheduler::listener::log_level') + $runner_log_level = lookup('swh::deploy::scheduler::runner::log_level') $task_broker = lookup('swh::deploy::scheduler::task_broker') $task_packages = lookup('swh::deploy::scheduler::task_packages') @@ -47,15 +50,12 @@ notify => Service[$services], } - # Template uses variables - # - $database - # - file {$conf_file: + file {$config_file: ensure => present, owner => 'root', group => $group, mode => '0640', - content => template('profile/swh/deploy/scheduler/scheduler.ini.erb'), + content => inline_template("<%= @config.to_yaml %>\n"), notify => Service[$services], } @@ -98,7 +98,7 @@ require => [ Package[$packages], Package[$task_packages], - File[$conf_file], + File[$config_file], File[$worker_conf_file], Systemd::Unit_File[$runner_unit_name], ], @@ -109,7 +109,7 @@ enable => true, require => [ Package[$packages], - File[$conf_file], + File[$config_file], File[$worker_conf_file], Systemd::Unit_File[$listener_unit_name], ], diff --git a/site-modules/profile/templates/swh/deploy/scheduler/scheduler.ini.erb b/site-modules/profile/templates/swh/deploy/scheduler/scheduler.ini.erb deleted file mode 100644 --- a/site-modules/profile/templates/swh/deploy/scheduler/scheduler.ini.erb +++ /dev/null @@ -1,6 +0,0 @@ -# swh.scheduler configuration file -# File managed by puppet - modifications will be overwritten - -[main] -scheduling_db = <%= @database %> - diff --git a/site-modules/profile/templates/swh/deploy/scheduler/swh-scheduler-listener.service.erb b/site-modules/profile/templates/swh/deploy/scheduler/swh-scheduler-listener.service.erb --- a/site-modules/profile/templates/swh/deploy/scheduler/swh-scheduler-listener.service.erb +++ b/site-modules/profile/templates/swh/deploy/scheduler/swh-scheduler-listener.service.erb @@ -11,7 +11,7 @@ User=<%= @user %> Group=<%= @group %> Type=simple -ExecStart=/usr/bin/python3 -m swh.scheduler.celery_backend.listener +ExecStart=/usr/bin/swh-scheduler --config-file <%= @config_file %> --log-level <%= @listener_log_level %> listener Restart=always RestartSec=10 diff --git a/site-modules/profile/templates/swh/deploy/scheduler/swh-scheduler-runner.service.erb b/site-modules/profile/templates/swh/deploy/scheduler/swh-scheduler-runner.service.erb --- a/site-modules/profile/templates/swh/deploy/scheduler/swh-scheduler-runner.service.erb +++ b/site-modules/profile/templates/swh/deploy/scheduler/swh-scheduler-runner.service.erb @@ -11,7 +11,7 @@ User=<%= @user %> Group=<%= @group %> Type=simple -ExecStart=/bin/sh -c 'while true; do echo running pending tasks at `/bin/date`...; /usr/bin/python3 -m swh.scheduler.celery_backend.runner; sleep 10; done' +ExecStart=/usr/bin/swh-scheduler --config-file <%= @config_file %> --log-level <%= @runner_log_level %> runner --period 10 Restart=always RestartSec=10