Skip to content

Instantly share code, notes, and snippets.

@EntropyWorks
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save EntropyWorks/f227239e33298851b9fb to your computer and use it in GitHub Desktop.

Select an option

Save EntropyWorks/f227239e33298851b9fb to your computer and use it in GitHub Desktop.
Vagrantfile and vangrant.yml for testing bifrost

Bifrost running inside vagrant virtualbox

Yes I know this is not perfect and Virtualbox does not pass the VT-x instructions making using it painfully slow. I will adding provider to use VMware Fusion and hopefully ESXi.

With the that out of the way.

  1. "git clone https://github.com/EntropyWorks/bifrost.git"
  2. "cd bitfrost"
  3. "curl -L -o Vagrantfile https://goo.gl/qP9Zla"
  4. "curl -L -o vagrant.yml https://goo.gl/jILciH"
  5. "vagrant up"
  6. "vagrant ssh"
  7. "cp -r ~vagrant/.ssh /root
  8. "exit"
  9. "vagrant provision"

That got me closer but still not all the way.

Error

PLAY [Tests connectivity to the VM] *******************************************

TASK: [bifrost-test-vm | Execute ping step to verify connectivity and login to the host.  If this fails, the configdrive may not have loaded.] ***
<192.168.122.2> ESTABLISH CONNECTION FOR USER: cirros
<192.168.122.2> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=cirros -o ConnectTimeout=10 192.168.122.2 hostname
fatal: [192.168.122.2] => SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
           to retry, use: --limit @/root/test-bifrost-dynamic.yaml.retry

127.0.0.1                  : ok=79   changed=32   unreachable=0    failed=0
192.168.122.2              : ok=0    changed=0    unreachable=1    failed=0
testvm1                    : ok=36   changed=26   unreachable=0    failed=0

****************************
Test failed. See logs folder
****************************
Making logs directory and collecting logs.

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
           to retry, use: --limit @/Users/yazz/vagrant.retry

bifrost                    : ok=11   changed=5    unreachable=0    failed=1

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

See what I have

Login in again "vagrant ssh"

vagrant@vagrant-ubuntu-vivid-64:~$ virsh list --all
 Id    Name                           State
----------------------------------------------------
 5     testvm1                        running
 
 vagrant@vagrant-ubuntu-vivid-64:~$ cd /srv/bifrost/
