Puppet Class: libraryupgrader
- Defined in:
- modules/libraryupgrader/manifests/init.pp
Overview
SPDX-License-Identifier: Apache-2.0
Class: libraryupgrader
This class sets up libraryupgrader aka LibUp www.mediawiki.org/wiki/Libraryupgrader
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 |
# File 'modules/libraryupgrader/manifests/init.pp', line 8
class libraryupgrader (
Stdlib::Unixpath $base_dir,
Boolean $enable_workers,
) {
$data_dir = "${base_dir}/data"
$git_dir = "${base_dir}/git"
$clone_dir = "${base_dir}/libraryupgrader"
ensure_packages(['python3-venv', 'rabbitmq-server'])
package { 'docker.io':
ensure => present,
}
systemd::sysuser { 'libup':
additional_groups => ['docker'],
}
keyholder::agent { 'libup':
trusted_groups => ['libup'],
priv_key_path => '/root/.ssh/id_libup',
}
file { [ $data_dir, $git_dir ]:
ensure => directory,
owner => 'libup',
group => 'libup',
mode => '0755',
}
git::clone { 'repos/ci-tools/libup':
ensure => present,
source => 'gitlab',
directory => $clone_dir,
branch => 'master',
owner => 'libup',
group => 'libup',
require => User['libup'],
}
# Create virtualenv
exec { 'create virtualenv':
command => '/usr/bin/python3 -m venv venv',
cwd => $clone_dir,
user => 'libup',
creates => "${clone_dir}/venv/bin/python",
require => [
Package['python3-venv'],
Git::Clone['repos/ci-tools/libup'],
],
}
exec { 'install pip and wheel in virtualenv':
command => "${clone_dir}/venv/bin/pip install -U pip wheel",
cwd => $clone_dir,
user => 'libup',
creates => "${clone_dir}/venv/bin/wheel",
require => Exec['create virtualenv'],
}
# Bootstrap initial dependencies
exec { 'install virtualenv dependencies':
command => "${clone_dir}/venv/bin/pip install -r requirements.txt",
cwd => $clone_dir,
user => 'libup',
# Just one example file created after the deps are installed
creates => "${clone_dir}/venv/bin/gunicorn",
require => Exec['install pip and wheel in virtualenv'],
}
# Install libup into venv
exec { 'install libup':
command => "${clone_dir}/venv/bin/pip install -e .",
cwd => $clone_dir,
user => 'libup',
# Just one example file created after libup is installed
creates => "${clone_dir}/venv/bin/libup-run",
require => Exec['install virtualenv dependencies'],
}
$systemd_ensure = stdlib::ensure($enable_workers)
systemd::service { 'libup-celery':
ensure => $systemd_ensure,
content => template('libraryupgrader/initscripts/libup-celery.service.erb'),
require => [
Exec['install libup'],
Package['rabbitmq-server'],
]
}
systemd::service { 'libup-push':
ensure => $systemd_ensure,
content => template('libraryupgrader/initscripts/libup-push.service.erb'),
require => [
Exec['install libup'],
Package['rabbitmq-server'],
]
}
systemd::service { 'libup-ssh-agent':
ensure => absent,
content => '',
}
systemd::timer::job { 'libup-run':
ensure => $systemd_ensure,
description => 'Trigger the libup daily run',
command => "${clone_dir}/venv/bin/libup-run --auto",
user => 'libup',
interval => {
'start' => 'OnCalendar',
'interval' => '*-*-* 00:00:00', # Every day at midnight
},
require => Exec['install libup'],
}
}
|