Skip to content

Instantly share code, notes, and snippets.

@markgraf
markgraf / NoneTypeAndAAnsibleMapping.md
Last active September 30, 2021 15:22
The tale of Ansible and the variable that should be there but isn't

The tale of Ansible and the variable that should be there but isn't

So I had a role where I needed to define lots of variables. I decided to split them over multiple files like this:

my_app/defaults/main/
  main.yml
  another.yml 

yet_another.yml

Unfortunately there is no repo for vagrant-packages to install .deb-packages from (see an ages old issue), so here's an ugly hack to install the latest version of vagrant through Ansible.

- name: Find latest vagrant-version
  shell: wget -qO - https://releases.hashicorp.com/vagrant/ | grep -o 'vagrant_[[:digit:]]\.[[:digit:]]\.[[:digit:]]' | sed 's/vagrant_//'| head -1
  register: vagrant_version.

- name: Install vagrant
@markgraf
markgraf / quick_script.md
Created April 29, 2020 19:38
Quickly turn your history into a shell script.

More often than not, I typed a couple of commands and realized that I will need those more often.

So I redirected my history into a file history > somefile.sh and edited that, removing line numbers and timestamps. Tedious work that can be automated with the following shell-function for bash.

qs () {
  # Quickly turns a shell-session into a script.
  # --------------------------------------------
 # The function will

So you deleted a private key file and have no backup?

It happened to me in my first IT job. I was told to rm a couple of outdated keyfiles. Of course they weren't named in a human readable manner. And of course I tab-completed to the wrong directory...

AAAAAAAAAAAAHHHH!!!

Of course, there was no such thing as "undelete" on the linux-box in question.

@markgraf
markgraf / extract_email.md
Last active May 20, 2018 12:07
So you need to extract email adresses from hundreds of excel-files and vcards?

Extracting email addresses

So your boss just jumped in, because he remembered that things need to be GDPR-compliant within the next few hours...
And of course he forgot to send the necessary mailing to your newsletter-subscribers.
And of course it's all properly documented in a haphazard mix of excel-files (each of which has a different layout), text-files, v-cards and the like...

So now you need to extract those email addresses from all those files, because doing it manually will never finish in time.