Skip to content

Instantly share code, notes, and snippets.

View tuxmea's full-sized avatar

Martin Alfke tuxmea

View GitHub Profile
@tuxmea
tuxmea / xml parsing puppet provider
Last active August 29, 2015 14:16
XML parsing in a puppet provider
Data which needs to get parsed:
<AR>
<AR_ID><![CDATA[8]]></AR_ID>
<IP><![CDATA[172.16.100.208]]></IP>
<MAC><![CDATA[02:00:ac:10:64:d0]]></MAC>
<SIZE><![CDATA[1]]></SIZE>
<TYPE><![CDATA[IP4]]></TYPE>
<USED_LEASES>0</USED_LEASES>
<LEASES/>
@tuxmea
tuxmea / gist:bf376284ceaff1c1f450
Last active August 29, 2015 14:20
property and Puppet Type dependency
e.g.
onevnet_addressrange { 'foo':
ensure => present,
onevnet => 'bar',
...
}
Should check, that
onevnet { 'bar':
ensure => present,
...
[root@icinga icinga2]# /etc/init.d/icinga2 checkconfig
Checking configuration: Done
information/cli: Icinga application loader (version: v2.4.1)
information/ConfigCompiler: Compiling config file: /etc/icinga2/icinga2.conf
information/ConfigCompiler: Compiling config file: /etc/icinga2/constants.conf
information/ConfigCompiler: Compiling config file: /etc/icinga2/zones.conf
information/ConfigCompiler: Compiling config file: /usr/share/icinga2/include/itl
information/ConfigCompiler: Compiling config file: /usr/share/icinga2/include/command.conf
information/Utility: Loading library 'libmethods.so'
information/ConfigCompiler: Compiling config file: /usr/share/icinga2/include/command-icinga.conf
[root@puppetmaster icinga2]# /etc/init.d/icinga2 checkconfig
Checking configuration: Done
information/cli: Icinga application loader (version: v2.4.1)
information/ConfigCompiler: Compiling config file: /etc/icinga2/icinga2.conf
information/ConfigCompiler: Compiling config file: /etc/icinga2/constants.conf
information/ConfigCompiler: Compiling config file: /etc/icinga2/zones.conf
information/ConfigCompiler: Compiling config file: /usr/share/icinga2/include/itl
information/ConfigCompiler: Compiling config file: /usr/share/icinga2/include/command.conf
information/Utility: Loading library 'libmethods.so'
information/ConfigCompiler: Compiling config file: /usr/share/icinga2/include/command-icinga.conf
cat zones.conf
/*
* Generated by Icinga 2 node setup commands
* on 2016-02-16 12:58:19 +0100
*/
object Endpoint NodeName {
}
object Zone ZoneName {
@tuxmea
tuxmea / voxpupuli-make-mrconfig.sh
Last active February 26, 2016 18:25
Get all modules from voxpupuli usng myrepos (mr)
#!/bin/bash
set -e
# Strongly adapted from
# http://anonscm.debian.org/gitweb/?p=pkg-ruby-extras/pkg-ruby-extras.git;a=blob;f=make-mrconfig
function msg() {
echo "I: $1"
}
# static rsource declaration
class company_users::sysadmin {
user {'a':
groups => 'sysadmin',
}
user { 'c':
groups => 'sysadmin',
}
}
# hiera
uptream:
'abc_core':
'ips':
- '1.2.3.4'
- '1.2.3.5'
'port': 8080
'abc_cp_core':
'ips':
- '1.2.3.4'
RSpec.configure do |c|
c.before(:each) do
# work around https://tickets.puppetlabs.com/browse/PUP-1547
# ensure that there's at least one provider available by emulating that any
if Puppet::version < '3.2'
# ONLY WORKING WITH PUPPET 2.X !!
require 'puppet/provider/confine/exists'
Puppet::Provider::Confine::Exists.any_instance.stubs(:which => '')
else
# ONLY WORKING WITH PUPPET 3.X !!
@tuxmea
tuxmea / gist:d777e46a3779dd746d8761ee2bc224e1
Created June 20, 2019 09:54
puppetlabs-accounts remove user with ssh key not in home
diff --git a/manifests/key_management.pp b/manifests/key_management.pp
index 6171151..091afc5 100644
--- a/manifests/key_management.pp
+++ b/manifests/key_management.pp
@@ -22,6 +22,7 @@
# @api private
#
define accounts::key_management(
+ Enum['present','absent'] $ensure = 'present',
String $user,