Skip to content

Instantly share code, notes, and snippets.

View JonTheNiceGuy's full-sized avatar

Jon "The Nice Guy" Spriggs JonTheNiceGuy

View GitHub Profile
@JonTheNiceGuy
JonTheNiceGuy / AA_Manipulating yaml tree data using Ansible.md
Last active February 21, 2019 09:35
Manipulating yaml tree data using Ansible

Manipulating yaml tree data using Ansible

I sometimes need to convert from a dictionary tree (like in data.yml) to a specific json formatted output file using Ansible.

In this case, I've used a combination of set_fact, a for loop and a combine filter to build my output. I'm also using a regex_search to make sure I'm only getting records where the data I'm interested in is there!

Hope it's useful to people!

Mapping the FortiGate Timezone Field with the TZ Database

This yml file shows the relationship between the tz_database values for regions (e.g. Europe/London) and the Fortigate "system global timezone" value (e.g. 25 = Europe/London).

The TZ Database names are taken from a Wikipedia entry on TZ values, and the Fortigate values are found by me splitting the strings (on comma's) from when I have tried auto-completing the timezone field on a Fortigate model.

It is not a perfect list! Updates welcome!!

@JonTheNiceGuy
JonTheNiceGuy / AAA_Readme for KPSync.md
Created April 25, 2019 22:35
Three-way sync on Keepass files, using Keepass2 and KPScript on a Linux based system.

This script is used if you want to do a three-way sync between (for example) Dropbox, Nextcloud and Syncthing (depending on your personal deployment capabilities).

It should be relatively easy to determine what tweaks are needed to reduce this to a 2-way sync, or up to a 4, 5 or even 6 way sync.

Sanitized Outlook Event Forwarding

This is an example of what I use with my work calendar, when I need to forward something to my personal calendar.

This macro does not include any of the meeting content (who will be there, what the content is), but is just to block out the time to prevent your personal and professional lives from overlapping. This macro will create a new appointment for the time window, optionally including the subject (or replace it with [WORK]) and optionally including the location (or replace it with [WORK]).

After the invite has been sent, it deletes the invite, so it doesn't look like you've got two meetings at the same time.

Readme for apt upgrades with Ansible

Here are three separate ways of using Ansible to perform system upgrades on an Ubuntu based system.

  1. apt-update-upgrade.yml This is the absolute most basic playbook I use. It performs an apt update, then apt full-upgrade and lastly an apt autoremove and apt autoclean.
  2. apt-update-upgrade-only-once-a-day.yml I use this in playbook where I'm repeatedly running it to do installs or reconfiguration, or where I have unattended-upgrades installed.
  3. apt-update-upgrade-with-check.yml On systems where I'm not the only administrator, I don't always know whether I'll want to apply an upgrade, so this gives me a chance to list off what packages will be updated
@JonTheNiceGuy
JonTheNiceGuy / Vagrantfile
Created August 6, 2019 15:36
Wordpress Development Machine in Vagrant
# Some of this is based on https://peteris.rocks/blog/unattended-installation-of-wordpress-on-ubuntu-server/
# and https://www.hongkiat.com/blog/install-wordpress-locally-vagrant/
Vagrant.configure("2") do |config|
config.vm.define "wordpress" do |wordpress|
wordpress.vm.hostname = "wordpress"
wordpress.vm.provider "virtualbox" do |vb|
vb.name = "wordpress"
end
@JonTheNiceGuy
JonTheNiceGuy / ssb_description.sh
Created November 19, 2019 16:14
How to publish an "about" message on Secure Scuttlebutt
ssb_id="$(if command -v jq >/dev/null 2>&1 ; then ssb-server whoami | jq -r .id ; else ssb-server whoami | grep id | cut -d\" -f4 ; fi)"
ssb-server publish --type about --about "$ssb_id" --name "JonTheNiceGuy" --description "Linux advocating geek. Fujitsu Distinguished Engineer since 2018. Blogging @ [jon.sprig.gs](jon.sprig.gs)
[Twitter](https://twitter.com/JonTheNiceGuy)|[FB](https://facebook.com/JonTheNiceGuy)|[LinkedIn](https://linkedin.com/in/JonTheNiceGuy) @ JonTheNiceGuy
🗺️ [Glossop, Derbyshire, UK : Maidenhead Grid: IO93ak](http://levinecentral.com/ham/grid_square?Grid=IO93ak) - Amateur Radio Callsign: [G7VRI](https://hamqth.com/g7vri)
He/Him
SameAs [Blog](@EFWzZK2K+b++CbBszsVkAB+WHlRJtX2kX8ynaJp0nHA=.ed25519), [Mobile](@3SEA7qNZQPiYFCzY6K57f0LTc9l+Bk6cewQc6lbs/Ek=.ed25519), [Laptop 1](@p3gu8eLHxXC0cuvZ0yXSC05ZROB4X7dpxGCEydIHZ0o=.ed25519), [Laptop 2](@3xnWXOEsfSNvazULuT54WL8AxGcUNCRyBPbCWcR/1ow=.ed25519), [Tablet](@ayUZ+IXBH8zX0HLk8A6h9YzIGy+LKy/RDIKJOT/xeVQ=.ed25519), [dispatch.sprig.gs Pub](@xp+Z

Thoughts on #SameAs

Preamble

I am not a particularly good coder. As such take these as a suggestion of what could be, not what is happening! If this were to be accepted, it would need to be adopted by all the SSB clients (ssb-server, manyverse, etc). Also, this may be extremely simplistic and may produce far too many messages to the pool very quickly!

I asked on the Scuttlebutt IRC channel, and it was suggested that @MixMix might be interested in this?

Actors

@JonTheNiceGuy
JonTheNiceGuy / a_readme.md
Created December 17, 2019 10:54
Create CA and Client Certificates on a protected CA Server, and transfer to them to your nodes, using Ansible

Create CA and Client Certificates on a protected CA Server, and transfer to them to your nodes, using Ansible

This is based on https://kapuablog.wordpress.com/2019/11/26/ansible-reading-a-remote-yaml-file/

It has been used in $my_service to generate client certificates on a protected Certificate Authority (CA) server (accessible only to my Ansible Tower/AWX server) and is then distributed to the client nodes.