Why does the provision of a script using Vagrant that contains an apt-get command stalls on Ubuntu-16.04?

خرید بک لینک

Aim

The aim is to install apache on CentOS7 and Ubuntu-16.04 using Vagrant.

Vagrantfile

  config.vm.define "vm_one" do |vm_one|
    vm_one.vm.box = "centos-7.0"
    vm_one.vm.provision "shell", path: "scripts/centos.sh"
  end

  config.vm.define "vm_one_ubuntu" do |vm_one_ubuntu|
    vm_one_ubuntu.vm.box = "ubuntu-16.04"
    vm_one_ubuntu.vm.provision "shell", path: "scripts/ubuntu.sh"
  end

scripts/centos.sh

yum install httpd -y

scripts/ubuntu.sh

apt-get install apache2 -y

Result

  • The provisioning of the script on the CentOS7 box succeeds while the one on ubuntu-16.04 stalls
  • When the apt-get command is removed from the script the script is able to complete
  • When the script stalls and the box is accessed using ssh the apache2 package has been installed
  • Vagrant version: 1.8.4

CentOS7

==> vm_one: Dependency Installed:
==> vm_one:   apr.x86_64 0:1.4.8-3.el7                      apr-util.x86_64 0:1.5.2-6.el7   
==> vm_one:   httpd-tools.x86_64 0:2.4.6-40.el7.centos.1    mailcap.noarch 0:2.1.41-2.el7   
==> vm_one: 
==> vm_one: Complete!

Ubuntu-16.04

==> vm_one_ubuntu: Importing base box 'ubuntu-16.04'...
==> vm_one_ubuntu: Matching MAC address for NAT networking...
==> vm_one_ubuntu: Setting the name of the VM: vagrant_vm_one_ubuntu_1468191900459_75953
==> vm_one_ubuntu: Fixed port collision for 22 => 2222. Now on port 2200.
==> vm_one_ubuntu: Clearing any previously set network interfaces...
==> vm_one_ubuntu: Preparing network interfaces based on configuration...
    vm_one_ubuntu: Adapter 1: nat
    vm_one_ubuntu: Adapter 2: bridged
==> vm_one_ubuntu: Forwarding ports...
    vm_one_ubuntu: 22 (guest) => 2200 (host) (adapter 1)
==> vm_one_ubuntu: Running 'pre-boot' VM customizations...
==> vm_one_ubuntu: Booting VM...
==> vm_one_ubuntu: Waiting for machine to boot. This may take a few minutes...
    vm_one_ubuntu: SSH address: 127.0.0.1:2200
    vm_one_ubuntu: SSH useame: vagrant
    vm_one_ubuntu: SSH auth method: private key
    vm_one_ubuntu: 
    vm_one_ubuntu: Vagrant insecure key detected. Vagrant will automatically replace
    vm_one_ubuntu: this with a newly generated keypair for better security.
    vm_one_ubuntu: 
    vm_one_ubuntu: Inserting generated public key within guest...
    vm_one_ubuntu: Removing insecure key from the guest if it's present...
    vm_one_ubuntu: Key inserted! Disconnecting and reconnecting using new SSH key...
==> vm_one_ubuntu: Machine booted and ready!
==> vm_one_ubuntu: Checking for guest additions in VM...
==> vm_one_ubuntu: Setting hostname...
==> vm_one_ubuntu: Configuring and enabling network interfaces...
==> vm_one_ubuntu: Running provisioner: shell...
    vm_one_ubuntu: Running: /tmp/vagrant-shell20160711-6061-8t7lio.sh

Although the script stalls apache2 has been installed

vagrant@box01-ubuntu:~$ dpkg -l apache2
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  apache2        2.4.18-2ubun amd64        Apache HTTP Server

Attempts to solve the issue

  • Perhaps something is wrong with the apt-get syntax. Changing it to apt-get -y install apache2 as described in this answer did not solve the issue.
  • Perhaps there is a permission issue? sudo apt-get -y install apache2 did not solve the issue either
  • No other solution was found on Google.

- - , .
.

Recent Questions...

ما را در سایت Recent Questions دنبال می‌کنید

برچسب: نویسنده: استخدام کار بازدید: 244 تاريخ: دوشنبه 21 تير 1395 ساعت: 6:33

صفحه بندی