Skip to content

Instantly share code, notes, and snippets.

@v1k0d3n
Created August 29, 2016 18:15
Show Gist options
  • Save v1k0d3n/52d2c2c71400d5f931a8735eb54e91b2 to your computer and use it in GitHub Desktop.
Save v1k0d3n/52d2c2c71400d5f931a8735eb54e91b2 to your computer and use it in GitHub Desktop.
# -*- mode: ruby -*-
# vi: set ft=ruby :
require "yaml"
require "vagrant-openstack-provider"
# Variable defaults (see below for overrides)
$ghost_version = "ubuntu/trusty64"
$ghost_memory = 512
$ghost_vcpus = 1
$ghost_count = 1
# Use a variable file for overrides:
CONFIG = File.expand_path("config.rb")
if File.exist?(CONFIG)
require CONFIG
end
# Force best practices for this environment:
if $ghost_memory < 512
puts "WARNING: Your machine should have at least 512 MB of memory"
end
# Install any Required Plugins
missing_plugins_installed = false
required_plugins = %w(vagrant-env vagrant-openstack-provider)
required_plugins.each do |plugin|
if !Vagrant.has_plugin? plugin
system "vagrant plugin install #{plugin}"
missing_plugins_installed = true
end
end
# If any plugins were missing and have been installed, re-run vagrant
if missing_plugins_installed
exec "vagrant #{ARGV.join(" ")}"
end
# Vagrantfile API/sytax version. Don’t touch unless you know what you’re doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
#vagrant-openstack provider can't live without below line
#config.ssh.username = $ssh_user
#config.ssh.port = $ssh_port
config.ssh.username = "ubuntu"
config.ssh.private_key_path = "~/.ssh/id_rsa"
# Guest Definitions:
# ------------------------
#
# START: ghost Definition(s)
(1..$ghost_count).each do |gc|
config.vm.define vm_name = "ghost#{gc}" do |ghost|
ghost.vm.box = $ghost_version
ghost.vm.hostname = "ghost#{gc}"
# NETWORK-SETTINGS: eth1 configured in the 192.168.236.0/24 network
ghost.vm.network "private_network", ip: "192.168.236.1#{gc}"
ghost.vm.network "forwarded_port", guest: 2368, host: "1236#{gc}", auto_correct: true
# Openstack Provider (Optional --provider=openstack):
ghost.vm.provider "virtualbox" do |vb|
vb.name = "ghost#{gc}"
vb.customize ["modifyvm", :id, "--memory", $ghost_memory]
vb.customize ["modifyvm", :id, "--cpus", $ghost_vcpus]
end
# Openstack Provider (Optional --provider=openstack):
ghost.vm.provider "openstack" do |os|
# Openstack Authentication Information:
os.openstack_auth_url = $os_auth_url
os.username = $os_username
os.password = $os_password
os.tenant_name = $os_tenant
# Openstack Instance Information:
os.server_name = "ghost#{gc}"
os.flavor = $os_flavor
os.image = $os_image
os.floating_ip_pool = $os_floatnet
os.networks = $os_fixednet
os.keypair_name = $os_keypair
os.security_groups = $os_secgroups
end
config.vm.provision :ansible do |ansible|
ansible.playbook = "ghost-install/ghost-install.yml"
config.vm.provision "shell", privileged: false, inline: <<-EOF
echo "Vagrant Box provisioned!"
echo "Ghost Address: http://192.168.236.1#{gc}:2368"
echo "Ghost app_log: /var/log/supervisor/ghost.log"
echo "Ghost err_log: /var/log/supervisor/ghost_err.log"
echo "\n"
echo "NOTICE: If you are using a byob, you may import your backup"
echo "using the ghost importer in the 'Labs' section of the Ghost"
echo "management interface You will likely need to import your"
echo "Blog Logo and Cover pictures again."
EOF
end
end
end
# STOP: ghost Definition(s)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment