Not sure if this is a vagrant thing or ansible thing, but running into a issue when trying to get an ansible playbook while specified in the vagrantfile. Here is my Vagrantfile:
# vi: set ft=ruby :
# -*- mode: ruby -*-
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
### Change to which ever you like. Adjust NODE_COUNT to number of nodes you want to spin up
PLUS_IMAGE = "vagrantubuntu20"
#FOSS_IMAGE = "ubuntu20-foss"
NODE_COUNT = 2
HOST_PORT_START = 8086
HA_PORT_START = 8081
PLUS_DASHBOARD = 9090
### This section install on 2 nodes
Vagrant.configure("2") do |config|
#config.vm.synced_folder "../data", "/vagrant_data"
(1..NODE_COUNT).each do |i|
config.vm.define "proxy-node0#{i}" do |subconfig|
subconfig.ssh.private_key_path = ["/home/xxx/.ssh/vagrant", "~/.vagrant.d/insecure_private_key"]
subconfig.vm.provision "file", source: "/home/xxx/.ssh/vagrant.pub", destination: "~/.ssh/authorized_keys"
subconfig.ssh.insert_key = false
#subconfig.ssh.username = "vagrant"
#subconfig.ssh.password = "vagrant"
#subconfig.ssh.insert_key = false
subconfig.vm.provider "virtualbox" do |vb|
vb.name = "node#{i}"
vb.memory = 1024
vb.cpus = 1
end
subconfig.vm.box = PLUS_IMAGE
subconfig.vm.hostname = "node0#{i}"
subconfig.vm.network :private_network, ip: "172.16.10.#{i + 20}"
subconfig.vm.network "forwarded_port", guest: 80, host: "#{HA_PORT_START + i}"
subconfig.vm.network "forwarded_port", guest: 8080, host: "#{PLUS_DASHBOARD + i}"
subconfig.vm.provision "ansible" do |ansible|
ansible.playbook = "./provisioners/ansible/mainplus.yml"
ansible.inventory_path = "./provisioners/ansible/inventory"
end
subconfig.vm.provision "setup-hosts", :type => "shell", :path => "provisioners/scripts/setup-hosts.sh" do |s|
s.args = ["enp0s8"]
end
end
end
#### The below codes configures 2 FOSSWeb servers that the top box will LB traffic to
#
(1..NODE_COUNT).each do |i|
config.vm.define "web0#{i}" do |subconfig|
subconfig.ssh.private_key_path = ["/home/xxxx.ssh/vagrant", "~/.vagrant.d/insecure_private_key"]
subconfig.vm.provision "file", source: "/home/xxxx/.ssh/vagrant.pub", destination: "~/.ssh/authorized_keys"
subconfig.ssh.insert_key = false
subconfig.vm.synced_folder "data/greyscale/", "/opt/www"
#subconfig.ssh.username = "vagrant"
#subconfig.ssh.password = "vagrant"
#subconfig.ssh.insert_key = false
subconfig.vm.provider "virtualbox" do |vb|
vb.name = "haweb0-#{i}"
vb.memory = 1024
vb.cpus = 1
end
subconfig.vm.box = PLUS_IMAGE
subconfig.vm.hostname = "web0#{i}"
subconfig.vm.network :private_network, ip: "192.168.10.#{i + 10}"
subconfig.vm.network "forwarded_port", guest: 80, host: "#{HOST_PORT_START + i}"
subconfig.vm.provision "ansible" do |ansible|
ansible.playbook = "./provisioners/ansible/mainfoss.yml"
ansible.inventory_path = "./provisioners/ansible/inventory"
end
subconfig.vm.provision "setup-hosts", :type => "shell", :path => "provisioners/scripts/setup-hosts.sh" do |s|
s.args = ["enp0s8"]
end
end
end
end
And this is the error I am seeing when executing vagrant up
:
TASK [Install extra tools] *****************************************************
fatal: [proxy-node01]: FAILED! => {"cache_update_time": 1596042500, "cache_updated": false, "changed": false, "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\" install 'gnupg2'' failed
: E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)\nE: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?\n", "rc": 100, "stderr": "E: Could not get
lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)\nE: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?\n", "stderr_lines": ["E: Could not get lock /var/lib/dpkg/lock
-frontend - open (11: Resource temporarily unavailable)", "E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?"], "stdout": "", "stdout_lines": []}
I think that something might be running that has not finished executing and this causes a ‘race’ condition.
Just thought i’d ask here, get some extra eyes on it.
Thank you.