Skip to content

Instantly share code, notes, and snippets.

View konstruktoid's full-sized avatar
🤖

Thomas Sjögren konstruktoid

🤖
  • Sweden
  • 13:03 (UTC +02:00)
  • LinkedIn in/thosjo
View GitHub Profile
@konstruktoid
konstruktoid / build_systemd.sh
Last active May 3, 2024 14:12
Build systemd from source
#!/bin/bash
set -eux
RELEASE="256-rc1"
URI="https://github.com/systemd/systemd/archive/refs/tags/v${RELEASE}.tar.gz"
BUILD_DIR="/tmp/build-systemd-v${RELEASE}"
sudo apt-get update
sudo apt-get --assume-yes build-dep systemd
$ cat test.yml
---
- name: Testing
hosts: localhost
any_errors_fatal: true
gather_facts: false
tasks:
- name: Set sysctl configuration directory as fact
block:
- name: Stat /usr/lib/sysctl.d/ exists
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --dearmor --yes --output /usr/share/keyrings/oracle-virtualbox-2016.gpg
sudo apt-get --assume-yes update
sudo apt-get --assume-yes upgrade
sudo apt-get --assume-yes install libssl-dev python3-pip vagrant virtualbox
vagrant plugin install vagrant-scp
vagrant plugin install vagrant-vbguest
$ pip3 install -U ansible-core ansible-lint molecule "molecule-plugins[vagrant]"
[...]
WARNING: molecule-plugins 23.4.0 does not provide the extra 'vagrant'
[...]
$ pip3 install -U ansible-core ansible-lint molecule molecule-plugins molecule-vagrant
$ molecule check
Traceback (most recent call last):
File "/home/ubuntu/py310/bin/molecule", line 8, in <module>
sys.exit(main())
File "/home/ubuntu/py310/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
@konstruktoid
konstruktoid / Vagrantfile
Last active March 7, 2023 15:55
Vagrant file for ansible-rulebook testing
$ubuntu_script = <<-'UBUNTU'
apt-get update
apt-get --assume-yes upgrade
apt-get --assume-yes install build-essential maven openjdk-17-jdk python3-dev python3-pip
echo "
export JDK_HOME=/usr/lib/jvm/java-17-openjdk-amd64
export JAVA_HOME=\$JDK_HOME
export PIP_NO_BINARY=jpy
export PATH=\$PATH:~/.local/bin
@konstruktoid
konstruktoid / Vagrantfile
Created October 15, 2022 21:31
Vagrantfile for local testing of Github workflows
$script = <<-'SCRIPT'
apt-get update
curl -sSL get.docker.com | sh && sudo addgroup vagrant docker
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | bash
SCRIPT
Vagrant.configure("2") do |config|
config.vbguest.installer_options = { allow_kernel_upgrade: true }
config.vm.provider "virtualbox" do |v|
v.memory = 2048
---
- hosts: localhost
tasks:
- name: 8 character random string
ansible.builtin.set_fact:
generated_password: "{{ lookup('community.general.random_string', min_lower=1, min_upper=1, min_special=1, min_numeric=1) }}"
register: password
- name: print registered password
debug:
---
- hosts: all
any_errors_fatal: true
gather_facts: false
vars:
a:
b: 2
c: 3
tasks:
- name: inline if
@konstruktoid
konstruktoid / verabrute.sh
Created May 25, 2022 10:45
Brute force a VeraCrypt container when algorithms aren't known
#!/bin/bash
# So sorry it had to come to this, this is slow.
# Note that pim and keyfiles etc is static and needs to be modified if used.
# veracrypt --text --dismount --slot 1
set -eu -o pipefail
CONTAINER=""
MOUNTDIR=""
WORDLIST=""
@konstruktoid
konstruktoid / ansible-fqcn.sh
Created January 6, 2022 10:43
crude Ansible FQCN converter
#!/bin/bash
set -uo pipefail
builtin="add_host
apt
apt_key
apt_repository
assemble
assert