Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Initiates the process of renewing AWS sessions for when you need to
# use MFA authentication with the AWS CLI (or any tool that relies on the
# AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_SESSION_TOKEN env vars).
# The script assumes Python3 is installed.
#
# This script expects the following variables have been exported and
# are avilable to it:
# 1. AWS_IAM_MFA_DEVICE_ARN

We keep all our Terraform files under the terraform directory.

Terraform allows to reuse definitions across environments. We thus don't have to have a set of definitions for provisioning Onadata resources in the production environment and a different set of definitions for provisioning Onadata resources in the staging environment. How we go about this is by creating a shared Terraform module for our setup, then including this module in Terraform files corresponding to each of the environments we plan to deploy the setup.

The following subsections will take you through how to codify your setup using Terraform, the Ona way. As a reference, we will use Onadata's Terraform files:

1. Create a Reusable Module

Keep the Terraform resource blocks for your setup in ../terraform/modules/. For instance, the Onadata setup's resource blocks are kept in terraform/modules/onadata. Then isolate the Ter

How to move commits between two repos that don't share a commit history:

  • I have two repos github.com/<my employer>/playbooks and github.com/roots/trellis
  • github.com/<my employer>/playbooks has a directory wordpress/trellis
  • wordpress/trellis in github.com/<my employer>/playbooks contains code from github.com/roots/trellis, has changes made but commited in github.com/<my employer>/playbooks/.git all tracked changes from upstream have been lost (github.com/<my employer>/playbooks/wordpress/trellis/.git was deleted).

We need to merge the latest changes in github.com/roots/trellis with whatever changes we staged for github.com/<my employer>/playbooks/wordpress/trellis

  1. Clone [email protected]:roots/trellis.git
git clone [email protected]:roots/trellis.git
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
int main() {
int res;
res = sethostid(gethostid());
if (res != 0) {
switch (errno) {
case EACCES:
#!/bin/bash
echo "Enter the serial number for the device you want to switch to WiFi"
read serialNo
ipAddr=`adb -s ${serialNo} shell ifconfig wlan0 | sed -n 's/inet addr:\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*/\1/p'`
if [ -z "${ipAddr}" ]; then
ipAddr=`adb -s ${serialNo} shell netcfg | sed -n 's/wlan0[ ]*UP[ ]*\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*/\1/p'`
fi

Keybase proof

I hereby claim:

  • I am jasonrogena on github.
  • I am jasonrogena (https://keybase.io/jasonrogena) on keybase.
  • I have a public key whose fingerprint is FE16 05CD 2F20 E5DE 1CA2 B1F2 DB04 2D01 3212 3B07

To claim this, I am signing this object:

---
#- name: Copy the MariaDB root non-interactive password
# template: src=mariadb_non_interactive_password.sh.j2 dest=/tmp/mariadb_non_interactive_password.sh owner=root group=root mode=0700
#
#- name: Execute the MariaDB root non-interactive password file
# shell: /tmp/mariadb_non_interactive_password.sh
#
#- name: Delete the MariaDB non-interactive password file
# file: path=/tmp/mariadb_non_interactive_password.sh state=absent
- name: Set Debconf root_password
---
- name: Copy the MariaDB root non-interactive password
template: src=mariadb_non_interactive_password.sh.j2 dest=/tmp/mariadb_non_interactive_password.sh owner=root group=root mode=0700
- name: Execute the MariaDN root non-interactive password file
shell: /tmp/mariadb_non_interactive_password.sh
- name: Delete the non-interactive password file
file: path=/tmp/mariadb_non_interactive_password.sh state=absent
#! /bin/bash
export DEBIAN_FRONTEND=noninteractive
debconf-set-selections <<< 'mariadb-server mysql-server/root_password password {{ mariadb_root_password }}'
debconf-set-selections <<< 'mariadb-server mysql-server/root_password_again password {{ mariadb_root_password }}'