SyntaxHighlighter JS

2021-07-02

Packer and package installs

Problem: 
When using Packer to generate an Ubuntu AWS AMI, I use a shell script provisioner to install and update packages via apt-get. When executing apt commands in the script, I was getting the errors such as: 
"Package has no installation candidate"
"Unable to locate package" 

 Solution: 
The error in the shell script was that I was executing apt-get commands before the AWS cloud-init completed.

To check that cloud-init finished before running apt-get, modify the script via

while [ ! -f  /var/lib/cloud/instance/boot-finished ];
do
    echo "Waiting for cloud-init to finish ..."
    sleep 2
done

apt-get update -y
apt-get install -y package

2018-10-29

Ruby on Rails json LoadError

Problem:
Running Ruby on Rails 'bin/rails s' and you get an error

in require: cannot load such file -- json (LoadError)


Solution:
Edit the Gemfile and add

gem 'json'


Installing Ruby on Rails on AWS Linux

To install Ruby on Rails on the AWS Linux VM, you need to install some prerequisites first.

sudo su -
yum install -y ruby24
alternatives --set ruby /usr/bin/ruby2.4
yum install -y ruby24-devel rubygems ruby24-devel gcc zlib-devel patch sqlite-devel
curl -sL https://rpm.nodesource.com/setup | bash -
yum install -y nodejs

gem install rails
rails --version

2018-10-26

Add hard disk to VMware CentOS 7 VM

There are two easy steps to add a hard disk for a a VMware CentOS 7 VM

  1.  Assign a new hard disk in VMware vSphere
  2.  Configure the new hard disk in CentOS
See the full picture tutorial at
https://dev.to/juttayaya/add-hard-disk-to-vmware-centos-7-vm-22m8

2018-10-25

Get the original username of sudo

For auditing and logging purposes, I needed to get the original Unix login username and not the sudo account name.

The Unix command to get the original login username is

logname 

With the logname command, the operator can su and sudo to various accounts and it will still display the original login.

To try it on a Unix prompt

sudo su - oracle
echo My sudo id is $(whoami) and my login id is $(logname)

Output:
My sudo id is oracle and my login id is juttayaya



Reference:https://stackoverflow.com/questions/4598001/how-do-you-find-the-original-user-through-multiple-sudo-and-su-commands