Thursday, 5 April 2018

Basic Ansible in 10 mins


  • "site.yml" file
    • playbook containing
      • "roles" that will be applied to individual host groups / "hosts"
      • how the hosts will be accessed
        • and by what user to run as
      • Puppet equivalent is "nodes.pp"
  • "hosts" file
    • use real/local DNS hostname to define which hosts are in which hostgroups
      • example: webserver1, webserver2, haproxy1, haproxy2, mongo1, mongo2
      • some variables like "port" can be added too
  • "group-vars" directory
    • key/value pairs to use when generating output from template files
    • files named identically to hostgroup names defined in "hosts" file
    • these are more in-line in Puppet, and less controllable/flexible
  • "roles" directory
    • Puppet equivalents are "modules"/"classes"
    • directories arbitrarily named to match "roles" in site.yml
    • e.g. "tomcat", "common", "mongod"
    • "templates" directory
      • files with variables that are resolved using "group-vars" key/values
      • moved on to target systems using task keyword "template"
      • same name is used in Puppet
    • "files"
      • raw files to be moved into place on the target filesystems
      • used by tasks with keyword "file"
      • same name used in Puppet
    • "handlers"
      • "main.yml"
      • control system services on target systems
        • "service" keyword
        • "state", e.g. "restarted"
        • in Puppet, these are not broken out from other "resources"
    • "tasks"
      • this is the core list of actions to perform on target systems
      • Puppet equivalents are "includes"/"classes", maybe "modules" as well
      • "main.yml"
        • collection of tasks
        • uses yml structure
          • "name" is arbitrary reference for developers
          • ansible keyword to perform some action on the system
            • ansible keywords: "file", "template", "command"
              • puppet equivalents are called "resources"
          • conditionals/dependencies: "when", "notify", "wait_for"


Keeping up with Hashicorp's Vault

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.




Friday, 8 September 2017

Multiple SSH Keys settings for different github accounts

Say you have two keys. Add these two keys as following to ssh agent running on your local machine:

 $ ssh-add ~/.ssh/id_rsa_hacker
 $ ssh-add ~/.ssh/id_rsa_exchan

You can check your saved keys

 $ ssh-add -l

Sample ssh config settings, uses aliases in first line of blocks

 Host github-hacker
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa_hacker

 Host github-exchan
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa_exchan

then use normal flow to push your code

git clone git@github.com:hacker/myrepo.git

set remote host from the default (github.com) to match alias in the ssh config

git remote set-url origin git@github-hacker:hacker/myrepo.git
you can see the change in .git/config file if you look carefully
git add .
git commit -m "your comments" git push

Monday, 4 September 2017

Docker training on Mac, 001


Take these steps, and, afterwards, try to understand how and why they worked, including flags/options "passed into" the command.
  • install Docker for Mac
    • verify install
      • docker --version
    • run basic container test
      • docker run hello-world
  • install iTerm2
    • open a terminal window and split horizontally, then close
    • open a terminal window and split vertically, then close
  • run webserver
    • open a terminal window and split horizontal
    • in bottom pane, run: 
      • watch -d -n7 docker ps -a
      • as you take steps below, watch what changes occur in this window
    • in top window, run:
      • docker run -d -p 8080:80 --name mywebserver001 nginx
    • open this in your web browser
      • http://localhost:8080
  • shut it down
    • docker stop mywebserver001
    • docker rm mywebserver001

Monday, 20 March 2017

Linux boot process

There seems to be a strong interest when interviewing in this process.

  • bios
    • stands for: basic input / output system
    • does system integrity checks
    • find and runs MBR boot loader program
  • mbr
    • located on first sector of bootable disk
    • under 512 bytes, 3 parts
      • primary boot loader info (446 bytes)
      • disk partition info (64 bytes)
      • mbr validation check (last 2 bytes)
    • contains info on GRUB
    • summary: loads and exec GRUB
  • grub
  • kernel
  • init
  • runlevel

Thursday, 9 March 2017

System Services Migrating from Operations Teams to The Cloud

Done, or in process to some degree.
  • system installs
  • disk formatting
  • volume management
  • database replication
  • monitoring tools
  • service start / stop
  • service start / stop scripts
  • backup automation

Wednesday, 25 January 2017

fizzbuzz in ruby

#!/usr/bin/env ruby

(1..100).each do |num|
  three = (num % 3 == 0)
  five = (num % 5 == 0)
  print 'fizz' if three
  print 'buzz' if five
  print num if (!three and !five)
  puts
end

Interview questions: 2020-12

Terraform provider vs provisioner Load balancing Network Load Balancer vs Application Load Balancer  Networking Layer 1 vs Layer 4 haproxy u...