Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

setting up a basic chef environment; chef server, chef workstation, nodes

Info:

setup 3 vm with below info, put these names under the hosts file on each vm.
Server Name
Function
Local user
chef-server
Chef server
anthony
chef-ws
Chef workstation
anthony
chef-client
Chef node
anthony

Setting up chef-server - standalone

Download the required installer file from chef website
$ dpkg -i chef-server-core_12.8.0-1_amd64.deb            
$ chef-server-ctl reconfigure
$ cd /etc/chef
$ chef-server-ctl user-create anthony anthony chin anthony.chin@bluecoat.com 'P@ssw0rd' --filename anthony.pem
$ chef-server-ctl org-create abctest 'ABC Test Co.' --association_user anthony --filename abctest-validator.pem

Setting up chef-workstation

In Ubuntu 16.04 workstation, download the chef-dk from chef website
$ dpkg -i chefdk_0.17.17-1_amd64.deb
$ mkdir -p ~/learn-chef/.chef
$ vi knife.rb

# See http://docs.chef.io/config_rb_knife.html for more information on knife configuration options

current_dir = File.dirname(__FILE__)
log_level                :info
log_location             STDOUT
node_name                "anthony"
client_key               "#{current_dir}/anthony.pem"
chef_server_url          "https://chef-server/organizations/abctest"
cookbook_path            ["#{current_dir}/../cookbooks"]

$ scp anthony@chef-server:/etc/chef/anthony.pem ./
$ knife ssl fetch  ß this will get the server certificate from chef-server when the server cert is self-sign.
$ knife ssl check
$ knife node list   ß if you are able to run this without any error, thus you have successfully authenticated with the chef-server

Setting up a cookbook

Extract and save the files under ~/learn-chef/cookbooks/
$ cd ~/learn-chef/cookbooks
$ knife cookbook list
$ knife cookbook upload learn_chef_apache2
$ knife cookbook list

Setting up chef-client (bootstrap from chef-workstation)

From chef-workstation
$ knife node list
$ knife bootstrap chef-client --ssh-user anthony --ssh-password 'P@ssw0rd' --sudo --use-sudo-password --node-name chef-client --run-list 'recipe[learn_chef_apache2]'
$ knife node list     ß you will have a “chef-client” node being added with a recipe associated
$ knife node show chef-client

By now, you have installed a chef server, chef workstation, and bootstrapped a node with a recipe associated with it.

Try load the http://chef-client from web browser and you shall get a “hello word” page.

reading dpkg -l output; what is ii what is rc ?



First letter -> desired package state ("selection state"):
  • u ... unknown
  • i ... install
  • r ... remove/deinstall
  • p ... purge (remove including config files)
  • h ... hold
Second letter -> current package state:
  • n ... not-installed
  • i ... installed
  • c ... config-files (only the config files are installed)
  • u ... unpacked
  • f ... half-configured (configuration failed for some reason)
  • h ... half-installed (installation failed for some reason)
  • w ... triggers-awaited (package is waiting for a trigger from another package)
  • t ... triggers-pending (package has been triggered)
