Last active
August 29, 2015 14:01
-
-
Save starise/e90d981b5f9e1e39f632 to your computer and use it in GitHub Desktop.
Windows provisioner for bedrock-ansible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.require_version '>= 1.5.1' | |
Vagrant.configure('2') do |config| | |
config.vm.box = 'roots/bedrock' | |
config.vm.network :private_network, ip: '192.168.50.5' | |
config.vm.hostname = 'example.dev' | |
# adjust paths relative to Vagrantfile | |
config.vm.synced_folder '../example.dev', '/srv/www/example.dev/current', | |
id: 'current', | |
owner: 'vagrant', | |
group: 'www-data', | |
mount_options: ['dmode=776', 'fmode=775'] | |
config.vm.provider "virtualbox" do |vb| | |
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant", "1"] | |
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/current", "1"] | |
end | |
# Check if we are on Windows using rbconfig | |
require 'rbconfig' | |
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) | |
if is_windows | |
# Provisioning configuration for shell script (Windows host) | |
config.vm.provision "shell" do |sh| | |
sh.path = "windows.sh" | |
sh.args = "site.yml hosts" | |
end | |
else | |
# Standard bedrock configuration for Ansible (Mac/Linux host). | |
config.vm.provision :ansible do |ansible| | |
ansible.playbook = './site.yml' | |
ansible.groups = { | |
'wordpress-server' => ['default'] | |
} | |
ansible.extra_vars = { | |
ansible_ssh_user: 'vagrant', | |
user: 'vagrant' | |
} | |
ansible.sudo = true | |
end | |
end | |
if Vagrant.has_plugin?('vagrant-cachier') | |
config.cache.scope = :box | |
config.cache.synced_folder_opts = { | |
type: :nfs, | |
mount_options: ['rw', 'vers=3', 'tcp', 'nolock'] | |
} | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Windows provisioner for bedrock-ansible | |
# based on KSid/windows-vagrant-ansible | |
# @author Andrea Brandi | |
# @version 1.0 | |
ANSIBLE_PLAYBOOK=$1 | |
ANSIBLE_HOSTS=$2 | |
TEMP_HOSTS="/tmp/ansible_hosts" | |
if [ ! -f /vagrant/$ANSIBLE_PLAYBOOK ]; then | |
echo "Ansible playbook not found." | |
exit 1 | |
fi | |
if [ ! -f /vagrant/$ANSIBLE_HOSTS ]; then | |
echo "Ansible hosts not found." | |
exit 2 | |
fi | |
# Create an ssh key if not already created. | |
if [ ! -f ~/.ssh/id_rsa ]; then | |
echo -e "\n\n\n" | ssh-keygen -t rsa | |
fi | |
# Install Ansible and its dependencies if not installed. | |
if [ ! -f /usr/bin/ansible ]; then | |
echo "Adding Ansible repository..." | |
sudo apt-add-repository ppa:rquillo/ansible | |
echo "Updating system..." | |
sudo apt-get -y update | |
echo "Installing Ansible..." | |
sudo apt-get -y install ansible | |
fi | |
cp /vagrant/${ANSIBLE_HOSTS} ${TEMP_HOSTS} && chmod -x ${TEMP_HOSTS} | |
echo "Running Ansible provisioner defined in Vagrantfile..." | |
ansible-playbook /vagrant/${ANSIBLE_PLAYBOOK} --inventory-file=${TEMP_HOSTS} --sudo --user=vagrant --extra-vars "default_ssh_user=vagrant is_windows=true" --connection=local | |
rm ${TEMP_HOSTS} |
Hi, please change:
sh.args = "site.yml hosts"
to
sh.args = "site.yml hosts/development"
in the Vagrantfile, then try again.
The README file here https://github.com/roots/bedrock-ansible says that additions to the default Vagranfile will be needed and it points here https://gist.github.com/starise/e90d981b5f9e1e39f632/a4b7819b3663c5d34e7c8a2ce4556b50771073e8 to get the additions.
Where do I add the additions to the default Vagrantfile?
Updated version for the newer Vagrantfile: https://gist.github.com/swalkinshaw/5266b6869fcbbedf074d
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I run this, I get these errors:
==> default: Mounting shared folders...
default: /vagrant => C:/Users/mero/Dropbox/d6ddev/bedrock-ansible
default: /srv/www/d6d.dev/current => C:/Users/mero/Dropbox/d6ddev/d6d.dev
==> default: Running provisioner: shell...
default: Running: C:/Users/mero/AppData/Local/Temp/vagrant-shell20140919-120
52-ew6ae2.sh
==> default: stdin: is not a tty
==> default: Ansible hosts not found.
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.