2016-10-17 04:05:49 +02:00
|
|
|
class zulip_ops::base {
|
2013-11-01 20:28:03 +01:00
|
|
|
include zulip::base
|
2016-10-17 04:17:45 +02:00
|
|
|
include zulip::apt_repository
|
2013-10-29 23:53:04 +01:00
|
|
|
|
2013-11-08 20:58:48 +01:00
|
|
|
$org_base_packages = [# Management for our systems
|
2018-08-13 21:29:40 +02:00
|
|
|
'openssh-server',
|
|
|
|
'mosh',
|
2018-08-13 21:27:41 +02:00
|
|
|
# package management
|
2018-08-13 21:29:40 +02:00
|
|
|
'aptitude',
|
2018-08-13 21:27:41 +02:00
|
|
|
# SSL Certificates
|
2018-08-13 21:29:40 +02:00
|
|
|
'letsencrypt',
|
2018-08-13 21:27:41 +02:00
|
|
|
# Monitoring
|
2018-08-13 21:29:40 +02:00
|
|
|
'munin-node',
|
|
|
|
'munin-plugins-extra' ,
|
2018-08-13 21:27:41 +02:00
|
|
|
# Security
|
2018-08-13 21:29:40 +02:00
|
|
|
'iptables-persistent',
|
2018-08-13 21:27:41 +02:00
|
|
|
# For managing our current Debian packages
|
2018-08-13 21:29:40 +02:00
|
|
|
'debian-goodies',
|
2018-08-13 21:27:41 +02:00
|
|
|
# Needed for zulip-ec2-configure-network-interfaces
|
2018-08-13 21:29:40 +02:00
|
|
|
'python3-six',
|
|
|
|
'python-six',
|
2019-06-26 07:06:59 +02:00
|
|
|
'python3-boto',
|
2018-08-13 21:29:40 +02:00
|
|
|
'python-boto', # needed for postgres_common too
|
|
|
|
'python3-netifaces',
|
|
|
|
'python-netifaces',
|
2018-08-13 21:27:41 +02:00
|
|
|
# Popular editors
|
2018-08-13 21:29:40 +02:00
|
|
|
'vim',
|
|
|
|
'emacs-nox',
|
2018-08-13 21:27:41 +02:00
|
|
|
# Prevent accidental reboots
|
2018-08-13 21:29:40 +02:00
|
|
|
'molly-guard',
|
2018-08-13 21:27:41 +02:00
|
|
|
# Useful tools in a production environment
|
2018-08-13 21:29:40 +02:00
|
|
|
'screen',
|
|
|
|
'strace',
|
|
|
|
'host',
|
|
|
|
'git',
|
|
|
|
'nagios-plugins-contrib',
|
2018-08-13 21:27:41 +02:00
|
|
|
]
|
2018-08-13 21:29:40 +02:00
|
|
|
package { $org_base_packages: ensure => 'installed' }
|
2013-10-29 23:53:04 +01:00
|
|
|
|
2016-07-21 07:56:00 +02:00
|
|
|
# Add system users here
|
|
|
|
$users = []
|
|
|
|
|
2016-08-03 21:53:03 +02:00
|
|
|
# Add hosts to monitor here
|
|
|
|
$hosts = []
|
|
|
|
|
2013-11-10 15:32:54 +01:00
|
|
|
file { '/etc/apt/apt.conf.d/02periodic':
|
2018-08-13 21:20:34 +02:00
|
|
|
ensure => file,
|
|
|
|
mode => '0644',
|
|
|
|
source => 'puppet:///modules/zulip_ops/apt/apt.conf.d/02periodic',
|
2013-11-10 15:32:54 +01:00
|
|
|
}
|
|
|
|
|
2016-08-19 17:27:17 +02:00
|
|
|
file { '/etc/apt/apt.conf.d/50unattended-upgrades':
|
2018-08-13 21:20:34 +02:00
|
|
|
ensure => file,
|
|
|
|
mode => '0644',
|
|
|
|
source => 'puppet:///modules/zulip_ops/apt/apt.conf.d/50unattended-upgrades',
|
2016-08-19 17:27:17 +02:00
|
|
|
}
|
|
|
|
|
2013-10-29 23:53:04 +01:00
|
|
|
file { '/home/zulip/.ssh':
|
2018-08-13 21:20:34 +02:00
|
|
|
ensure => directory,
|
|
|
|
require => User['zulip'],
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'zulip',
|
|
|
|
group => 'zulip',
|
2018-08-13 21:20:34 +02:00
|
|
|
mode => '0600',
|
2013-10-29 23:53:04 +01:00
|
|
|
}
|
|
|
|
|
2018-05-07 03:47:40 +02:00
|
|
|
# Clear /etc/update-motd.d, to fix load problems with Nagios
|
|
|
|
# caused by Ubuntu's default MOTD tools for things like "checking
|
|
|
|
# for the next release" being super slow.
|
|
|
|
file { '/etc/update-motd.d':
|
2018-08-13 21:20:34 +02:00
|
|
|
ensure => directory,
|
|
|
|
recurse => true,
|
|
|
|
purge => true,
|
2018-05-07 03:47:40 +02:00
|
|
|
}
|
|
|
|
|
2016-09-26 19:22:45 +02:00
|
|
|
file { '/etc/pam.d/common-session':
|
2018-08-13 21:20:34 +02:00
|
|
|
ensure => file,
|
|
|
|
require => Package['openssh-server'],
|
|
|
|
source => 'puppet:///modules/zulip_ops/common-session',
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
|
|
|
mode => '0644',
|
2016-09-26 19:22:45 +02:00
|
|
|
}
|
|
|
|
|
2018-02-10 01:20:26 +01:00
|
|
|
service { 'ssh':
|
|
|
|
ensure => running,
|
|
|
|
}
|
|
|
|
|
2019-06-26 07:06:59 +02:00
|
|
|
file { '/etc/ssh/sshd_config':
|
|
|
|
ensure => file,
|
|
|
|
require => Package['openssh-server'],
|
|
|
|
source => 'puppet:///modules/zulip_ops/sshd_config',
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
|
|
|
mode => '0644',
|
|
|
|
notify => Service['ssh'],
|
2013-11-07 23:45:07 +01:00
|
|
|
}
|
|
|
|
|
2016-07-31 05:45:09 +02:00
|
|
|
file { '/root/.emacs':
|
2018-08-13 21:20:34 +02:00
|
|
|
ensure => file,
|
|
|
|
mode => '0600',
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
2018-08-13 21:20:34 +02:00
|
|
|
source => 'puppet:///modules/zulip_ops/dot_emacs.el',
|
2016-07-31 05:45:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
file { '/home/zulip/.emacs':
|
2018-08-13 21:20:34 +02:00
|
|
|
ensure => file,
|
|
|
|
mode => '0600',
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'zulip',
|
|
|
|
group => 'zulip',
|
2018-08-13 21:20:34 +02:00
|
|
|
source => 'puppet:///modules/zulip_ops/dot_emacs.el',
|
|
|
|
require => User['zulip'],
|
2016-07-31 05:45:09 +02:00
|
|
|
}
|
|
|
|
|
2019-06-26 07:06:59 +02:00
|
|
|
$hosting_provider = zulipconf('machine', 'hosting_provider', 'ec2')
|
|
|
|
if $hosting_provider == 'ec2' {
|
|
|
|
# This conditional block is for for whether it's not
|
|
|
|
# chat.zulip.org, which uses a different hosting provider.
|
|
|
|
package { 'dhcpcd5':
|
|
|
|
ensure => 'installed',
|
|
|
|
}
|
2018-02-10 01:19:01 +01:00
|
|
|
file { '/root/.ssh/authorized_keys':
|
2018-08-13 21:20:34 +02:00
|
|
|
ensure => file,
|
|
|
|
mode => '0600',
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
2018-08-13 21:20:34 +02:00
|
|
|
source => 'puppet:///modules/zulip_ops/root_authorized_keys',
|
2018-02-10 01:19:01 +01:00
|
|
|
}
|
|
|
|
file { '/home/zulip/.ssh/authorized_keys':
|
2018-08-13 21:20:34 +02:00
|
|
|
ensure => file,
|
|
|
|
require => File['/home/zulip/.ssh'],
|
|
|
|
mode => '0600',
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'zulip',
|
|
|
|
group => 'zulip',
|
2018-08-13 21:20:34 +02:00
|
|
|
source => 'puppet:///modules/zulip_ops/authorized_keys',
|
2018-02-10 01:19:01 +01:00
|
|
|
}
|
|
|
|
file { '/var/lib/nagios/.ssh/authorized_keys':
|
2018-08-13 21:20:34 +02:00
|
|
|
ensure => file,
|
|
|
|
require => File['/var/lib/nagios/.ssh'],
|
|
|
|
mode => '0600',
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'nagios',
|
|
|
|
group => 'nagios',
|
2018-08-13 21:20:34 +02:00
|
|
|
source => 'puppet:///modules/zulip_ops/nagios_authorized_keys',
|
2018-02-10 01:19:01 +01:00
|
|
|
}
|
2013-10-29 23:53:04 +01:00
|
|
|
}
|
|
|
|
|
2019-06-26 07:06:59 +02:00
|
|
|
if $hosting_provider == 'ec2' {
|
2018-02-10 01:17:44 +01:00
|
|
|
file { '/usr/local/sbin/zulip-ec2-configure-interfaces':
|
2018-08-13 21:20:34 +02:00
|
|
|
ensure => file,
|
|
|
|
mode => '0755',
|
|
|
|
source => 'puppet:///modules/zulip_ops/zulip-ec2-configure-interfaces',
|
2018-02-10 01:17:44 +01:00
|
|
|
}
|
2013-10-29 23:53:04 +01:00
|
|
|
|
2018-02-10 01:17:44 +01:00
|
|
|
file { '/etc/network/if-up.d/zulip-ec2-configure-interfaces_if-up.d.sh':
|
2018-08-13 21:20:34 +02:00
|
|
|
ensure => file,
|
|
|
|
mode => '0755',
|
|
|
|
source => 'puppet:///modules/zulip_ops/zulip-ec2-configure-interfaces_if-up.d.sh',
|
2018-02-10 01:17:44 +01:00
|
|
|
}
|
2013-10-29 23:53:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
group { 'nagios':
|
2018-08-13 21:20:34 +02:00
|
|
|
ensure => present,
|
|
|
|
gid => '1050',
|
2013-10-29 23:53:04 +01:00
|
|
|
}
|
|
|
|
user { 'nagios':
|
|
|
|
ensure => present,
|
|
|
|
uid => '1050',
|
|
|
|
gid => '1050',
|
|
|
|
shell => '/bin/bash',
|
|
|
|
home => '/var/lib/nagios',
|
|
|
|
managehome => true,
|
|
|
|
}
|
|
|
|
file { '/var/lib/nagios/':
|
2018-08-13 21:20:34 +02:00
|
|
|
ensure => directory,
|
|
|
|
require => User['nagios'],
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'nagios',
|
|
|
|
group => 'nagios',
|
2018-08-13 21:20:34 +02:00
|
|
|
mode => '0600',
|
2013-10-29 23:53:04 +01:00
|
|
|
}
|
|
|
|
file { '/var/lib/nagios/.ssh':
|
2018-08-13 21:20:34 +02:00
|
|
|
ensure => directory,
|
|
|
|
require => File['/var/lib/nagios/'],
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'nagios',
|
|
|
|
group => 'nagios',
|
2018-08-13 21:20:34 +02:00
|
|
|
mode => '0600',
|
2013-10-29 23:53:04 +01:00
|
|
|
}
|
|
|
|
file { '/home/nagios':
|
2018-08-13 21:20:34 +02:00
|
|
|
ensure => absent,
|
|
|
|
force => true,
|
2013-10-29 23:53:04 +01:00
|
|
|
recurse => true,
|
|
|
|
}
|
2019-06-26 07:06:59 +02:00
|
|
|
|
|
|
|
file { '/etc/iptables/rules.v4':
|
|
|
|
ensure => file,
|
|
|
|
mode => '0600',
|
|
|
|
content => template('zulip_ops/iptables/rules.v4.erb'),
|
|
|
|
require => Package['iptables-persistent'],
|
|
|
|
}
|
|
|
|
service { 'netfilter-persistent':
|
|
|
|
ensure => running,
|
|
|
|
|
|
|
|
# Because there is no running process for this service, the normal status
|
|
|
|
# checks fail. Because puppet then thinks the service has been manually
|
|
|
|
# stopped, it won't restart it. This fake status command will trick puppet
|
|
|
|
# into thinking the service is *always* running (which in a way it is, as
|
|
|
|
# iptables is part of the kernel.)
|
|
|
|
hasstatus => true,
|
|
|
|
status => '/bin/true',
|
|
|
|
|
|
|
|
# Under Debian, the "restart" parameter does not reload the rules, so tell
|
|
|
|
# Puppet to fall back to stop/start, which does work.
|
|
|
|
hasrestart => false,
|
|
|
|
|
|
|
|
require => Package['iptables-persistent'],
|
|
|
|
subscribe => File['/etc/iptables/rules.v4'],
|
2013-11-07 23:47:23 +01:00
|
|
|
}
|
2013-10-29 23:53:04 +01:00
|
|
|
}
|