Wednesday, November 23, 2016

Customize Fedora 25 in a few minutes using Ansible

Instead of spending a few hours after installing Fedora 25 on adding the software you want and tweaking the options you prefer, why not use Ansible to get you up and running in minutes?

I assume you have already downloaded Fedora 25 Workstation from the official site at https://getfedora.org/, and that you have installed it, and that your personal user is allowed to run sudo (hint: being a member of the wheel group).


After logon to Fedora 25, download my Ansible playbook sample from https://github.com/avnes/blogsamples/blob/master/fedora.yml 

The rest of this article assumes you saved the file to ~/fedora.yml

Open ~/fedora.yml in a text editor (for instance vi or Gedit) and have look at what software it is installing, and what software it removes. Change it if you like.

When you are ready to play, run the following commands as your personal user:
sudo dnf install -y ansible
ansible-playbook ~/fedora.yml --connection=local --ask-become-pass

When promoted for a password, type in your personal password, and the playbook will then be executed with sudo rights. Both the sudo command and the ansible.playbook command will prompt you for your personal password.

Afterwards you should see a similar output as below, though changed would be higher than 0. In my case of is 0 because I have already run the playbook a few times already, so no changes.




Wednesday, November 9, 2016

How to install Vagrant with Oracle® VM VirtualBox and libvirt support on Antergos Linux

Installation

I recently needed to install Vagrant with support for Oracle® VM VirtualBox and libvirt for my dixie project at GitHub. Some of the virtualbox dependencies was found in this excellent post over at forum.antergos.com. Then I wrapped it into a script, and the here is the part of the script that installs and configures it:

if [ $(uname -r | grep ARCH | wc -l) -gt 0 ]; then
  sudo pacman -S --needed --noconfirm vagrant
  sudo pacman -S --needed --noconfirm libvirt
  sudo pacman -S --needed --noconfirm linux-headers
  sudo pacman -S --needed --noconfirm virtualbox virtualbox-guest-iso
  sudo pacman -S --needed --noconfirm vde2 net-tools virtualbox-ext-vnc virtualbox-host-modules-arch
  sudo pacman -S --needed --noconfirm ansible rsync
  sudo su -c "modprobe vboxdrv" || echo "Reboot your computer and try again"
  if [ ! -f "/etc/modules-load.d/virtualbox.conf" ]; then
    sudo touch /etc/modules-load.d/virtualbox.conf
  fi

  if [ $(grep vboxdrv /etc/modules-load.d/virtualbox.conf | wc -l) -eq 0 ]; then
    sudo su -c 'echo "vboxdrv" >> /etc/modules-load.d/virtualbox.conf'
  fi

  if [ $(grep vboxnetadp /etc/modules-load.d/virtualbox.conf | wc -l) -eq 0 ]; then
    sudo su -c 'echo "vboxnetadp" >> /etc/modules-load.d/virtualbox.conf'
  fi
  if [ $(grep vboxnetflt /etc/modules-load.d/virtualbox.conf | wc -l) -eq 0 ]; then
    sudo su -c 'echo "vboxnetflt" >> /etc/modules-load.d/virtualbox.conf'
  fi
  if [ $(grep vboxpci /etc/modules-load.d/virtualbox.conf | wc -l) -eq 0 ]; then
    sudo su -c 'echo "vboxpci" >> /etc/modules-load.d/virtualbox.conf'
  fi
fi

Install Ruby with gem support on Red Hat® Enterprise Linux

This post is heavily influenced by http://collectiveidea.com/blog/archives/2011/10/31/install-ruby-193-with-libyaml-on-centos/, so all credit to that author.

The problem

Installing a Ruby gem with gem install on  Red Hat® Enterprise Linux 6.8 returns errors indicating problems with libyaml:

gem install bundler
/usr/local/lib/ruby/1.9.1/yaml.rb:84:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.

The investigation

Trying to reinstall libyaml and libyaml-devel followed by a reinstall of ruby did not solve the issue.

The solution

After investigating this issue for a while, and not able to solve it through yum, I considered to either install and use rvm for this, or to download and compile the source. I found  http://collectiveidea.com/blog/archives/2011/10/31/install-ruby-193-with-libyaml-on-centos/ where the author had good success with the latter, so I did the same, but cleaning up all by Ruby and libyaml stuff from yum first:

yum remove -y ruby libyaml libyaml-devel rubygem-rake rubygems rubygems-devel

# Download and install libyaml
cd /tmp
wget http://pyyaml.org/download/libyaml/yaml-0.1.7.tar.gz
tar xzvf yaml-0.1.7.tar.gz
cd yaml-0.1.7
./configure --prefix=/usr/local
make
make install

# Download and install Ruby
cd /tmp
wget http://ftp.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.gz
tar xzvf ruby-2.3.1.tar.gz
cd ruby-2.3.1
./configure --prefix=/usr/local --enable-shared --disable-install-doc --with-opt-dir=/usr/local/lib
make install

# Install your gems
gem install bundler