Skip to content

Instantly share code, notes, and snippets.

@casperghst42
casperghst42 / testfile.yml
Created May 23, 2024 14:35
Ansible: test for user existence
- name: get list of existing users
ansible.builtin.getent:
database: passwd
- name: get list of existing usernames
ansible.builtin.set_fact:
existing_users: "{{ ansible_facts.getent_passwd.keys() | list }}"
- name: create ansible user
ansible.builtin.user:
@casperghst42
casperghst42 / powertop.service
Created April 26, 2024 20:07
Start powertop --auto-tune on startup
[Unit]
Description=PowerTOP auto tune
[Service]
Type=oneshot
Environment="TERM=dumb"
RemainAfterExit=true
ExecStart=/usr/sbin/powertop --auto-tune
[Install]
[Default]
acceleration_breaking=50
acceleration_breaking_enable=false
acceleration_enabled=true
acceleration_infill=2500
acceleration_ironing=3000
acceleration_limit_mess="[[0.5,1.0,100,6000,210],[1.0,1.5,80,5500,200],[1.5,2.0,60,5000,190]]"
acceleration_limit_mess_enable=false
acceleration_prime_tower=2000
acceleration_print=2500
@casperghst42
casperghst42 / strip-xml-namespace.xslt
Last active October 27, 2023 12:07
Strip off XML NameSpace from the output of the NetIQ IDM Soap Driver. Not what one should do, but it make life easier, and the name space is not really needed.
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet exclude-result-prefixes="query cmd dncv" version="1.0" xmlns:cmd="http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.XdsCommandProcessor" xmlns:dncv="http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.DNConverter" xmlns:query="http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.XdsQueryProcessor" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- parameters passed in from the DirXML engine -->
<xsl:param name="srcQueryProcessor"/>
<xsl:param name="destQueryProcessor"/>
<xsl:param name="srcCommandProcessor"/>
<xsl:param name="destCommandProcessor"/>
<xsl:param name="dnConverter"/>
<xsl:param name="fromNds"/>
<!-- identity transformation template -->
<!-- in the absence of any other templates this will cause -->
@casperghst42
casperghst42 / create-cloud-init.sh
Last active July 4, 2024 09:34
Create a cloud-init Debian 12 image on proxmox
#!/bin/bash
# Author: Casper Pedersen (github.com/casperghst42)
# License: GPL2
wget https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2
virt-customize -a debian-12-generic-amd64.qcow2 --install qemu-guest-agent --install resolvconf --install systemd-resolved --update --run-command 'mkdir -p /etc/network/interfaces.d' --run-command 'echo "auto ens18" >> /etc/network/interfaces.d/ens18' --run-command 'echo "iface ens18 inet manual" >> /etc/network/interfaces.d/ens18'
qm create 100000 --name "debian12-cloudinit-template" --memory 2048 --net0 virtio,bridge=vmbr0
qm importdisk 100000 debian-12-generic-amd64.qcow2 local-lvm -format qcow2
@casperghst42
casperghst42 / docker.yml
Created September 10, 2023 10:26
Ansible Docker install on debian based distributions
- name: instal packages
apt:
state: present
install_recommends: false
pkg:
- bridge-utils
- ca-certificates
- curl
- gnupg
update_cache: true
@casperghst42
casperghst42 / sources.yml
Last active April 25, 2024 09:50
Add non-free-firmware to sources.list
- name: Add non-free repository
replace:
dest: /etc/apt/sources.list
regexp: '^(deb(?!.* non-free).*)'
replace: '\1 non-free'
@casperghst42
casperghst42 / wireless-power-save-tasks-main.yml
Last active January 5, 2023 17:15
disable Raspbian wireless-power-save with ansible
---
- name: wireless-power-save | create unit file
copy:
dest: /etc/systemd/system/wifi_powersave@.service
content: |
[Unit]
Description=Set WiFi power save %i
After=sys-subsystem-net-devices-wlan0.device
[Service]