Thursday, January 1, 2015

New Blog Description for a New Year

Having had my own blog for many years with relatively little content it seems obvious I have had a hard time with it. Why? The main obstacle has been to collect diverse topics into one blog.  However, if I treat the blog like a conversation with colleagues then I think there is a higher chance for success. Let's think about the wide variety of lunch time conversations that happen:
1. Technology trends.
2. Workplace management / politics / news.
3. Devops / Agile / Waterfall
4. Welcoming new team members
5. Reminiscing with previous coworkers
6. Jokes
7. Faith / Jesus / God
Now this list came to mind in just a few minutes, which aligns with the idea that if I can spend just a few minutes on a post,  then I will be more likely to regularly post.  Plus if I can keep the stream of thought focus of my content similar to what you would get at a lunch with me then I should feel conformable blogging from my phone during the small breaks during any God given day. 
Right now I'm at the gym doing a chest workout. I'm using the android app Fitnotes,  having been a professional personal trainer in my lifetime, I will call my recommendation of the app FitNotes a professional opinion. We should have a whole conversation on its merits another day.
Talk to you later.

Saturday, December 20, 2014

Task: Create a Virtual Box for Atlas

[Task time 2 hours]

Use Atlas, a recently released product of Hashicorp, to host virtualbox images.  I already created an account, which was easy and free. I've also created my first box "abrooke/centos-7" from the web GUI at atlas. However, I need to now create a "box" for vagrant to upload it after configuring a "virtualbox" provider in my new box's configuration in Atlas and that is where the blog post is picking up the story...
  • Download a minimal ISO from centos.
  • Create a new VirtualBox VM and use the ISO to install centos.
    • Use "Nat" for the first network adapter.
    • Note the MAC address for later.
    • The minimal install doesn't come with dhclient running, so no IP. So addition setup instructions:
      • List the interfaces with "nmcli d"
      • Set the disconnected interface to automatically connect with "nmtui"
      • Then finally restart the network "systemctl restart network"
  • Then follow the instructions for createing a base box and Virtual Box specifics:
    • Set root password to "vagrant"
    • Add "vagrant" user using command: "adduser vagrant"
    • Set "vagrant" password to "vagrant" using command: "passwd vagrant"
    • Give "vagrant" user sudo permissions:
      • Run "visudo"
      • Add to the file "vagrant ALL=(ALL) NOPASSWD: ALL"
      • Remove "requiretty" so that sudo can run without a tty.
    • Add insecure key to authorized_keys file of the vagrant user.
      • Install wget as root: "yum install wget"
      • Wget the public key from vagrant on github and put it in the "authorized_keys" file of the "vagrant" user in the "~/.ssh/" directory.
      • Set modes for ssh files:
        • "chmod 600 ~/.ssh/authorized_keys"
        • "chmod 700 ~/.ssh"
    • Install Virtual Box guest additions:
      • REQUIRES bzip2, kernel-devel, kernel-headers, gcc:
        • "yum install bzip2"
        • "yum install kernel-devel-$(uname -r)"
        • "yum install kernel-headers-$(uname -r)"
        • "yum install gcc"
        • Troubleshooting: you might need to reboot.
      • Mount the Virtualbox guest additions:
        • Make sure the virtual cd with the additions is loaded.
        • Make mount point "/media/cdrom"
        • Now mount the "mount /dev/cdrom /media/cdrom"
    • Set "UseDNS  no" in the "/etc/ssh/sshd_config" to speed up the box when not connected to the internet.
  • HACK Vagrant version 1.7.1 to actually package the Vagrant Box:
  • Package box in current working directory with "vagrant package --base [name of VM]".

After the Vagrant box has been created, the testing of the box can be done by loading it into vagrant's box list using:
  • "vagrant add box [box name] [box path from package process]

After testing the box, the box can be uploaded to Atlas. Then subsequently a "Vagrantfile" can be configured to use it. Then "vagrant up" will use the "Vagrantfile" and download the box from Atlas. If the box is private in Atlas, then "vagrant login" will be necessary.

Tuesday, December 16, 2014

Start SSH Agent on Bash Shell Login (Works in Cygwin)

Automatically starting ssh-agent on login to bash shell can be done by adding the following script to ".bash_profile" file in a users home directly. This should work on linux and cygwin.  This script was adapted from the stack overflow post start-ssh-agent-on-login.



function start_agent {

    echo "Initialising new SSH agent..."
    /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
    echo succeeded
    chmod 600 "${SSH_ENV}"
    . "${SSH_ENV}" > /dev/null
    echo "Manage keys as follows..."
    echo "ssh-add <identity file>    Add identity file."
    echo "ssh-add -L                 List the keys currently."   
    echo "ssh-add -D                 Delete the keys."

# Source SSH settings, if applicable

if [ -f "${SSH_ENV}" ]; then

    . "${SSH_ENV}" > /dev/null
    #ps ${SSH_AGENT_PID} doesn't work under cywgin
    ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {

--- END SCRIPT ---