This is a follow-on to my last post, Creating a Vagrant box from Oracle 11.2g Virtualbox Appliance. It tells how to modify the Vagrant box so it is Ansible-ready.
Start up the base Virtualbox instance.
If you successfully got vagrant up
to spin up a VirtualBox, you will see a new entry in the list that VirtualBox displays when it starts up (the bottom one in the screenshot below).

To get the Vagrant box to support Ansible, we need to modify the original one and then re-export it. In my case, the original box is called "oracle_11.2g", so I pick that one, click Start, and login as root (password = oracle).
Note:
One thing I found suprising about Vagrant is that an up/halt cycle of the vagrant box saves state. That is, if you
the installed software is still there.
vagrant up
,- install some software,
vagrant halt
, and thenvagrant up
againTo restart from a blank state (say, if you want to retest your Ansible script from step 1), you need to delete the VirtualBox that Vagrant generates, then run
vagrant up
.
Install EPEL
The version of Oracle Linux that comes in the 11.2g appliance does not provide a Python version greater than 2.4. (I'm guessing Oracle built there's based on Centos 5.9). To get a more recent Python, you need to install "Extra Packages for Enterprise Linux". I followed How to Enable EPEL Repository for RHEL/CentOS 6/5
- Logged in as root, right click and select "Open Terminal".
- Get and install the package of EPEL GPG keys and repository information.
[root@localhost ~]# wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm --2013-08-16 06:43:58-- http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm Resolving download.fedoraproject.org... 66.135.62.201, 67.203.2.67, 66.35.62.166, ... Connecting to download.fedoraproject.org|66.135.62.201|:80... connected. HTTP request sent, awaiting response... 302 FOUND Location: http://mirror.pnl.gov/epel/5/i386/epel-release-5-4.noarch.rpm [following] --2013-08-16 06:43:59-- http://mirror.pnl.gov/epel/5/i386/epel-release-5-4.noarch.rpm Resolving mirror.pnl.gov... 192.101.102.2 Connecting to mirror.pnl.gov|192.101.102.2|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 12232 (12K) [application/octet-stream] Saving to: `epel-release-5-4.noarch.rpm' 100%[==============================>] 12,232 --.-K/s in 0.09s 2013-08-16 06:44:00 (128 KB/s) - `epel-release-5-4.noarch.rpm' saved [12232/12232] [root@localhost ~]# rpm -ivh epel-release-5-4.noarch.rpm warning: epel-release-5-4.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 217521f6 Preparing... ################################# [100%] 1:epel-release ################################# [100%] [root@localhost ~]#
Install Python 2.6
# yum update # yum install python26 # cd /usr/bin # ln -sf python26 python [root@localhost bin]# python -V Python 2.6.8 #
Shut down the Virtualbox
# halt -p
Export the Box
We repeat the steps from the last log entry, except that we remove the old version before adding the new one.
$ cd ~/VirtualBox\ VMs/oracle_11.2g $ rm package.box $ vagrant package --base oracle_11.2g [oracle_11.2g] Clearing any previously set forwarded ports... [oracle_11.2g] Creating temporary directory for export... [oracle_11.2g] Exporting VM... [oracle_11.2g] Compressing package to: /Users/mark/VirtualBox VMs/oracle_11.2g/package.box $ vagrant box remove oracle_11.2g Removing box 'oracle_11.2g' with provider 'virtualbox'... $ vagrant box add oracle_11.2g package.box Downloading or copying the box... Extracting box...te: 216M/s, Estimated time remaining: --:--:--) Successfully added box 'oracle_11.2g' with provider 'virtualbox'! $
Add static IP to Vagrant box
$ cd ~/src/cm3/ansible $ vi Vagrantfile ... $ cat Vagrantfile VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "oracle_11.2g" config.vm.network :private_network, ip: "192.168.67.10" end $ vagrant up $ ping 192.168.67.10 PING 192.168.67.10 (192.168.67.10): 56 data bytes 64 bytes from 192.168.67.10: icmp_seq=0 ttl=64 time=1.071 ms ^C --- 192.168.67.10 ping statistics --- 1 packets transmitted, 1 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 1.071/1.071/1.071/0.000 ms $
Test to make sure ansible will connect on ssh
By default, Ansible ssh's in on the usual port.
$ ssh vagrant@192.168.67.10 vagrant@192.168.67.10's password: Last login: Sat Aug 17 18:54:12 2013 from 192.168.67.1 [vagrant@localhost ~]$ exit
Simple Ansible command
Add the static IP of the Vagrant host as well as the ssh credentials to the Ansible hosts file
$ vi /etc/ansible/hosts ... $ cat /etc/ansible/hosts [vagrant] 192.168.67.10 ansible_ssh_user=vagrant ansible_ssh_pass=vagrant ansible_ssh_pass=vagrant $
Hello World, in Ansible
$ cat playbook.yml - hosts: vagrant sudo: yes tasks: - name: Test task. command: /bin/echo "Hello World!" $
Action!
$ ansible-playbook playbook.yml PLAY [vagrant] *********************************************************** GATHERING FACTS ********************************************************** ok: [192.168.67.10] TASK: [Test task.] ******************************************************* changed: [192.168.67.10] PLAY RECAP *************************************************************** 192.168.67.10 : ok=2 changed=1 unreachable=0 failed=0 $Next up ... we build an Ansible playbook to install AOLSever, start up Oracle and install ArsDigita Community System.
No comments:
Post a Comment