9
0
Fork 1
soc-ops/global/overlay/etc/puppet/modules/soc/manifests/intelmq.pp

145 lines
3.6 KiB
ObjectPascal
Raw Normal View History

2024-11-13 16:25:14 +01:00
class soc::intelmq(
2024-11-14 14:16:39 +01:00
Optional[String] $tls_cert = undef,
Optional[String] $tls_chain = undef,
Optional[String] $tls_key = undef,
2024-11-14 14:20:01 +01:00
String $servername = $facts['networking']['fqdn'],
2024-11-14 14:16:39 +01:00
Boolean $use_snakeoil = false,
2024-11-13 16:25:14 +01:00
) {
2024-11-14 14:16:39 +01:00
include sunet::systemd_reload
2024-11-13 16:25:14 +01:00
group { 'intelmq':
ensure => present,
}
user { 'intelmq':
2024-11-13 16:49:11 +01:00
ensure => present,
gid => 'intelmq',
groups => 'www-data',
home => '/opt/intelmq',
managehome => true,
2024-11-14 10:24:57 +01:00
shell => '/bin/bash',
2024-11-13 16:25:14 +01:00
}
file { '/etc/intelmq':
ensure => directory,
owner => 'intelmq',
group => 'intelmq',
}
# file { '/opt/sso/apache/groups.txt':
# ensure => file,
# content => template('soc/sso/apache-groups.txt.erb')
# }
2024-11-14 12:28:48 +01:00
package { 'apache2':
ensure => 'latest',
}
package { 'libapache2-mod-wsgi-py3':
2024-11-14 12:29:32 +01:00
ensure => 'latest',
2024-11-14 12:28:48 +01:00
}
package { ['postgresql', 'python3-venv', 'python3-pip', 'python3-gpg', 'python3-psycopg2', 'redict', ]:
2024-11-13 16:25:14 +01:00
ensure => 'latest',
}
2024-11-14 12:16:26 +01:00
exec { 'Install IntelMQ venv':
command => 'sudo -u intelmq /usr/bin/python3 -m venv --system-site-packages /opt/intelmq/venv',
creates => '/opt/intelmq/venv',
2024-11-13 16:25:14 +01:00
}
2024-11-14 10:24:57 +01:00
file { '/opt/intelmq/install-intelmq.sh':
ensure => file,
content => file('soc/intelmq/install-intelmq.sh'),
2024-11-14 10:27:12 +01:00
mode => '0555',
2024-11-14 10:24:57 +01:00
}
2024-11-14 12:16:26 +01:00
exec { 'Install IntelMQ':
command => 'sudo -u intelmq /opt/intelmq/install-intelmq.sh',
creates => '/opt/intelmq/.installed'
2024-11-13 16:25:14 +01:00
}
2024-11-14 10:51:10 +01:00
2024-11-14 12:16:26 +01:00
exec { 'Run IntelMQ setup script':
command => '/opt/intelmq/venv/bin/intelmqsetup --state-file /opt/intelmq/.setup_state',
2024-11-14 10:58:37 +01:00
creates => '/opt/intelmq/.setup_state',
returns => ['0', '1',],
2024-11-14 10:51:10 +01:00
}
2024-11-14 10:52:32 +01:00
file { '/etc/sudoers.d/01_intelmq-api':
2024-11-14 10:51:10 +01:00
ensure => file,
content => file('soc/intelmq/sudoers-01-intelmq-api'),
mode => '0440',
}
2024-11-14 12:16:26 +01:00
service { 'apache2':
ensure => 'running',
enable => true,
2024-11-14 12:28:48 +01:00
require => Package['apache2'],
2024-11-14 12:16:26 +01:00
}
exec { 'Enable Apache2 modules':
2024-11-14 12:47:14 +01:00
command => 'a2enmod ssl wsgi proxy proxy_http headers rewrite',
2024-11-14 12:28:48 +01:00
require => Package['libapache2-mod-wsgi-py3'],
2024-11-14 12:47:14 +01:00
notify => Service['apache2'],
2024-11-14 12:16:26 +01:00
}
2024-11-14 12:47:14 +01:00
file { '/etc/apache2/conf-available/wsgi-venv.conf':
ensure => file,
content => file('soc/intelmq/apache/wsgi-venv.conf'),
}
exec { 'Enable wsgi-venv conf':
2024-11-14 12:48:16 +01:00
command => 'a2enconf wsgi-venv',
creates => '/etc/apache2/conf-enabled/wsgi-venv.conf',
2024-11-14 12:47:14 +01:00
notify => Service['apache2'],
}
2024-11-14 14:16:39 +01:00
file { '/etc/apache2/sites-available/intelmq-vhost.conf':
ensure => file,
2024-11-14 14:23:08 +01:00
content => template('soc/intelmq/intelmq-vhost.conf.erb'),
2024-11-14 14:16:39 +01:00
}
file { '/etc/intelmq/api-config.json':
ensure => file,
owner => 'intelmq',
group => 'intelmq',
2024-11-14 14:17:42 +01:00
mode => '0444',
2024-11-14 14:16:39 +01:00
content => 'soc/intelmq/api-config.json',
}
file { 'api-session.sqlite':
ensure => 'present',
replace => 'no',
owner => 'intelmq',
group => 'www-data',
mode => '0660'
}
file { '/etc/systemd/system/intelmq-api.service':
ensure => file,
content => 'soc/intelmq/intelmq-api.service',
2024-11-14 14:20:56 +01:00
notify => [Class['sunet::systemd_reload'], Service['intelmq-api.service'],],
2024-11-14 14:16:39 +01:00
}
file { '/etc/systemd/system/intelmq-api.socket':
ensure => file,
content => 'soc/intelmq/intelmq-api.socket',
2024-11-14 14:20:56 +01:00
notify => [Class['sunet::systemd_reload'], Service['intelmq-api.socket'],],
2024-11-14 14:16:39 +01:00
}
service { 'intelmq-api.service':
ensure => running,
name => 'intelmq-api.service',
2024-11-14 14:24:32 +01:00
enable => true,
2024-11-14 14:16:39 +01:00
hasrestart => true,
}
service { 'intelmq-api.socket':
ensure => running,
name => 'intelmq-api.socket',
2024-11-14 14:24:32 +01:00
enable => true,
2024-11-14 14:16:39 +01:00
hasrestart => true,
}
2024-11-13 16:25:14 +01:00
}