Skip to content

Instantly share code, notes, and snippets.

View konstruktoid's full-sized avatar
🤖

Thomas Sjögren konstruktoid

🤖
  • Sweden
  • 06:50 (UTC +01:00)
  • LinkedIn in/thosjo
View GitHub Profile
@konstruktoid
konstruktoid / coreos_vagrant.sh
Last active October 9, 2024 15:04
Building an Fedora CoreOS Vagrant box
#!/bin/bash
set -eu -o pipefail
if ! command -v VBoxManage &> /dev/null; then
echo "[ERROR] VirtualBox is not installed"
exit 1
fi
if ! command -v vagrant &> /dev/null; then

ansible --version

ansible [core 2.16.7]
  config file = None
  configured module search path = ['/home/vagrant/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/vagrant/ansible/lib/python3.12/site-packages/ansible
  ansible collection location = /home/vagrant/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/vagrant/ansible/bin/ansible
  python version = 3.12.3 (main, Apr 10 2024, 05:33:47) [GCC 13.2.0] (/home/vagrant/ansible/bin/python3)
  jinja version = 3.1.4
$ 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=""