Third letter -> error state (you normally shouldn't see a thrid letter):
  • r ... reinst-required (package broken, reinstallation required)

When to use old-release.ubuntu.com and when to use archive.ubuntu.com

If you are running a old version of Ubuntu, probably you will need to amend your /etc/apt/sources.list file to have "old-release" as the URL. As those older versions of packages may have been moved over to here.

deb http://old-releases.ubuntu.com/ubuntu/ lucid main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ lucid main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ lucid-updates main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ lucid-updates main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ lucid-security main restricted universe multiverse 

deb-src http://old-releases.ubuntu.com/ubuntu/ lucid-security main restricted universe multiverse

If you are running the later version of Ubuntu, probably you will be getting as below, which is correct.

root@ubuntu:/home/anthony# egrep -v '^#|^$' /etc/apt/sources.list
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
deb http://us.archive.ubuntu.com/ubuntu/ xenial universe
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
deb http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
deb http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu xenial-security main restricted
deb http://security.ubuntu.com/ubuntu xenial-security universe

deb http://security.ubuntu.com/ubuntu xenial-security multiverse

After you have done so, do an update on the index files.

root@ubuntu:/home/anthony# apt-get update

change Ubuntu default boot sequence

If you have dual-boot as me, Ubuntu and Windows 7, and wish to have Windows 7 as default boot.
Edit /etc/default/grub file, and change the value below to the line of your Windows 7.

For example, my Windows 7 was at line 5, you need to put it as "4", as the numbering starts at 0.

GRUB_DEFAULT=4

Save and exit, remember to run below to make it effective.

$ update-grub

Now reboot and it should have Windows 7 selected by default.

Ubuntu Change Preferred Default Boot Order

You have dual boot system; Ubuntu and Win7.
And you like to auto boot into the previous booted system.

Change GRUB_DEFAULT to "saved" and GRUB_SAVEDEFAULT to "true"

$ sudo vi /etc/default/grub
#GRUB_DEFAULT=0
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""


$ sudo update-grub
 
Now do a reboot and give it a try


change default editor in Ubuntu

Just installed Ubuntu, and tried to edit some files, but nano came out?
Not used to nano editor?

Change it to your preferred editor (vim in our case).

$ sudo update-alternatives –config editor
$ sudo update-alternatives –config editor
There are 5 alternatives which provide `editor’. 
Selection Alternative
———————————————–
1 /usr/bin/vim
2 /bin/ed
*+ 3 /bin/nano
4 /usr/bin/vim.basic
5 /usr/bin/vim.tiny
Press enter to keep the default[*], or type selection number: 

 

virtualbox '/etc/init.d/vboxdrv setup'

You probably have setup virtualbox with some vm.
And you have just upgraded some of the latest patches (including kernel packages as well).

And after reboot, you try to start the vm, but it shows errors, and asking you to try run '/etc/init.d/vboxdrv setup' 

Resolution:
- make sure you have your latest kernel installed along with the kernel-headers,

Under Fedora
-

Under Ubuntu
- there will be no /etc/init.d/vboxdrv command.
- You will need to make sure packages below are installed:

$ sudo aptitude install dkms virtualbox-dkms
$ sudo aptitude install linux-headers-3.5.0-26
$ sudo aptitude install linux-headers-3.5.0-26-generic
$ sudo dpkg-reconfigure virtualbox-dkms



Reference:
http://askubuntu.com/questions/205154/virtualbox-etc-init-d-vboxdrv-setup-issue

chkconfig in Ubuntu

If you have just installed an Ubuntu and install some new application such as SSH server (which Ubuntu didn't ship with by default). And you want to make it start upon system reboot.

In normal cases like Fedora or CentOS or Redhat, we can always use the chkconfig to to the job.
But how can we do it in Ubuntu?

Easy. Just install "sysv-rc-conf" package using apt-get.
Just enter the menu as below and select which run levels and services you want to start in one single menu.
> sudo sysv-rc-conf


How to Clean Up Ubuntu Grub Boot Menu After Upgrades

Ubuntu adopted the new version of the Grub boot manager in version 9.10, getting rid of the old problematic menu.lst. Today we look at how to change the boot menu options in Grub2.

Grub2 is a step forward in a lot of ways, and most of the annoying menu.lst issues from the past are gone. Still, if you’re not vigilant with removing old versions of the kernel, the boot list can still end up being longer than it needs to be.

There are few ways to cleanup the list,

1. You may just remove the older kernel packages (identify which is current via "uname -r") and run "sudo update-grub2"

2. You may just move those un-used packages to a folder (as long as not in the /root/ dir), and run the "sudo update-grub2".

eg:

root@Latitude:/boot# uname -r
2.6.35-24-generic
root@Latitude:/boot# mkdir old
root@Latitude:/boot# mv *2.6.35-22* old/
root@Latitude:/boot# update-grub2
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-24-generic
Found initrd image: /boot/initrd.img-2.6.35-24-generic
Found memtest86+ image: /memtest86+.bin
Found Microsoft Windows XP Professional on /dev/sda2
done