Puppet Class: codesearch
- Defined in:
- modules/codesearch/manifests/init.pp
Overview
SPDX-License-Identifier: Apache-2.0
Class: codesearch
This class sets up the basics needed for MediaWiki code search hosted at codesearch.wmcloud.org
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'modules/codesearch/manifests/init.pp', line 7
class codesearch(
Optional[Stdlib::Unixpath] $base_dir = undefined,
Hash[String, Integer] $ports = undefined,
Integer $lock_file_min_age = undefined,
){
$hound_dir = "${base_dir}/hound"
$clone_dir = "${base_dir}/codesearch"
ensure_packages([
'gunicorn3',
'python3-flask',
'python3-requests',
'python3-yaml',
'docker.io',
])
if debian::codename::ge('trixie') {
ensure_packages(['docker-cli'])
}
systemd::sysuser { 'codesearch':
additional_groups => ['docker'],
}
file { $hound_dir:
ensure => directory,
owner => 'codesearch',
group => 'codesearch',
mode => '0755',
}
git::clone {'labs/codesearch':
ensure => latest,
directory => $clone_dir,
branch => 'master',
owner => 'codesearch',
group => 'codesearch',
}
file { '/etc/hound-gitconfig':
ensure => present,
owner => 'root',
group => 'root',
source => 'puppet:///modules/codesearch/hound-gitconfig',
}
systemd::timer::job { 'codesearch-write-config':
description => 'Generate hound configuration files',
command => "${clone_dir}/write_config.py --restart",
user => 'root',
interval => {
'start' => 'OnCalendar',
'interval' => '*-*-* 06:00:00', # Every day before Europe wakes up
},
require => [
Git::Clone['labs/codesearch'],
],
}
# To prevent incidents like T421147 we are attempting to
# find zombie lock files that don't have a corresponding process
# anymore but have not been cleaned up.
file { '/usr/local/bin/delete-hound-zombie-locks.sh':
ensure => file,
owner => 'root',
mode => '0755',
source => 'puppet:///modules/codesearch/delete-zombie-locks.sh',
}
file { '/etc/hound-delete-zombie-locks.conf':
ensure => file,
owner => 'root',
mode => '0644',
content => template('codesearch/delete-zombie-locks.conf.erb'),
}
systemd::timer::job { 'codesearch-delete-zombie-locks':
description => 'Delete lock files older than X.',
command => '/usr/local/bin/delete-hound-zombie-locks.sh',
user => 'root',
interval => {
'start' => 'OnCalendar',
'interval' => 'hourly',
},
require => [
File['/usr/local/bin/delete-hound-zombie-locks.sh'],
File['/etc/hound-delete-zombie-locks.conf'],
],
}
systemd::service { 'hound_proxy':
ensure => present,
content => template('codesearch/initscripts/hound_proxy.service.erb'),
restart => true,
subscribe => File['/etc/codesearch_ports.json'],
require => [
Git::Clone['labs/codesearch'],
Package['gunicorn3'],
File['/etc/codesearch_ports.json'],
]
}
systemd::service { 'codesearch-frontend':
ensure => present,
content => template('codesearch/initscripts/codesearch-frontend.service.erb'),
require => [
Git::Clone['labs/codesearch'],
Package['docker.io'],
]
}
file { '/etc/codesearch_ports.json':
ensure => present,
content => to_json_pretty($ports),
owner => 'codesearch',
}
$ports.each |String $name, Integer $port| {
systemd::service { "hound-${name}":
ensure => present,
content => template('codesearch/initscripts/hound.service.erb'),
restart => true,
require => [
Package['docker.io'],
Systemd::Service['hound_proxy'],
Systemd::Timer::Job['codesearch-write-config'],
File['/etc/hound-gitconfig'],
]
}
}
}
|