Oremo Ojwang
unread,Oct 16, 2022, 3:57:24 PM10/16/22Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
I intend to launch a number of of vms on multiple host machines. So I have a playbook that installs vagrant and virtualbox on the host machine. Following the installations, the playbook then copies specific Vagrantfile from the ansible controller to the remote host where vms are to be lauched via 'vagrant up'.
NB:
I am able to run the 'vagrant up' on the target machine but an error is thrown when I use the ansible playbook
Before running the ansible, I already have set up a sudoer user called devops.
Target host machines are ubuntu 22 desktop
ansible version 2.10.8
vagrant version 2.3.1
virtualbox version 6.1
Below is the playbook content:
---
- hosts: vagranthosts
remote_user: devops
become: yes
roles:
- robertdebock.virtualbox
- darkwizard242.vagrant
tasks:
- name: Show host's ip
debug:
msg: "{{ ansible_ssh_host }}"
- name: Remove vagrant previous file
file:
path: /home/devops/vagrant-deploy/Vagrantfile
state: absent
- name: install prerequisites
apt:
name: libfuse2
state: present
- name: move to vagrant-deploy and launch vms for this host
shell:
cmd: vagrant up
chdir: /home/devops/vagrant-deploy/
become: yes
Blow is the line use to run the playbook:
ansible-playbook -i hosts.ini install-vagrant.yaml -kK -vvv
Below the specific Vagrant file that is failing:
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# General Vagrant VM configuration.
config.vm.box = "bento/ubuntu-22.04"
config.ssh.insert_key = false
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.provider :virtualbox do |v|
v.memory = 1024
v.linked_clone = true
end
# vagrant server 01.
config.vm.define "app" do |app|
app.vm.hostname = "orc-app1.test"
app.vm.network :private_network, ip: "192.168.60.201"
end
# vagrant server 02
config.vm.define "app" do |app|
app.vm.hostname = "orc-app2.test"
app.vm.network :private_network, ip: "192.168.60.202"
end
end
Below is error:
fatal: [192.168.1.138]: FAILED! => {
"changed": true,
"cmd": "vagrant up",
"delta": "0:00:17.237544",
"end": "2022-10-15 12:09:06.419253",
"invocation": {
"module_args": {
"_raw_params": "vagrant up",
"_uses_shell": true,
"argv": null,
"chdir": "/home/devops/vagrant-deploy/",
"creates": null,
"executable": null,
"removes": null,
"stdin": null,
"stdin_add_newline": true,
"strip_empty_ends": true,
"warn": true
}
},
"msg": "non-zero return code",
"rc": 1,
"start": "2022-10-15 12:08:49.181709",
"stderr": "There was an error while executing `VBoxManage`, a CLI used by Vagrant\nfor controlling VirtualBox. The command and stderr is shown below.\n\nCommand: [\"showvminfo\", \"9420c5e1-629e-4148-8ce1-92658357a477\"]\n\nStderr: /usr/lib/virtualbox/VBoxManage: /tmp/.mount_vagranMxQRIa/usr/lib/libcurl.so.4: no version information available (required by /usr/lib/virtualbox/VBoxRT.so)\nVBoxManage: error: Failed to create the VirtualBox object!\nVBoxManage: error: Code NS_ERROR_ABORT (0x80004004) - Operation aborted (extended info not available)\nVBoxManage: error: Most likely, the VirtualBox COM server is not running or failed to start.",
"stderr_lines": [
"There was an error while executing `VBoxManage`, a CLI used by Vagrant",
"for controlling VirtualBox. The command and stderr is shown below.",
"",
"Command: [\"showvminfo\", \"9420c5e1-629e-4148-8ce1-92658357a477\"]",
"",
"Stderr: /usr/lib/virtualbox/VBoxManage: /tmp/.mount_vagranMxQRIa/usr/lib/libcurl.so.4: no version information available (required by /usr/lib/virtualbox/VBoxRT.so)",
"VBoxManage: error: Failed to create the VirtualBox object!",
"VBoxManage: error: Code NS_ERROR_ABORT (0x80004004) - Operation aborted (extended info not available)",
"VBoxManage: error: Most likely, the VirtualBox COM server is not running or failed to start."
],
"stdout": "",
"stdout_lines": []
}