diff --git a/data/common/common.yaml b/data/common/common.yaml --- a/data/common/common.yaml +++ b/data/common/common.yaml @@ -4227,19 +4227,33 @@ borg::encryption: repokey-blake2 +swh::deploy::base_search::config_directory: "%{hiera('swh::conf_directory')}/search" +swh::deploy::base_search::user: swhstorage +swh::deploy::base_search::group: swhstorage + swh::deploy::search::sentry_swh_package: swh.search swh::deploy::search::sentry_environment: "%{alias('swh::deploy::environment')}" swh::deploy::search::sentry_dsn: "https://%{lookup('swh::deploy::search::sentry_token')}@sentry.softwareheritage.org/15" -swh::deploy::search::conf_directory: "%{hiera('swh::conf_directory')}" -swh::deploy::search::conf_file: "%{hiera('swh::deploy::search::conf_directory')}/search.yml" -swh::deploy::search::user: swhstorage -swh::deploy::search::group: swhstorage +swh::deploy::search::conf_file: "%{hiera('swh::deploy::base_search::config_directory')}/server.yml" +swh::deploy::search::user: "%{alias('swh::deploy::base_search::user')}" +swh::deploy::search::group: "%{alias('swh::deploy::base_search::group')}" swh::deploy::search::config: search: cls: elasticsearch args: hosts: "%{alias('swh::elasticsearch::nodes')}" +swh::deploy::search_journal_client::config_file: "%{lookup('swh::deploy::base_search::config_directory')}/journal_client.yml" +swh::deploy::search_journal_client::config: + search: + cls: elasticsearch + args: + hosts: "%{alias('swh::elasticsearch::nodes')}" + journal: + brokers: "%{alias('swh::deploy::journal::brokers')}" + group_id: swh.search.journal_client + prefix: "%{alias('swh::deploy::journal::prefix')}" + swh::deploy::search::backend::listen::host: 127.0.0.1 swh::deploy::search::backend::listen::port: "%{alias('swh::remote_service::search::port')}" swh::deploy::search::backend::workers: 4 diff --git a/manifests/site.pp b/manifests/site.pp --- a/manifests/site.pp +++ b/manifests/site.pp @@ -165,7 +165,7 @@ } node /^search\d\.internal\.staging\.swh\.network$/ { - include role::swh_search + include role::swh_search_with_journal_client } node 'webapp.internal.staging.swh.network' { diff --git a/site-modules/profile/manifests/swh/deploy/base_search.pp b/site-modules/profile/manifests/swh/deploy/base_search.pp new file mode 100644 --- /dev/null +++ b/site-modules/profile/manifests/swh/deploy/base_search.pp @@ -0,0 +1,20 @@ +# Base class for search related manifests +class profile::swh::deploy::base_search { + $config_directory = lookup('swh::deploy::base_search::config_directory') + $user = lookup('swh::deploy::base_search::user') + $group = lookup('swh::deploy::base_search::group') + + file {$config_directory: + ensure => 'directory', + owner => $user, + group => $group, + mode => '0755', + } + + $packages = ['python3-swh.search'] + + package {$packages: + ensure => 'present', + } + +} diff --git a/site-modules/profile/manifests/swh/deploy/search.pp b/site-modules/profile/manifests/swh/deploy/search.pp --- a/site-modules/profile/manifests/swh/deploy/search.pp +++ b/site-modules/profile/manifests/swh/deploy/search.pp @@ -1,10 +1,8 @@ # Deployment of the swh.search.api server class profile::swh::deploy::search { - $packages = ['python3-swh.search'] + include ::profile::swh::deploy::base_search - package {$packages: - ensure => 'present', - } ~> Service['gunicorn-swh-search'] + Package['python3-swh.search'] ~> Service['gunicorn-swh-search'] ::profile::swh::deploy::rpc_server {'search': executable => 'swh.search.api.server:make_app_from_configfile()', diff --git a/site-modules/profile/manifests/swh/deploy/search_journal_client.pp b/site-modules/profile/manifests/swh/deploy/search_journal_client.pp new file mode 100644 --- /dev/null +++ b/site-modules/profile/manifests/swh/deploy/search_journal_client.pp @@ -0,0 +1,32 @@ +# Deployment of the swh.search.journal_client +class profile::swh::deploy::search_journal_client { + include ::profile::swh::deploy::base_search + include ::profile::swh::deploy::journal + + $config_path = lookup('swh::deploy::search_journal_client::config_file') + $config = lookup('swh::deploy::search_journal_client::config') + + $service_name = 'swh-search-journal-client' + $unit_name = "${service_name}.service" + $user = lookup('swh::deploy::base_search::user') + $group = lookup('swh::deploy::base_search::group') + + Package['python3-swh.search'] ~> Service[$service_name] + + file {$config_path: + ensure => present, + owner => 'root', + group => 'swhdev', + mode => '0644', + content => inline_template("<%= @config.to_yaml %>\n"), + notify => Service[$service_name], + } + + ::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-search-journal-client.service.erb b/site-modules/profile/templates/swh/deploy/journal/swh-search-journal-client.service.erb new file mode 100644 --- /dev/null +++ b/site-modules/profile/templates/swh/deploy/journal/swh-search-journal-client.service.erb @@ -0,0 +1,18 @@ +# Indexer Journal Client unit file +# Managed by puppet class profile::swh::deploy::indexer_journal_client +# Changes will be overwritten + +[Unit] +Description=Software Heritage Indexer Journal Client +After=network.target + +[Service] +User=<%= @user %> +Group=<%= @group %> +Type=simple +ExecStart=/usr/bin/swh search --config-file <%= @config_path %> journal-client objects +Restart=always +RestartSec=10 + +[Install] +WantedBy=multi-user.target diff --git a/site-modules/role/manifests/swh_search.pp b/site-modules/role/manifests/swh_search.pp deleted file mode 100644 --- a/site-modules/role/manifests/swh_search.pp +++ /dev/null @@ -1,3 +0,0 @@ -class role::swh_search inherits role::swh_server { - include ::profile::swh::deploy::search -} diff --git a/site-modules/role/manifests/swh_search_with_journal_client.pp b/site-modules/role/manifests/swh_search_with_journal_client.pp new file mode 100644 --- /dev/null +++ b/site-modules/role/manifests/swh_search_with_journal_client.pp @@ -0,0 +1,4 @@ +class role::swh_search_with_journal_client inherits role::swh_server { + include ::profile::swh::deploy::search + include profile::swh::deploy::search_journal_client +}