Last active
February 7, 2023 15:39
-
-
Save gnarf/b103e77f37236ca72d8e to your computer and use it in GitHub Desktop.
multi-vagrant-ansible-setup
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
:vms: | |
control: | |
:hostname: "vagrant.control.jquery.net" | |
:ip: "33.33.33.10" | |
znc: | |
:hostname: "vagrant.znc.jquery.net" | |
:ip: "33.33.33.11" | |
simple-sites: | |
:hostname: "vagrant.simple-sites.jquery.net" | |
:ip: "33.33.33.12" | |
splunk: | |
:hostname: "vagrant.splunk.jquery.net" | |
:ip: "33.33.33.14" | |
php-sites: | |
:hostname: "vagrant.php-sites.ops.jquery.net" | |
:ip: "33.33.33.13" | |
builder: | |
:hostname: "vagrant.builder.jquery.net" | |
:ip: "172.27.72.28" | |
wp-content: | |
:hostname: "vagrant.wp-content.jquery.net" | |
:ip: "172.27.72.27" | |
:groups: | |
builder: | |
- builder | |
control: | |
- control | |
znc: | |
- znc | |
simple-sites: | |
- simple-sites | |
php-sites: | |
- php-sites | |
wp-content: | |
- wp-content |
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
# this just lets you run playbooks directly on vagrant once you bring a machine up, super useful if you have your | |
# users installed with a sudoers_nopassword group in your deploy_env=vagrant | |
[control] | |
vagrant.control.jquery.net ansible_ssh_host=33.33.33.10 deploy_env=vagrant | |
[php-sites] | |
vagrant.php-sites.jquery.net ansible_ssh_host=33.33.33.13 deploy_env=vagrant | |
[simple-sites] | |
vagrant.simple-sites.jquery.net ansible_ssh_host=33.33.33.12 deploy_env=vagrant | |
[builder] | |
vagrant.builder.jquery.net ansible_ssh_host=172.27.72.28 deploy_env=vagrant | |
[wp-content] | |
vagrant.wp-content.jquery.net ansible_ssh_host=172.27.72.27 deploy_env=vagrant | |
[znc] | |
vagrant.znc.jquery.net ansible_ssh_host=33.33.33.13 deploy_env=vagrant |
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 : | |
require 'yaml' | |
config_yml = YAML.load_file(File.open(File.expand_path(File.dirname(__FILE__)) + "/vagrant-config.yml")) | |
# 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. | |
Vagrant.configure(2) do |config| | |
config_yml[:vms].each do |name, settings| | |
# use the config key as the vm identifier | |
config.vm.define(name) do |vm_config| | |
# Debian 8 (jessie), currently the default case | |
vm_config.vm.box = "ARTACK/debian-jessie" | |
vm_config.vm.box_url = "https://atlas.hashicorp.com/ARTACK/boxes/debian-jessie" | |
# Example of overriding, we don't support wheezy anymore though | |
# if settings[:distro] == "wheezy" | |
# vm_config.vm.box = "jquery-wheezy-amd64" | |
# vm_config.vm.box_url = "http://boxes.jquery.com/jquery-wheezy-amd64.box" | |
# end | |
# NOTE right place to store the project files? Overwrite /etc/puppet? | |
vm_config.vm.synced_folder "./", "/vagrant" | |
# assign an ip address in the hosts network | |
vm_config.vm.network "private_network", ip: settings[:ip] | |
vm_config.vm.hostname = settings[:hostname] | |
config.vm.provider "virtualbox" do |v| | |
# make sure that the name makes sense when seen in the vbox GUI | |
v.name = settings[:hostname] | |
# Be nice to our users. | |
v.customize ["modifyvm", :id, "--cpuexecutioncap", "50"] | |
end | |
vm_config.vm.provision :ansible do |ansible| | |
ansible.playbook = "playbook.yml" | |
ansible.groups = config_yml[:groups] | |
ansible.extra_vars = { | |
deploy_env: "vagrant" | |
} | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment