Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Implement puppetserver #50

Draft
wants to merge 64 commits into
base: production
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
ce6b2f2
Implement puppetserver
bastelfreak Jul 27, 2023
cd38567
README.md: explain dependency handling
bastelfreak Jul 27, 2023
4fe5d69
README.md: document csr_attributes
bastelfreak Jul 27, 2023
5deccbe
profiles::base: pull in puppet agent/server
bastelfreak Jul 27, 2023
a64ba64
hiera.yaml: Add role layere
bastelfreak Jul 27, 2023
8aeda50
add puppetserver yaml data
bastelfreak Jul 27, 2023
7453142
dont install gcc twice
bastelfreak Jul 27, 2023
a0cdce3
add puppetserver firewalling
bastelfreak Jul 27, 2023
24c4649
add nftables profile
bastelfreak Jul 27, 2023
9512fe0
fix puppetserver setup
bastelfreak Jul 27, 2023
0ab3a5e
fix java 11 setup
bastelfreak Jul 27, 2023
d27e390
disable reports for now
bastelfreak Jul 27, 2023
50dd8c8
add redis profile
bastelfreak Jul 27, 2023
33be0b6
postgresql: Add support for 15
bastelfreak Jul 27, 2023
35086e8
puppetserver: use postgresql 15
bastelfreak Jul 27, 2023
21b7419
puppetserver: always install foreman
bastelfreak Jul 27, 2023
7f36ed6
add foreman profile
bastelfreak Jul 27, 2023
cdb4e02
fix datatype
bastelfreak Jul 27, 2023
c8cb258
add apache
bastelfreak Jul 27, 2023
0c5bdbc
add foreman deps
bastelfreak Jul 27, 2023
aa7ecc5
apply: enhance params
bastelfreak Jul 27, 2023
7104fa6
add missing richardc/datacat dep
bastelfreak Jul 27, 2023
22f691a
nftables: allow hkp
bastelfreak Jul 27, 2023
de4fbb4
foreman: set version
bastelfreak Jul 27, 2023
6e4a5a6
fix ordering
bastelfreak Jul 27, 2023
661c87f
fix ordering
bastelfreak Jul 27, 2023
7f605e6
fix
bastelfreak Jul 27, 2023
69efeaa
fix debian family support
bastelfreak Jul 27, 2023
f58ef04
fix firewalling
bastelfreak Jul 27, 2023
a11824a
fix msgpack
bastelfreak Jul 27, 2023
db47e75
configure r10k
bastelfreak Jul 27, 2023
e293417
r10k: bump version
bastelfreak Jul 27, 2023
2605ba3
r10k: fix url
bastelfreak Jul 27, 2023
fac5473
disable puppet after bootstrap
bastelfreak Jul 28, 2023
c911607
site/profiles/manifests/puppetcode.pp
bastelfreak Jul 28, 2023
878cbfa
fix pluginsync
bastelfreak Jul 28, 2023
436cbab
site.pp: add tag
bastelfreak Jul 28, 2023
e36eec2
fix typo
bastelfreak Jul 28, 2023
b703247
run apt update before package installation
bastelfreak Jul 28, 2023
1562053
fix
bastelfreak Jul 28, 2023
d4b48b3
foo
bastelfreak Jul 28, 2023
5a675ad
reorder pg packages
bastelfreak Jul 28, 2023
b5e74fe
reorder collector
bastelfreak Jul 28, 2023
77e020d
add puppetdb
bastelfreak Jul 28, 2023
707196e
foo
bastelfreak Jul 28, 2023
432fae1
foo
bastelfreak Jul 28, 2023
4938eb4
foo
bastelfreak Jul 28, 2023
78eaa1f
foo
bastelfreak Jul 28, 2023
287f651
foo
bastelfreak Jul 28, 2023
cefeea5
enhance cloud-init
bastelfreak Jul 28, 2023
3d002f5
cleanup
bastelfreak Jul 28, 2023
ea1626e
cleanup
bastelfreak Jul 28, 2023
422ac94
.fixtures.yml: remove legacy yardoc dependency
bastelfreak Jul 28, 2023
5cc65b9
fix typo
bastelfreak Jul 28, 2023
69095d7
metadata.json: Allow newest versions
bastelfreak Jul 29, 2023
1852742
enhance tests
bastelfreak Jul 29, 2023
b8ccdfa
foo
bastelfreak Jul 29, 2023
707b24d
allowo newest versions
bastelfreak Jul 30, 2023
7a408b6
foo
bastelfreak Jul 30, 2023
60b2c8c
make puppetdb setup more dynamic
bastelfreak Oct 26, 2023
34aafc7
nftables
bastelfreak Sep 6, 2024
3c04732
add foremandns
bastelfreak Sep 6, 2024
67a5849
foreman 3.11
bastelfreak Sep 6, 2024
231f0ba
README.md: fix documentation
bastelfreak Sep 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ mod 'saz/sudo', '8.0.0'
mod 'puppet/github_actions_runner', '1.1.0'
mod 'puppet/nftables', '4.0.0'
mod 'puppetlabs/docker', '10.0.1'
mod 'theforeman/puppetserver_foreman', '4.0.0'
mod 'theforeman/foreman', '25.2.1'
mod 'theforeman/foreman_proxy', '26.1.0'
mod 'theforeman/dns', '11.0.0'
mod 'puppetlabs/puppetdb', '8.1.0'
mod 'puppet/redis', '11.0.0'
mod 'puppetlabs/apache', '12.1.0'
mod 'richardc/datacat', '0.6.2'
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,46 @@ sed -i 's#remote:.*#remote: https://github.com/voxpupuli/controlrepo.git#' /etc/
r10k deploy environment production --puppetfile --verbose
puppet apply /etc/puppetlabs/code/environments/production/manifests/site.pp --show_diff
```

## Hetzner Cloud cloud-init userdata:

```yaml
#cloud-config
---
package_reboot_if_required: true
package_upgrade: true
packages:
- git
- ca-certificates
repo_update: true
repo_upgrade: all
puppet:
install_type: aio
collection: puppet8
cleanup: false
package_name: puppet-agent
csr_attributes:
extension_requests:
pp_role: puppetserver
runcmd:
- systemctl disable --now puppet
- /opt/puppetlabs/puppet/bin/gem install --no-document r10k toml
- cd /root && git clone https://github.com/voxpupuli/controlrepo
- cd /root/controlrepo && /opt/puppetlabs/puppet/bin/r10k puppetfile install --verbose
- /opt/puppetlabs/puppet/bin/puppet apply /root/controlrepo/manifests/site.pp --modulepath /root/controlrepo/modules:/root/controlrepo/site --show_diff --write_catalog_summary --hiera_config /root/controlrepo/hiera.yaml --summarize --graph --tags r10k,hacked_pluginsync
- /opt/puppetlabs/puppet/bin/r10k deploy environment --modules --verbose
- /opt/puppetlabs/puppet/bin/puppet apply /etc/puppetlabs/code/environments/production/manifests/site.pp --show_diff --environment production --write_catalog_summary --summarize --graph
- /opt/puppetlabs/puppet/bin/puppet agent -t
- /opt/puppetlabs/puppet/bin/puppet agent -t
```

## ToDos

* setup csr_attributes (cloud-inits supports that as well)
* write the r10k config so we can do the initial provisioning into `/etc/puppetlabs/code/environments` and not `/root`

## metadata.json and dependencies

the `site/profiles/metadata.json` only tracks modules that are direct
dependencies to profiles. The `.fixtures.yml` can be autogenerated with the
`generate_fixtures` rake task.
3 changes: 3 additions & 0 deletions data/nodes/puppetserver.voxpupuli.org.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
profiles::puppet::server: true
profiles::postgresql::version: '15'
3 changes: 3 additions & 0 deletions data/roles/puppetserver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
classes:
- profiles::puppet
2 changes: 2 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ defaults:
hierarchy:
- name: "Per-node data"
path: "nodes/%{facts.networking.fqdn}.yaml"
- name: "Role data"
path: "roles/%{trusted.extensions.pp_role}.yaml"
- name: "one file to rule them all"
path: "global.yaml"
25 changes: 15 additions & 10 deletions manifests/site.pp
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# hack pluginsync as file resource. only required for `puppet apply` usage
# this works by accident with puppet agent, but only on the puppetserver
# it breaks puppet agent on other systems, so we need to guard it
if $trusted['authenticated'] == 'local' {
file { $settings::libdir:
ensure => directory,
source => 'puppet:///plugins', # lint:ignore:puppet_url_without_modules
recurse => true,
purge => true,
backup => false,
noop => false,
tag => 'hacked_pluginsync',
}
}

# include base profile that every node gets
contain profiles::base

## pluginsync
file { $::settings::libdir: # lint:ignore:top_scope_facts
ensure => directory,
source => 'puppet:///plugins', # lint:ignore:puppet_url_without_modules
recurse => true,
purge => true,
backup => false,
noop => false,
}

# include node specific profiles
lookup('classes', Array[String[1]], 'unique', []).each |$c| {
contain $c
Expand Down
4 changes: 4 additions & 0 deletions site/profiles/.fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ fixtures:
inifile: https://github.com/puppetlabs/puppetlabs-inifile
systemd: https://github.com/voxpupuli/puppet-systemd
postgresql: https://github.com/puppetlabs/puppetlabs-postgresql
puppetdb: https://github.com/puppetlabs/puppetlabs-puppetdb.git
prometheus: https://github.com/voxpupuli/puppet-prometheus.git
borg: https://github.com/voxpupuli/puppet-borg.git
puppet: https://github.com/theforeman/puppet-puppet
foreman: https://github.com/theforeman/puppet-foreman
foreman_proxy: https://github.com/theforeman/puppet-foreman_proxy
extlib: https://github.com/voxpupuli/puppet-extlib.git
nftables: https://github.com/voxpupuli/puppet-nftables.git
docker: https://github.com/puppetlabs/puppetlabs-docker
redis: https://github.com/voxpupuli/puppet-redis.git
archive: https://github.com/voxpupuli/puppet-archive
concat: https://github.com/puppetlabs/puppetlabs-concat
ssh_keys: https://github.com/puppetlabs/puppetlabs-sshkeys_core
Expand Down
95 changes: 88 additions & 7 deletions site/profiles/REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,29 @@
* [`profiles::borg`](#profiles--borg): configures borg backups
* [`profiles::certbot`](#profiles--certbot): configures the certbot foo. Doesn't create certificates!
* [`profiles::docker`](#profiles--docker): installs docker
* [`profiles::foreman`](#profiles--foreman): configure foreman + plugins
* [`profiles::github_runners`](#profiles--github_runners): configures a self-hosted github runner
* [`profiles::grafana`](#profiles--grafana): installs grafana to display stats from dropsonde about Vox Pupuli modules
* [`profiles::nftables`](#profiles--nftables): configure certain nftable rules
* [`profiles::nginx`](#profiles--nginx): multiple profiles requires nginx vhosts, this profile pulls in the nginx class/package/service setup
* [`profiles::node_exporter`](#profiles--node_exporter): install node_exporter
* [`profiles::postfix`](#profiles--postfix): installs postfix
* [`profiles::postgres_exporter`](#profiles--postgres_exporter): installs a postgres exporter
* [`profiles::postgresql`](#profiles--postgresql): install latest postgresql with upstream repositories
* [`profiles::prometheus`](#profiles--prometheus): install Prometheus
* [`profiles::puppetagent`](#profiles--puppetagent): profile to manage puppet agent + deps
* [`profiles::puppetcode`](#profiles--puppetcode): some resources to manage puppete code
* [`profiles::puppet`](#profiles--puppet): configure puppet agent and server
* [`profiles::puppetmodule`](#profiles--puppetmodule): configures puppetmodule.info
* [`profiles::redis`](#profiles--redis): configures redis on different platforms
* [`profiles::ssh`](#profiles--ssh): ssh profile to manage sshd + ssh keys
* [`profiles::ssh_keys`](#profiles--ssh_keys): configure keys from GitHubs in the authorized_keys file
* [`profiles::vpt`](#profiles--vpt): this profile will, in the future, instal Vox Pupuli Tasks

#### Private Classes

* `profiles::github_runners::ruby`: install ruby for GitHub self hosted runners
* `profiles::puppet::code`: some resources to manage puppete code
* `profiles::puppet::db`: installs puppetdb *on a puppetserver that also runs foreman*
* `profiles::puppet::server_firewalling`: manages nft rules on Puppetserver/PuppetDB

### Defined types

Expand Down Expand Up @@ -153,6 +158,14 @@ configures the certbot foo. Doesn't create certificates!

installs docker

### <a name="profiles--foreman"></a>`profiles::foreman`

configure foreman + plugins

* **See also**
* `cat
* /opt/puppetlabs/puppet/cache/foreman_cache_data/admin_password` provides the admin password

### <a name="profiles--github_runners"></a>`profiles::github_runners`

configures a self-hosted github runner
Expand Down Expand Up @@ -287,6 +300,51 @@ Data type: `String[1]`

Default value: `$postgresql_user`

### <a name="profiles--nftables"></a>`profiles::nftables`

configure certain nftable rules

#### Parameters

The following parameters are available in the `profiles::nftables` class:

* [`in_ssh`](#-profiles--nftables--in_ssh)
* [`icmp`](#-profiles--nftables--icmp)
* [`nat`](#-profiles--nftables--nat)
* [`out_all`](#-profiles--nftables--out_all)

##### <a name="-profiles--nftables--in_ssh"></a>`in_ssh`

Data type: `Boolean`

allows incoming ssh connections

Default value: `true`

##### <a name="-profiles--nftables--icmp"></a>`icmp`

Data type: `Boolean`

allow all ICMP traffic

Default value: `true`

##### <a name="-profiles--nftables--nat"></a>`nat`

Data type: `Boolean`

decide if the box should be allowed to handle NAT traffic

Default value: `false`

##### <a name="-profiles--nftables--out_all"></a>`out_all`

Data type: `Boolean`

Allow all outbound connections

Default value: `false`

### <a name="profiles--nginx"></a>`profiles::nginx`

multiple profiles requires nginx vhosts, this profile pulls in the nginx class/package/service setup
Expand Down Expand Up @@ -315,7 +373,7 @@ The following parameters are available in the `profiles::postgresql` class:

##### <a name="-profiles--postgresql--version"></a>`version`

Data type: `Enum['11', '12', '13', '14']`
Data type: `Enum['11', '12', '13', '14', '15']`

desired postgresql version

Expand All @@ -325,13 +383,32 @@ Default value: `'13'`

install Prometheus

### <a name="profiles--puppetagent"></a>`profiles::puppetagent`
### <a name="profiles--puppet"></a>`profiles::puppet`

configure puppet agent and server

#### Parameters

The following parameters are available in the `profiles::puppet` class:

* [`server`](#-profiles--puppet--server)
* [`manage_msgpack`](#-profiles--puppet--manage_msgpack)

##### <a name="-profiles--puppet--server"></a>`server`

Data type: `Boolean`

profile to manage puppet agent + deps
decide if the server should be configured as well

### <a name="profiles--puppetcode"></a>`profiles::puppetcode`
Default value: `($trusted['pp_role'] == 'puppetserver'`

some resources to manage puppete code
##### <a name="-profiles--puppet--manage_msgpack"></a>`manage_msgpack`

Data type: `Boolean`

configure if we should install msgpack on the agent

Default value: `($facts['os']['name'] != 'gentoo'`

### <a name="profiles--puppetmodule"></a>`profiles::puppetmodule`

Expand Down Expand Up @@ -382,6 +459,10 @@ the database user

Default value: `'puppetmodule'`

### <a name="profiles--redis"></a>`profiles::redis`

configures redis on different platforms

### <a name="profiles--ssh"></a>`profiles::ssh`

ssh profile to manage sshd + ssh keys
Expand Down
22 changes: 14 additions & 8 deletions site/profiles/manifests/base.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@
package { 'snapd':
ensure => 'absent',
}
# do an apt update daily, don't log it, run it before packages
class { 'apt':
update => {
frequency => 'daily',
loglevel => 'debug',
},
}
# ensure update runs before installing packages
Class['apt::update'] -> Package <| provider == 'apt' |>

# https://www.sshaudit.com/hardening_guides.html
class { 'ssh':
storeconfigs_enabled => false,
Expand Down Expand Up @@ -162,12 +172,8 @@
}
}

class { 'nftables':
in_ssh => true,
in_icmp => true,
out_icmp => true,
in_out_conntrack => true,
reject_with => false,
out_all => true,
}
include profiles::nftables

# configure puppet agent/server
contain profiles::puppet
}
55 changes: 55 additions & 0 deletions site/profiles/manifests/foreman.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#
# @summary configure foreman + plugins
#
# @see `cat /opt/puppetlabs/puppet/cache/foreman_cache_data/admin_password` provides the admin password
#
class profiles::foreman {
require profiles::redis
require profiles::postgresql
require profiles::nftables # ensures hkp access is working to download the apt key

class { 'foreman::repo':
repo => '3.11',
}

class { 'foreman':
logging_type => 'journald',
initial_admin_username => 'admin',
initial_admin_first_name => 'Vox',
initial_admin_last_name => 'Pupuli',
initial_admin_email => 'pmc@voxpupuli.org',
register_in_foreman => true, # is a foreman 3.1+ feature
rails_cache_store => {
'type' => 'redis',
'urls' => ['localhost:6379/0'],
'options' => {
'compress' => 'true',
'namespace' => 'foreman',
},
},
}
$packages = $facts['os']['family'] ? {
'RedHat' => ['rubygem-foreman_puppet', 'rubygem-puppetdb_foreman'],
'Debian' => ['ruby-foreman-puppet', 'ruby-puppetdb-foreman'],
}
$packages.each |$package| {
package { $package:
ensure => 'installed',
require => Package['foreman-service'],
notify => Service['foreman'],
}
}
class { 'foreman_proxy':
register_in_foreman => true, # is a foreman 3.1+ feature
puppet => true,
puppetca => true,
tftp => false,
dhcp => false,
dns => false,
bmc => false,
realm => false,
}
# open http/https in firewall
require nftables::rules::http
require nftables::rules::https
}
1 change: 1 addition & 0 deletions site/profiles/manifests/grafana.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
String[1] $postgresql_user = 'grafana',
String[1] $postgresql_database = $postgresql_user,
) {
require profiles::base
$domain = "grafana.${facts['networking']['fqdn']}"
require profiles::nginx
require profiles::certbot
Expand Down
Loading
Loading