I've been away from PHP nearly four years, I've been working in javascript and Node.JS instead. I have a memory of what tools I was comfortable working with.. it's a rusty memory how it all went together. I've followed Traversy's tutorial to get the LAMP box running
and have connected from MySQL WorkBench.
I'd like to use PHPAdmin, How do I add PHPadmin to my bootstrap.sh commands?
Installing phpMyAdmin On Vagrant
I like this version best, cause each domain has it's own /phpadmin, but I don't understand how he is editing the config file from inside bootstrap.sh
A super-simple Vagrant LAMP stack bootstrap (installable with one command)
I tried this one first, but got an error from the first curly brace, saying it didn't recognize the character..
bootstrap.sh
# Use single quotes instead of double quotes to make it work with special-character passwords
PASSWORD='12345678'
PROJECTFOLDER='myproject'
# Update Packages
apt-get update
# Upgrade Packages
apt-get upgrade
# Basic Linux Stuff
apt-get install -y git
# Apache
apt-get install -y apache2
# Enable Apache Mods
a2enmod rewrite
#Add Onrej PPA Repo
apt-add-repository ppa:ondrej/php
apt-get update
# Install PHP
apt-get install -y php7.2
# PHP Apache Mod
apt-get install -y libapache2-mod-php7.2
# Restart Apache
service apache2 restart
# PHP Mods
apt-get install -y php7.2-common
apt-get install -y php7.2-mcrypt
apt-get install -y php7.2-zip
# Set MySQL Pass
debconf-set-selections <<< 'mysql-server mysql-server/root_password password $PASSWORD'
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password $PASSWORD'
# Install MySQL
apt-get install -y mysql-server
# PHP-MYSQL lib
apt-get install -y php7.2-mysql
# Install phpmyadmin
# apt-get install phpmyadmin
# Restart Apache
sudo service apache2 restart
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# Box Settings
config.vm.box = "ubuntu/trusty64"
# Provider Settings
config.vm.provider "virtualbox" do |vb|
vb.memory = 2048
vb.cpus = 4
end
# Network Settings
# config.vm.network "forwarded_port", guest: 80, host: 8080
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
config.vm.network "private_network", ip: "192.168.33.10"
# config.vm.network "public_network"
# Folder Settings
config.vm.synced_folder ".", "/var/www/html", :nfs => { :mount_options => ["dmode=777", "fmode=666"] }
# Provision Settings
# config.vm.provision "shell", inline: <<-SHELL
# apt-get update
# apt-get install -y apache2
# SHELL
config.vm.provision "shell", path: "bootstrap.sh"
end
When I do vagrant up on a new machine it tries do a sudo apt-get update before it runs of the provisioning lines. It appears that the process still exists however.
My Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "scotch/box"
config.vm.box_version = "1.5.0"
config.vm.box_check_update = false
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.hostname = "vagrant"
config.vm.provision "shell", inline: <<-SHELL
apt-get -y install pdftk
SHELL
end
The problem is that some of the APT repos are returning 404's. This is causing output to stderr which appears to be preventing the shell provisioner winds up not running. Doing vagrant halt and then vagrant up a second time seems to do the trick but I'd rather not have to do 3x commands when 1x could be sufficient.
Anyway ideas how to disable this behavior?
Here's the output when I do vagrant up after doing vagrant destroy:
https://pastebin.com/4Hh49J7c
The errors in the logs are due to the vagrant vbguest plugin. This plugin will need to install the guest additions package for virtualbox matching your version and to do so some apt-get update are run.
You can disable this if this is causing issues during the creation of your VM
Vagrant.configure("2") do |config|
config.vbguest.auto_update = false
end
If you later want to align the version between virtualbox and the guest addition (this is recommended) you can run the following command
$ vagrant vbguest install
I am new to docker and vagrant. I installed vmbox and vagrant in my ubuntu 14.04 machine.
I did "git clone https://github.com/dotcloud/docker.git" to get the docker repository. I have also added precise64 from vagrant successfully.
From docker directory i tried "vagrant up". But it told me to do "vagrant init" first. So I did "vagrant init precise64". After doing "vagrant ssh" there is no docker inside the precise64 vm. How can I make sure that docker is installed already in precise64 on startup?
PS: vagrantfile is not allowing " config.vm.provision "docker" "
The following Vagrantfile will get you a VM with docker ready to go:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "phusion/ubuntu-14.04-amd64"
config.vm.hostname = "dockerhost"
config.vm.provision "shell", inline: <<-SCRIPT
curl -sL https://get.docker.io/ | sh
curl -sL https://raw.githubusercontent.com/dotcloud/docker/master/contrib/completion/bash/docker > /etc/bash_completion.d/docker
adduser vagrant docker
SCRIPT
end
EDIT :
Even easier, you can now use Docker Toolbox to get up and running.
You might be using old version of vagrant.
config.vm.provision "docker" work only with vagrant 1.6.5 .
Try upgrading your vagrant to 1.6.5. It will resolve the issue.
Upgrading the Vagrant to 1.6.5 resolves the issue.
I need to distribute a Vagrant file to people who already have Vagrant installed.
What I am not sure about, is whether Vagrant requires a separate installation of Ansible or whether Ansible is automatically installed together with Vagrant.
Ansible must be installed on the machine in addition to Vagrant (and likely Virtualbox).
Stealing from my own project documentation.
Developer installation
Download and install Vagrant
Download and install VirtualBox
Install Ansible
OSX: brew install ansible
Ubuntu (see below)
Ansible from source for Ubuntu:
apt-get update
apt-get install python-pip python-dev git -y
pip install PyYAML jinja2 paramiko
git clone https://github.com/ansible/ansible.git
cd ansible
make install
Notes on Vagrant plus Ansible
Snippets from the Vagrantfile:
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.provider "virtualbox" do |v|
v.memory = 4096 # we're running Java, need more than the 512mb default
v.customize ["modifyvm", :id, "--vram", "10"] # no graphics used.
end
config.vm.provision "ansible" do |ansible|
ansible.playbook = "../provisioning/vagrant.yml"
ansible.inventory_path = "../provisioning/hosts.ini"
ansible.limit = "vagrant"
We use the following for a vagrant-inventory.ini:
[vagrant]
192.168.111.222
And the vagrant.yml:
- hosts: vagrant
sudo: yes
pre_tasks:
(early init tasks here)
roles:
- role1
- role2
Hope this helps.
I have this in my Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.provision "puppet"
end
Yet, when I run puppet --version I get :
[vagrant#vagrant-centos65 ~]$ puppet --version
-bash: puppet: command not found
Do I need to manually install puppet?
No, (at the moment) Vagrant doesn't install it automatically.
So you either need to use a basebox which already has it installed (Puppet Labs provides boxes too), or you need to install it yourself. Probably the easiest way to install is to use shell provisioner before the puppet provisioner(s).
In response to #tmatilai, I created this simple set up:
Vagrantfile:
Vagrant.configure(2) do |config|
config.vm.box = "centos6.5_64"
config.vm.provision "shell", path: "manifests/puppet.sh"
config.vm.provision "puppet"
end
manifest/puppet.sh:
echo "Adding puppet repo"
sudo rpm -ivh https://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-7.noarch.rpm
echo "installing puppet"
sudo yum install puppet -y
echo "ensure puppet service is running"
sudo puppet resource service puppet ensure=running enable=true
#echo "ensure puppet service is running"
#sudo puppet resource service puppetmaster ensure=running enable=true
echo "ensure puppet service is running for standalone install"
sudo puppet resource cron puppet-apply ensure=present user=root minute=30 command='/usr/bin/puppet apply $(puppet apply --configprint manifest)'
[vagrant#vagrant-centos65 home]$ puppet --version
3.4.2
If you want to use a plugin, I made one that will automatically install Puppet from a version given in the Vagrantfile:
Vagrant.configure("2") do |config|
config.puppet_install.puppet_version = :latest
end
This will also do a few cool tricks like make sure the puppet version you specify is a valid version and the like, full details here: https://github.com/petems/vagrant-puppet-install/
Yes. I'm not sure what the state of Vagrant was at the time of some of these other answers, but these days puppet does not have to be installed via a shell provisioner, as Vagrant has a support puppet provisioner built right in.
At the most basic level, you can make sure puppet is supported on your box by adding provision "puppet" or provision "puppet_server" to your `Vagrantfile. For example:
#open config block (already present in your templated Vagrantfile)
Vagrant.configure(2) do |config|
#...[snip]... other config.vm settings. Ex...
# Ubuntu 14.04 LTS version
#config.vm.box = "ubuntu/trusty64"
# Make puppet avail inside machine
config.vm.provision "puppet"
#close out Vagrant configuration for this instance
end
using puppet sets up puppet for local puppet apply (uses local manifests for configuring your machine), whereas using puppet_server hooks you up to a puppet master, and allows you to provision your vagrant box using a puppet server (a puppet master agent).
As a few other people have already answered, there is no 'standard' that ensures a vagrant box comes pre-installed with Puppet.
By design, a vagrant box could have 'anything' pre-installed on it. Or it could just as easily have 'nothing' at all pre-installed. It all depends on who created it and what they included in the process of setting up the box.
If you find that your machine doesn't have Puppet pre-installed on it, you could also use one of the scripts that Mitchell Hashimoto has put together. See the following project on GitHub for details...
https://github.com/hashicorp/puppet-bootstrap
At this point of time of writing, Vagrant does pre-installs puppet service. I ssh-ed into guest machine (used the box 'ubuntu/trusty64') and got following result :
vagrant#vagrant-ubuntu-trusty-64:~$ puppet --version
3.4.3
As stated by others it depends on the box. For instance ubuntu/trusty64 comes with puppet pre-installed whereas ubuntu/xenial64 does not.
So to fix this for Ubuntu ubuntu/xenial64 adding an inline shell provisioner before the puppet provisioner is enough:
config.vm.box = "ubuntu/xenial64"
config.vm.provision :shell, :inline => 'apt-get -y update; apt-get -y install puppet'
config.vm.provision :puppet do |puppet|
# ...
As of June 16 2016 Vagrant does NOT install puppet within the client VM as far as I can tell. I believe like it's sister project "packer" it expects you to do so explicitly. See: https://www.packer.io/docs/provisioners/puppet-masterless.html
Note: Puppet will not be installed automatically by this provisioner.
This provisioner expects that Puppet is already installed on the
machine. It is common practice to use the shell provisioner before the
Puppet provisioner to do this.
this worked for me:
put this inside your Vagrantfile - before your provisioning
$script = <<SCRIPT
echo I am installing puppet on guest
sudo apt-get install -yq puppet=*
SCRIPT
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: $script
end
This should install a puppet agent on the guest before you do other provisioning