Skip to content

Instantly share code, notes, and snippets.

View h0tw1r3's full-sized avatar
🏝️
Living the dream

Jeffrey Clark h0tw1r3

🏝️
Living the dream
View GitHub Profile
@h0tw1r3
h0tw1r3 / rand.rb
Created January 2, 2023 19:13
puppet custom functions
# Return a random number
Puppet::Functions.create_function(:rand) do
# @param [Integer] max
# maximum random number
# @return [Variant[Integer,Float]]
# random number
# @example Calling the function
# rand(10)
dispatch :generate_random_number do
optional_param 'Integer', :max
@h0tw1r3
h0tw1r3 / PROXMOX_SOLARIS_INSTALL.md
Last active March 2, 2024 04:42
Solaris 11.4 CDE Install Proxmox
@h0tw1r3
h0tw1r3 / apply.pp
Last active October 20, 2022 21:56
Allow PE puppet nodes API access to delete their own certificate
pe_puppet_authorization::rule { 'allow-ca-client-delete-self':
match_request_path => '/puppet-ca/v1/certificate_status/([^/]+)$',
match_request_type => 'regex',
match_request_method => ['delete'],
allow => '$1',
sort_order => 500,
path => "/etc/puppetlabs/puppetserver/conf.d/auth.conf",
notify => Service['pe-puppetserver'],
}
@h0tw1r3
h0tw1r3 / 99-bottles-of-beer.pp
Created August 29, 2022 16:40
Puppet 99 Bottles of Beer on the Wall
$bottles = Integer[0,99].map |$bottle| { abs($bottle - 99) }
$report = {
bottles => '%s bottle%s of beer on the wall, %s bottle%s of beer.',
left => '%s bottle%s of beer on the wall.',
take => 'Take one down and pass it around',
buy => 'Go to the store and buy some more',
}
$bottles.map |$bottles_on_wall| {
@h0tw1r3
h0tw1r3 / nessusagent.pp
Last active October 26, 2022 17:35
Deploy nessus agent with Puppet
class nessusagent (
String $agent_key,
Array[String] $agent_groups = ['All'],
String $agent_name = $facts['networking']['hostname'],
String $nessus_host = 'cloud.tenable.com',
Integer $nessus_port = 443,
String $package_name = 'NessusAgent',
Hash $package_params = {
ensure => 'latest',
},
@h0tw1r3
h0tw1r3 / homebrew.pp
Last active July 28, 2022 21:43
Deploy shared homebrew on Linux
class homebrew (
Array[String] $packages = ['procps-ng', 'curl', 'file', 'git'],
) {
yum::group { 'Development Tools':
ensure => present,
}
-> package { $packages:
ensure => present
}
-> user { 'linuxbrew':
#!/bin/bash
# halt on any errors
set -o pipefail -e
BREW_INSTALL_PATH=/home/linuxbrew/.linuxbrew
if ! [ -x "/home/linuxbrew/.linuxbrew/bin/brew" ] ; then
if ! sudo -l -U root >/dev/null 2>&1 ; then
echo "root sudo permission required to install"
@h0tw1r3
h0tw1r3 / playbook-system-update.yml
Last active March 27, 2022 14:26
ansible playbook to update all apt or yum packages
---
- hosts: all
tasks:
- name: "yum: upgrade packages"
yum:
name: '*'
state: latest
update_cache: yes
update_only: yes
register: yum_update_status
@h0tw1r3
h0tw1r3 / check_lastupdate.py
Last active October 24, 2021 00:36
nagios style last system update check for yum, dnf and apt
#!/usr/bin/env python
from __future__ import print_function
from datetime import timedelta
from datetime import datetime
import os
import re
import sys
@h0tw1r3
h0tw1r3 / dns-sync.sh
Created April 19, 2020 19:53
Work-around issues with WSL DNS resolver
#!/bin/bash
# Based on https://gist.github.com/matthiassb/9c8162d2564777a70e3ae3cbee7d2e95
PATH=/sbin:/bin
WINSYS32=/mnt/c/Windows/System32
PS=$WINSYS32/WindowsPowerShell/v1.0/powershell.exe
CHCP=$WINSYS32/chcp.com
PIDFILE=/var/run/dns-sync.pid