From 2e0ccdd92d76e4ab8ea170cb96a8affbcc35aa2a Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Thu, 26 Jan 2023 09:53:36 +0100 Subject: [PATCH] Add example setup_cosmos_modules script This patch adds an example script written in python to help people get started with writing their own implementation. The docs are also updated. --- docs/cosmos-puppet-ops.mkd | 3 + .../etc/puppet/setup_cosmos_modules.example | 134 ++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100755 global/overlay/etc/puppet/setup_cosmos_modules.example diff --git a/docs/cosmos-puppet-ops.mkd b/docs/cosmos-puppet-ops.mkd index af43745..5933cfe 100644 --- a/docs/cosmos-puppet-ops.mkd +++ b/docs/cosmos-puppet-ops.mkd @@ -380,6 +380,9 @@ different ways: proceed to step 3, otherwise use this dynamically generated list of modules. 3. Use a (very small) default set of modules from the pre-hook global/post-tasks.d/010cosmos-modules. +There is an example implementation of the script to help you get started with writing your own, +available in global/etc/puppet/setup_cosmos_modules.example. + HOWTO and Common Tasks ====================== diff --git a/global/overlay/etc/puppet/setup_cosmos_modules.example b/global/overlay/etc/puppet/setup_cosmos_modules.example new file mode 100755 index 0000000..9b4c7e2 --- /dev/null +++ b/global/overlay/etc/puppet/setup_cosmos_modules.example @@ -0,0 +1,134 @@ +#!/usr/bin/env python3 + +try: + from configobj import ConfigObj + + os_info = ConfigObj("/etc/os-release") +except (IOError, ModuleNotFoundError): + os_info = None + + +modulesfile: str = "/etc/puppet/cosmos-modules.conf" +modules: dict = { + "concat": { + "repo": "https://github.com/SUNET/puppetlabs-concat.git", + "upgrade": "yes", + "tag": "sunet-2*", + }, + "stdlib": { + "repo": "https://github.com/SUNET/puppetlabs-stdlib.git", + "upgrade": "yes", + "tag": "sunet-2*", + }, + "cosmos": { + "repo": "https://github.com/SUNET/puppet-cosmos.git", + "upgrade": "yes", + "tag": "sunet-2*", + }, + "ufw": { + "repo": "https://github.com/SUNET/puppet-module-ufw.git", + "upgrade": "yes", + "tag": "sunet-2*", + }, + "apt": { + "repo": "https://github.com/SUNET/puppetlabs-apt.git", + "upgrade": "yes", + "tag": "sunet-2*", + }, + "vcsrepo": { + "repo": "https://github.com/SUNET/puppetlabs-vcsrepo.git", + "upgrade": "yes", + "tag": "sunet-2*", + }, + "xinetd": { + "repo": "https://github.com/SUNET/puppetlabs-xinetd.git", + "upgrade": "yes", + "tag": "sunet-2*", + }, + "python": { + "repo": "https://github.com/SUNET/puppet-python.git", + "upgrade": "yes", + "tag": "sunet-2*", + }, + "hiera-gpg": { + "repo": "https://github.com/SUNET/hiera-gpg.git", + "upgrade": "yes", + "tag": "sunet-2*", + }, + "pound": { + "repo": "https://github.com/SUNET/puppet-pound.git", + "upgrade": "yes", + "tag": "sunet-2*", + }, + "augeas": { + "repo": "https://github.com/SUNET/puppet-augeas.git", + "upgrade": "yes", + "tag": "sunet-2*", + }, + "bastion": { + "repo": "https://github.com/SUNET/puppet-bastion.git", + "upgrade": "yes", + "tag": "sunet-2*", + }, + "pyff": { + "repo": "https://github.com/samlbits/puppet-pyff.git", + "upgrade": "yes", + "tag": "puppet-pyff-*", + }, + "dhcp": { + "repo": "https://github.com/SUNET/puppetlabs-dhcp.git", + "upgrade": "yes", + "tag": "sunet_dev-2*", + }, + "varnish": { + "repo": "https://github.com/samlbits/puppet-varnish.git", + "upgrade": "yes", + "tag": "puppet-varnish-*", + }, + "apparmor": { + "repo": "https://github.com/SUNET/puppet-apparmor.git", + "upgrade": "yes", + "tag": "sunet-2*", + }, + "docker": { + "repo": "https://github.com/SUNET/garethr-docker.git", + "upgrade": "yes", + "tag": "sunet-2*", + }, + "network": { + "repo": "https://github.com/SUNET/attachmentgenie-network.git", + "upgrade": "yes", + "tag": "sunet-2*", + }, + "sunet": { + "repo": "https://github.com/SUNET/puppet-sunet.git", + "upgrade": "yes", + "tag": "sunet-2*", + }, + "sysctl": { + "repo": "https://github.com/SUNET/puppet-sysctl.git", + "upgrade": "yes", + "tag": "sunet-2*", + }, + "nagioscfg": { + "repo": "https://github.com/SUNET/puppet-nagioscfg.git", + "upgrade": "yes", + "tag": "sunet-2*", + }, +} + +# When/if we want we can do stuff to modules here +if os_info: + if os_info["VERSION_CODENAME"] == "bullseye": + pass + +with open(modulesfile, "w") as fh: + for key in modules: + fh.write( + "{0:11} {1} {2} {3}\n".format( + key, + modules[key]["repo"], + modules[key]["upgrade"], + modules[key]["tag"], + ) + )