| Synopsis: Vagrant is a tool using virtual machine as box image. You can install Vagrant on Windows, Mac or Linux. |
Contents
Installation
Based on your preferences you can install vagrant either with urpmi or dnf from Mageia repositories.
For installation with urpmi:
# urpmi vagrant
For installation with dnf:
# dnf install vagrant
Current Mageia version of Vagrant is 2.3.7 and latest upstream version available is 2.4.1
An image has been created named defwxyz/mageia8, there.
Basic usage
You can start a VirtualBox machine with the following Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "defwxyz/mageia8"
#config.vm.box_version = "0.1.1"
config.vm.provider "virtualbox" do |v|
v.name = "merlin"
v.memory = 1024
v.cpus = 1
end
end
Then inside the folder where Vagrantfile is located, say:
vagrant up
And it starts to construct your virtual machine.
Then you type
vagrant ssh
Ansible provisioning
In order to use ansible_local provisioning, we need to first install Ansible. (This is usually done by Vagrant but this is a missing brick for Mageia.)
So here is an example to do it:
$ cat Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "defwxyz/mageia8"
#config.vm.box_version = "0.1.1"
config.vm.provision "shell", inline: "urpmi --auto ansible"
config.vm.provision "ansible_local" do |ansible|
ansible.playbook = "playbook.yml"
end
end
$ cat playbook.yml
- hosts: all
connection: local
tasks:
- name: "display facts"
debug:
var: ansible_facts
Docker provisioning
To use Docker provisioning, we need a supplementary step. (the capability is not yet available for Mageia in Vagrant)
For instance you can use the following Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "defwxyz/mageia8"
#config.vm.box_version = "0.1.1"
config.vm.provision "shell", inline: "sudo dnf -y install docker; sudo systemctl enable --now docker"
config.vm.provision "docker" do |d|
d.run "redis"
end
end
It will start a Redis Docker image inside the newly created Mageia vm.