Skip to content

Instantly share code, notes, and snippets.

@aderixon
aderixon / passwd_history.pp
Created May 20, 2014 15:08
Example of enabling password history in PAM using Puppet/Augeas
class pam::passwd_history(
$num = 4
) {
case $::osfamily {
/(?i-mx:redhat)/: {
# enable password history
# if not present:
augeas { 'passwd-hist':
context => '/files/etc/pam.d/system-auth',
changes => ["set *[module =~ regexp('.*pam_unix.so')][type = 'password']/argument[last()+1] remember=${num}"],
@aderixon
aderixon / tally.pp
Created May 20, 2014 15:06
Example of enabling pam_tally on various Linux with Puppet/Augeas
class pam::tally {
$tally_deny = extlookup('tally_deny', 5)
case $::operatingsystem {
# EL
/(?i-mx:redhat|centos|oraclelinux|oel)/: {
$pammod = $::osmajor ? {
'6' => 'pam_tally2.so',
default => 'pam_tally.so',
}
@aderixon
aderixon / grub-rhgb.pp
Created June 5, 2014 15:13
Remove entries from grub.conf with augeas
augeas {
"Disable Graphical Boot in /etc/grub.conf":
context => "/files/etc/grub.conf",
lens => "grub.lns",
incl => "/etc/grub.conf",
changes => "rm title/kernel/rhgb";
"Disable Quiet Boot in /etc/grub.conf":
context => "/files/etc/grub.conf",
lens => "grub.lns",
incl => "/etc/grub.conf",
@aderixon
aderixon / ctrlaltdel.pp
Created May 20, 2014 15:11
Disable CTRL-ALT-DEL reboot sequence on Linux using Puppet
$initconf = '/etc/inittab'
case $::osfamily {
/(?i-mx:redhat)/: {
case $::osmajor {
'6': {
# EL6+ has a dedicated config file
file { '/etc/init/control-alt-delete.conf':
ensure => 'present',
source => "puppet:///modules/${module_name}/control-alt-delete.conf",
owner => 'root',

Time Machine configuration for filesystem

Create a case sensitive sparse bundle on the destination folder with:

hdiutil create -size 500g -type SPARSEBUNDLE -fs "HFS+J" -fsargs -s -volname 'TimeMachine' TimeMachine.sparsebundle

Tell TM to inherit it (sets the correct label):

sudo tmutil inheritbackup /path/to/TimeMachine.sparsebundle
---
# complete example
driver:
name: vagrant
vagrantfiles:
- test/vagrant-vbguest.rb
provision: true
provisioner:
name: ansible_playbook
@aderixon
aderixon / main.yml
Last active September 22, 2017 13:33
Ansible MySQL 5.7 Community Edition install
# before starting mysqld:
- name: check for MySQL pre systemd script
stat:
path: /usr/bin/mysqld_pre_systemd
register: pre_systemd
# Monkey-patch MySQL pre-start systemd script to prevent it setting
# a random root password
# Don't hate me, blame Oracle
@aderixon
aderixon / graylog-api-token.yml
Created November 13, 2018 11:30
Example of creating Graylog API token in Ansible
# Ansible tasks to obtain an existing API token from Graylog or
# create a new token if there isn't one.
# (Token can be used to create utility scripts from templates.)
# Token will be named 'ansible'.
# Illustrates use of uri module to interact with REST API,
# and JSON parsing in Ansible.
# Requires Graylog admin user & password.
- set_fact:
graylog_token: ''
@aderixon
aderixon / zonecfg-loop-bug.txt
Last active March 7, 2019 12:33
Solaris 11.3 bug/oddity with remote zonecfg in loop
Consider this script on Solaris 11.3:
#!/bin/ksh93
echo "a\nb\nc" | while read val; do
echo "$val :"
ssh -q remotehost "zonecfg -z azone \"select capped-memory; end;\""
done
When run, it will only execute the first iteration of the loop:
@aderixon
aderixon / uefi.sh
Last active September 11, 2019 08:16
Cobbler post-sync trigger script to generate GRUB2 per-client configurations
#!/bin/bash
# Write configs for UEFI boot from Cobbler, see:
# http://sapitnotes.com/cobbler-загрузка-по-pxe-в-режиме-uefi-centos-7/
# Translation:
# https://translate.google.com/translate?hl=en&sl=ru&u=http://sapitnotes.com/cobbler-%25D0%25B7%25D0%25B0%25D0%25B3%25D1%2580%25D1%2583%25D0%25B7%25D0%25BA%25D0%25B0-%25D0%25BF%25D0%25BE-pxe-%25D0%25B2-%25D1%2580%25D0%25B5%25D0%25B6%25D0%25B8%25D0%25BC%25D0%25B5-uefi-centos-7/&prev=search
# Adaptations by ajr, 2019-06
# Make executable and place in /var/lib/cobbler/triggers/sync/post/uefi.sh
# or equivalent for your Cobbler installation
for o_name in $(ls -A1 /var/lib/tftpboot/grub/ | grep -E '(.{2}-){6}.{2}');