Posts

packer: virtualbox

Prep
Vagrantvagrant init hashicorp/precise64vagrant upvagrant destroy -f Generate Packerfind ~/.vagrant.d/ -name '*ovf' -ls | grep hashicreate ex001.jsonsee belowfix "source_path" to ovf file to match your systempacker validate ex001.jsonpacker build ex001.jsonvagrant box add my-box-001 packer_virtualbox-ovf_virtualbox.box --force Test mkdir test001cd test001vagrant initin generated "Vagrantfile", change 1st line to 2nd line  config.vm.box = "base"  config.vm.box = "my-box-001"vagrant upvagrant sshcat /var/tmp/welcome.txtshould say, "welcome001"vagrant destroy -f Cleanup vagrant box remove my-box-001 --forcevagrant box remove hashicorp/precise64 --force
ex001.json
{
  "builders": [{
      "type": "virtualbox-ovf",
      "source_path": "<path to your home dir>/.vagrant.d//boxes/hashicorp-VAGRANTSLASH-precise64/1.1.0/virtualbox/box.ovf",
      "ssh_username": "vagrant…

end is nigh: serverless

"For a small company focused on rapid growth, the last thing we wanted to deal with was disk space and memory management, logging agents, security patches, operating system updates, and other traditional server management processes."

recursive

def recursive_countdown(x):
    print('Countdown: ' + str(x))
    if x == 1:
        return 1
    else:
        return recursive_countdown(x - 1)

recursive_countdown(5)


def recursive_fib(x):
    #print('Fib: ' + str(x))
    if x in [0, 1]:
        return x
    else:
        return (recursive_fib(x - 1) + recursive_fib(x -2 ))

# this algo can be easily improved if answers are indexed

print(recursive_fib(5))
print(recursive_fib(6))
print(recursive_fib(7))
print(recursive_fib(8))

Python: sort by value then key

No idea yet how this works, or why. >>> d = {'apple': 7, 'banana': 3, 'almond': 7, 'peach': 4, 'beetroot': 3} >>> sorted(d.iteritems(), key=lambda(k, v): (-v, k)) [('almond', 7), ('apple', 7), ('peach', 4), ('banana', 3), ('beetroot', 3)]

Basic Ansible in 10 mins

"site.yml" fileplaybook containing"roles" that will be applied to individual host groups / "hosts"how the hosts will be accessedand by what user to run asPuppet equivalent is "nodes.pp""hosts" fileuse real/local DNS hostname to define which hosts are in which hostgroupsexample: webserver1, webserver2, haproxy1, haproxy2, mongo1, mongo2some variables like "port" can be added too"group-vars" directorykey/value pairs to use when generating output from template filesfiles named identically to hostgroup names defined in "hosts" filethese are more in-line in Puppet, and less controllable/flexible"roles" directoryPuppet equivalents are "modules"/"classes"directories arbitrarily named to match "roles" in site.ymle.g. "tomcat", "common", "mongod""templates" directoryfiles with variables that are resolved using "group-vars" key…

Keeping up with Hashicorp's Vault

Image
To retrieve secrets, employees replace plaintext secrets with a call to Secrets Manager APIs, eliminating the need to hard-code secrets in source code or update configuration files and redeploy code when secrets are rotated.