Monthly Archives: September 2015

Harq’ al’Ada

I have been listening and reading all sorts of proposals on what Greece needs so that it can recover from its endemic recession. Many politicians and economics scientists, including the notorious Varoufakis, propose this recipe and that playbook that has worked in the past in this country or that region.

Quite frankly everything is going to fail for a single reason: Greece refuses to change the habits that are pushing towards the same fate as Atlantis. The country is rife with cronyism and sub educated supernumerary public sector employees to point out the most glaring problems.

What Greece needs is what the venerated Frank Herbert wrote throughout his work: the “Harq al’Ada”: the breaking of the habit. It is the same meme that Marvin Minsky denotes when he says: “Try to surprise yourself by the way you think today”. The old ways and the stale ancestor worshiping must end.

All that we Greeks knew, all that we know, is useless. We have to adapt or we will be overcome by our very own deficiencies  that is the gist of the 20th century and we are already treading water in the 21st. Adapting means changing fundamentally, in habits as well as values and I am calling on all intelligent people to get involved or Atlantis will no longer by an ancient myth.

Advertisements

Running ansible-playbook on a bastion host

Running ansible playbooks against AWS servers can be glacially slow because of the many SSH connections, even when using Bilbie’s recipe for an ssh proxy setup. What follows is a code snippet that replaces the local ansible-playbook command with a bash function that calls a remote script Run_ansible.sh. Run_ansible in turn massages the parameters in an edible-format creates a temp bash script and launches it.

Time savings for a largish deployment: down to 24 mins from 1hr 58Mins with exactly the same scripts!

Note: ansible-ssh-host is used in the inventory to denote the final target system


# if just local
ANSIBLE_PLAYBOOK=ansible-playbook

#
# Running the playbooks on the jump box
#
if [[ "$USE_JUMPBOX" == true ]]; then
    if [[ -n "$ANSIBLE_SSH_HOST" ]] && [[ -n "$JUMP_USER" ]] && [[ -n "$JUMP_BOX" ]]; then
        extra_vars=ansible_ssh_host=${ANSIBLE_SSH_HOST}

        # Now we need to pass parameters to the jump box
        ANSIBLE_PLAYBOOK=remote_ansible

        # massage the remote env
        # copy the playbooks over   
        ssh ${JUMP_USER}@${JUMP_BOX}  mkdir -p /tmp/deployment-ansible
        rsync -avuh --delete $WORKSPACE/ansible  ${JUMP_USER}@${JUMP_BOX}:/tmp/deployment-ansible/
        # copy the dispatcher script
        scp $WORKSPACE/Run_ansible.sh  ${JUMP_USER}@${JUMP_BOX}:
    else
        echo "ANSIBLE_SSH_HOST,JUMP_USER,JUMP_BOX must be set when USE_JUMPBOX is true" exit 1
    fi
fi
# --extra-vars must be the last parameter to ansible-playbook 
# or this hack will not work
function remote_ansible {
 ssh -t ${JUMP_USER}@${JUMP_BOX} /bin/bash -l ./Run_ansible.sh -vvv $@
}

And the helper script that runs on the bastion host. People with experience in quoting quotes over BASH driver SSH scripts will nod in understanding.


cat Run_ansible.sh
#/bin/bash

# quoting across SSH is a nightmare
params="$@"

params=`echo $params | sed -e "s/extra-vars/extra-vars \"/g"`
params="$params\""

echo "cd /tmp/deployment-ansible/ansible" > t
echo "ansible-playbook $params" >> t
bash t

Backup woes

Dirvish is a relatively nice disk backup program for linux and under certain conditions windows too. Unfortunately it likes to default to SSH to do the file transfers. It is not its fault directly because it is using RSYNC and RSYNC likes to use RSH/SSH unless one tweaks it.

But how do you actually tweak dirvish to use a native rsync protocol, that is without SSH as transport and without altering the code ? It only took me 1/2 a day to find out. Here is how

In every vault’s default.conf file there is the tree: line that specifies the top level the backup should start with. Plug there the rsync server’s module name prepended by colon like so

tree: :root

And of course you have to make sure that the rsync server contains a [root] stanza.

Done.