vagrant@vagrant-ubuntu-vivid-64:/srv/bifrost$ . env-vars
vagrant@vagrant-ubuntu-vivid-64:/srv/bifrost$ ironic node-list
+--------------------------------------+------+---------------+-------------+--------------------+-------------+
| UUID                                 | Name | Instance UUID | Power State | Provisioning State | Maintenance |
+--------------------------------------+------+---------------+-------------+--------------------+-------------+
| a8cb6624-0d9f-c882-affc-046ebb96ec01 | None | None          | power on    | active             | False       |
+--------------------------------------+------+---------------+-------------+--------------------+-------------+
vagrant@vagrant-ubuntu-vivid-64:/srv/bifrost$ ironic port-list
+--------------------------------------+-------------------+
| UUID                                 | Address           |
+--------------------------------------+-------------------+
| 22d28ab5-3507-4ca4-bd09-b7d01b5eb5a0 | 52:54:00:8b:07:3f |
+--------------------------------------+-------------------+
vagrant@vagrant-ubuntu-vivid-64:/srv/bifrost$ ironic driver-list
+---------------------+-------------------------+
| Supported driver(s) | Active host(s)          |
+---------------------+-------------------------+
| agent_ilo           | vagrant-ubuntu-vivid-64 |
| agent_ipmitool      | vagrant-ubuntu-vivid-64 |
| agent_ssh           | vagrant-ubuntu-vivid-64 |
| agent_ucs           | vagrant-ubuntu-vivid-64 |
| pxe_amt             | vagrant-ubuntu-vivid-64 |
+---------------------+-------------------------+
---
###############################################################################
#
# The vagrant vm's IP address is assumed to be 192.168.99.12
#
- hosts: bifrost
sudo: yes
tasks:
############################################################################
# APT Updates
############################################################################
- name: Stop updating /etc/resolv.conf
command: "sudo resolvconf --disable-updates"
# Make sure our VM's software is ~@Latest
- name: Apt Update
apt: update_cache=yes
upgrade=dist
cache_valid_time=86400
############################################################################
# Install all the needed packages in one go.
############################################################################
- name: Install Required Packages
apt: name={{item}}
state=present
with_items:
- ansible
- build-essential
- git
- libvirt-bin
- python-dev
- python-pip
- python-setuptools
- qemu
- vim
# Reboot if required.
- name: Reboot system if required
command: shutdown -r now 'Rebooting to complete system upgrade'
removes=/var/run/reboot-required
register: rebooted
- name: Wait for VM Reboot.
sudo: no
local_action: wait_for
port=22
host="{{ip}}"
search_regex=OpenSSH
delay=30
timeout=900
when: rebooted.changed
############################################################################
# Get the bifrost code
############################################################################
- name: Clone bifrost repo
git: repo=https://github.com/EntropyWorks/bifrost.git
accept_hostkey=true
dest=/srv/bifrost
version=master
############################################################################
# Switching from the virbr0 to eth1 so I can provision other virtual machines
# not just within this Vagrant Box itself
############################################################################
#- name: Set proper network interface in ansible config
# lineinfile: "dest=/srv/bifrost/playbooks/inventory/group_vars/all
# regexp='^network_interface: \"virbr0\"'
# line='network_interface: eth1'"
############################################################################
# If I uses python-pip it fails later during the ironic-install
# TASK: [ironic-install | proliantutils - Install from pip] *********************
# ImportError: cannot import name IncompleteRead
############################################################################
- name: Remove problem package
apt: name={{item}}
state=absent
with_items:
- python-pip
- name: Add pip via easy_install
command: easy_install pip
############################################################################
# Add vagrant user to libvirtd just for virsh testing later. Will be removed
############################################################################
- name: Add libvirtd group if missing
group: name=libvirtd
state=present
system=yes
############################################################################
# Generate ssh-key for vagrant user
############################################################################
- name: Add vagrant user to libvirtd group
user: user=vagrant groups=libvirtd generate_ssh_key=yes append=yes
############################################################################
# Run the bifrost ansible-playbook
# Todo: see if I can get Virtualbox VM's -e "network_interface=eth1"
############################################################################
- name: Install Bifrost and build bootable image. This takes a very long time
command: ansible-playbook -i inventory/localhost install.yaml -e "testing=true"
args:
chdir: /srv/bifrost/playbooks
- name: Testing Bifrost. This may take sometime alos.
command: ansible-playbook -i inventory/localhost test-bifrost.yaml -e "testing=true"
args:
chdir: /srv/bifrost/playbooks
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Goals:
# - Create an isolated bifrost work environment that developlers can share.
# Todo:
# - Boot virtual machines in Virtualbox or VMware
VAGRANTFILE_API_VERSION = '2'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# There are some benifits to moving past ubuntu/trusty64
config.vm.box = 'ubuntu/vivid64'
if Vagrant.has_plugin?("vagrant-cachier")
# Configure cached packages to be shared between instances of the same base box.
# More info on http://fgrehm.viewdocs.io/vagrant-cachier/usage
config.cache.scope = :machine
end
config.vm.define 'bifrost' do |bifrost|
bifrost.vm.provider :virtualbox do |vb|
vb.customize ['modifyvm', :id, '--memory', '4096' ]
# vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'off']
vb.customize ["modifyvm", :id, "--natdnsproxy1", "off"]
vb.customize ["modifyvm", :id, "--natdnsproxy2", "off"]
end
bifrost.vm.network 'private_network', ip: '192.168.99.12' # It goes to 12.
bifrost.vm.provision 'ansible' do |ansible|
ansible.verbose = 'v'
ansible.playbook = 'vagrant.yml'
ansible.extra_vars = {
ip: '192.168.99.12'
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment