|
| 1 | +Objective |
| 2 | +========= |
| 3 | + |
| 4 | +To use virtual machine software VirtualBox and vagrant, and provisioning |
| 5 | +software Ansible, to produce an environment suitable for micromagnetic |
| 6 | +simulation. |
| 7 | + |
| 8 | +Quick Start |
| 9 | +=========== |
| 10 | + |
| 11 | +To get started with this repository and creating virtual machines without |
| 12 | +understanding the underlying concepts, simply adhere to the "Requirements" |
| 13 | +section below and use the Makefile as described in the "How to Use" section |
| 14 | +following it. |
| 15 | + |
| 16 | +Just remember that there is no shortcut to work done true and well. |
| 17 | + |
| 18 | +Introduction to Concepts |
| 19 | +======================== |
| 20 | + |
| 21 | +A number of different concepts interplay in this repository, so a brief |
| 22 | +introduction to them is provided here. |
| 23 | + |
| 24 | +Virtual Machines |
| 25 | +---------------- |
| 26 | + |
| 27 | +A virtual machine is a software that imitates a certain other software (usually |
| 28 | +an operating system or environment) on a certain hardware. For our purposes |
| 29 | +however, it can be thought of as an operating system running in an operating |
| 30 | +system. Virtual machines are useful because they allow software tasks to be |
| 31 | +undertaken in precisely defined environments with little repercussion on the |
| 32 | +host system they run on. These machines themselves can be described by single |
| 33 | +files representing the equivalent of a hard disk of the machine, as well as a |
| 34 | +description of the hardware that the virtual machine emulates. |
| 35 | + |
| 36 | +VirtualBox (www.virtualbox.org) is a virtualizer software that can create and |
| 37 | +manage virtual machines, and is open source and freely available under the GNU |
| 38 | +GPL (https://www.gnu.org/copyleft/gpl.html) at time of writing. It is a |
| 39 | +"provider" of virtual machines. Other popular provider software includes VMWare |
| 40 | +and KVM. |
| 41 | + |
| 42 | +Vagrant (www.vagrantup.com) is a wrapper around multiple pieces of software. It |
| 43 | +provides a command-line interface to the creation and provision of virtual |
| 44 | +machines, and provides a framework in which virtual machines can be easily |
| 45 | +shared. Most importantly for our purpose, this interfacing can be automated to |
| 46 | +generate virtual machines containing an environment without user |
| 47 | +intervention. This environment can then be used to complete our objectives. To |
| 48 | +specify this environment however, provisioning software is required. |
| 49 | + |
| 50 | +Provisioning |
| 51 | +------------ |
| 52 | + |
| 53 | +In the context of virtual machines, provisioning is the action of taking an |
| 54 | +existing virtual machine, and running select commands on it to result in a |
| 55 | +desired end-state. By "state", here we mean how storage is populated with |
| 56 | +packages, environment definitions, and more. The user of a provisioner |
| 57 | +describes the desired state of the system, and the provisioner makes it so. In |
| 58 | +the absence of a provisioner, shell commands can be executed by Vagrant to |
| 59 | +specify the state of the system, but for large projects this becomes unwieldy |
| 60 | +because focus is placed on the instructions needed to obtain the desired state, |
| 61 | +as opposed to the state itself. Since nobody really likes to write large |
| 62 | +projects in shell, a provisioner is recommended. |
| 63 | + |
| 64 | +Ansible (www.ansible.com) is a provisioner supported by Vagrant. It uses YAML |
| 65 | +syntax to describe plays to run on a remote system to define the |
| 66 | +environment. Since the focus is on the end-state of the system, idempotency a |
| 67 | +strong design concern, meaning that tasks only need to be run to achieve a |
| 68 | +change in the state, and are not run if they do not change the state or obtain |
| 69 | +information about it. Plays are described by playbook files, and may contain |
| 70 | +many roles; hence the existence of a "roles" directory in this |
| 71 | +repository. Roles are a way of breaking down a play into sensible sentence-like |
| 72 | +instructions, which in turn contain a number of tasks. Examples of role |
| 73 | +descriptions include "Install magpar." and "Configure passwordless SSH for |
| 74 | +BitBucket access." |
| 75 | + |
| 76 | +In addition to provisioning virtual machines, Ansible is a general framework |
| 77 | +for running instructions to define a state on any machine. This means that |
| 78 | +Ansible can be (and is) used by a host to create virtual machines using |
| 79 | +vagrant. This is convenient due to its inherent idempotency; a virtual machine |
| 80 | +need not be created and defined again from scratch if it already exists. |
| 81 | + |
| 82 | +Tying it together |
| 83 | +----------------- |
| 84 | + |
| 85 | +To conclude, virtual machines are created in this repository to produce build |
| 86 | +artefacts. Ansible is used to define the state of virtual machines, which are |
| 87 | +managed by Vagrant. Vagrant commands VirtualBox to create and internally manage |
| 88 | +virtual machines in an automated way. These virtual machines are in turn |
| 89 | +provisioned by Ansible to define their internal state. Once this provisioning |
| 90 | +has happened, a build artefact is produced according to the desired objective. |
| 91 | + |
| 92 | +Requirements |
| 93 | +============ |
| 94 | + |
| 95 | +This repository was developed on and designed for use by Ubuntu GNU/Linux, but |
| 96 | +should be usable by anyone using GNU/Linux and enough modification and |
| 97 | +persistence. The following software are required to use this repository for its |
| 98 | +intended purpose: |
| 99 | + |
| 100 | + - 2.6 <= Python < 3.0 |
| 101 | + > A note for bleeding-edge distribution users like ArchLinux; Ansible |
| 102 | + doesn't like Python 3.0. You may need to create a virtualenv |
| 103 | + (https://pypi.python.org/pypi/virtualenv) to ensure you are working with |
| 104 | + an older python version. |
| 105 | + - VirtualBox >= 4.3.28 |
| 106 | + - Vagrant >= 1.7.2 |
| 107 | + - Ansible >= 1.9 |
| 108 | + > available from the python package index (https://pypi.python.org/pypi). |
| 109 | + - thydel.patch Ansible role |
| 110 | + > command "ansible-galaxy install thydel.patch" with privileges. |
| 111 | + - yaegashi.blockinfile Ansible role |
| 112 | + > command "ansible-galaxy install yaegashi.blockinfile" with privileges. |
| 113 | + - Vagrant-vbguest plugin >= 0.10.0 |
| 114 | + > command "vagrant plugin install vagrant-vbguest" |
| 115 | +
|
| 116 | +The following software is recommended: |
| 117 | + |
| 118 | + - Cowsay |
| 119 | + |
| 120 | +How to Use |
| 121 | +========== |
| 122 | + |
| 123 | +Now that you have prepared your host machine by following the "Requirements" |
| 124 | +section, you will probably want to build a virtual machine. By way of example, |
| 125 | +if you want the full virtualmicromagnetics experience, command: |
| 126 | + |
| 127 | + make full |
| 128 | + |
| 129 | +This Makefile uses the master.yml playbook, which runs the "create_vm" |
| 130 | +role. This will create a virtual machine and provision it with the playbook |
| 131 | +passed as a command-line argument in the makefile, which should live in the |
| 132 | +jobs directory (see "Where things are" below). It will also do some |
| 133 | +post-provisioning tasks using the hookbook, again passed as a command-line |
| 134 | +argument. The fundamental difference between the playbook and the hookbook is |
| 135 | +that the playbook is run on the guest virtual machine by vagrant, and the |
| 136 | +hookbook is run on the host machine. Different Makefile targets may place |
| 137 | +different build artefacts in the artefacts directory (see 'Where Things Are' |
| 138 | +and 'Artefacts'). |
| 139 | + |
| 140 | +Artefacts |
| 141 | +========= |
| 142 | + |
| 143 | +After running a job from the Makefile, certain build artefacts may be |
| 144 | +created. At present only *.vhd (virtual hard disk) files are created, but other |
| 145 | +file types could be produced by future jobs. These files are to be used with |
| 146 | +virtual machine providers, such as VirtualBox. To use these files with the |
| 147 | +VirtualBox GUI, build a "New" machine with an 64 bit Ubuntu OS, and supply as |
| 148 | +much RAM as you are able. All virtual machines in this repository are built off |
| 149 | +such an operating system. |
| 150 | + |
| 151 | +Where Things Are |
| 152 | +================ |
| 153 | + |
| 154 | +In order to add jobs, one should edit the Makefile. In order to do that, one |
| 155 | +would need to know where things are, hence the purpose of this section. This |
| 156 | +repository is structured as follows: |
| 157 | + |
| 158 | + - Makefile: This is the makefile through which all jobs are conducted. |
| 159 | + |
| 160 | + - ansible.cfg and inventory.txt: These files are used by Ansible when the |
| 161 | + master.yml playbook is run. They contain configuration information. |
| 162 | + |
| 163 | + - roles/: This directory contains roles (obviously). Each role is given a |
| 164 | + subdirectory, and should not overlap. Each role directory contains |
| 165 | + tasks, and may also contain the subdirectories: |
| 166 | + |
| 167 | + - vars/ (variable definitions), |
| 168 | + - templates/ (files to duplicate to the guest virtual machine), |
| 169 | + - meta/ (metadata, such as role dependencies), |
| 170 | + - files/ (files used by tasks that aren't covered by the usecases of |
| 171 | + templates) |
| 172 | + |
| 173 | + as well as others we haven't thought of yet. |
| 174 | + |
| 175 | + - jobs/: This directory contains playbooks and directories that can be |
| 176 | + thought of as jobs in the Makefile. They are either provisioning playbooks, |
| 177 | + or post-provisioning hookbooks. |
| 178 | + |
| 179 | + - machines/: This directory is created by the Makefile, and houses the |
| 180 | + vagrant environment for each individual virtual machine. The provision |
| 181 | + process is recorded to a log file in the machine's directory (for example, |
| 182 | + the provision log for the lite build job exists in |
| 183 | + machines/virtualmicromagnetics-lite/virtualmicromagnetics-lite.log) |
| 184 | + |
| 185 | + - artefacts/: This directory is created by the Makefile, and houses build |
| 186 | + artefacts. |
| 187 | + |
| 188 | +Postamble |
| 189 | +========= |
| 190 | + |
| 191 | +See LICENSE.md for licensing details regarding distribution and |
| 192 | +liability. These tools are provided by the University of Southampton (Mark |
| 193 | +Vousden, Max Albert, Hans Fangohr and others). Neither the University of |
| 194 | +Southampton nor the authors assume any responsibility whatsoever for its use by |
| 195 | +other parties, and makes no guarantees, expressed or implied, about its |
| 196 | +quality, reliability, or any other characteristic. |
| 197 | + |
| 198 | +List of Things to do |
| 199 | +==================== |
| 200 | + |
| 201 | + - Learn how YAML linebreaks work, and reduce the lengths of lines to <80 |
| 202 | + characters. |
| 203 | + - Make syntax more consistent. |
0 commit comments