Skip to content

Commit

Permalink
Merge branch 'release/1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
publysher committed Aug 9, 2013
2 parents 4ac8dc8 + d5c9659 commit 0a7bc39
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea
.vagrant
*.iml

build/
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
BUILDDIR = build
KEYDIR = $(BUILDDIR)/keys

.PHONY: all
all: keys

.PHONY: clean
clean:
@rm -rf $(BUILDDIR)

.PHONY: keys
keys: $(KEYDIR)/master.pub \
$(KEYDIR)/nginx01.intranet.pub


%.pub: %.pem
openssl rsa -in $< -pubout > $@

.PRECIOUS: %.pem
%.pem:
mkdir -p $(dir $@)
openssl genrsa -out $@ 2048
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
infra-example-nginx
===================

Companion repository for my blog post [Infra as a Repo - Using Vagrant and Salt Stack to deploy Nginx on DigitalOcean](http://blog.publysher.nl/2013/07/infra-as-repo-using-vagrant-and-salt.html)
Companion repository for my blog post series [Infra as a Repo](http://blog.publysher.nl/search/label/infra-as-a-repo).

Requirements
------------

* [Vagrant](http://vagrantup.com)
* [vagrant-hostmanager](https://github.com/smdahlen/vagrant-hostmanager)
* [vagrant-digitalocean](https://github.com/smdahlen/vagrant-digitalocean)
* [salty-vagrant](https://github.com/saltstack/salty-vagrant) *from source*

If you want to deploy to a VPS as well, a [Digital Ocean](http://www.digitalocean.com) account is needed as well.

Please note that the latest released vagrant-salt-plugin is terribly outdated. Use the
[Installing from Source](https://github.com/saltstack/salty-vagrant#installing-from-source) instructions to install
salty-vagrant.

Create a local server
---------------------

Expand Down
41 changes: 33 additions & 8 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# A Happy Hack to set hostmanager aliases and override them on a provider-specific basis
def set_host_aliases(node, aliases)
node.hostmanager.aliases = aliases
node.hostmanager.ignore_private_ip = false

node.vm.provider :digital_ocean do |provider, override|
override.hostmanager.aliases = aliases
override.hostmanager.ignore_private_ip = true
end
end


Vagrant.configure("2") do |config|

# Default configuration for Virtualbox
Expand All @@ -10,34 +22,47 @@ Vagrant.configure("2") do |config|
# Create a host-managed private network
config.hostmanager.enabled = false
config.hostmanager.manage_host = false
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true

# VM-specific digital ocean config
config.vm.provider :digital_ocean do |provider, override|
config.vm.provider :digital_ocean do |provider|
provider.image = 'Debian 7.0 x64'
provider.region = 'New York 1'
provider.size = '512MB'

override.hostmanager.ignore_private_ip = true
end

# General provisioning #1: update host file
config.vm.provision :hostmanager

# General provisioning #2: run Salt
config.vm.provision :salt do |salt|
salt.minion_config = 'salt/standalone-minion'
salt.bootstrap_script = 'lib/salt-bootstrap/bootstrap-salt.sh'
salt.run_highstate = true
salt.verbose = true

salt.install_master = true
salt.run_highstate = false

salt.minion_key = 'build/keys/nginx01.intranet.pem'
salt.minion_pub = 'build/keys/nginx01.intranet.pub'

salt.master_key = 'build/keys/master.pem'
salt.master_pub = 'build/keys/master.pub'

salt.seed_master = {
'nginx01.intranet' => 'build/keys/nginx01.intranet.pub'
}
end

# NGINX01 is a web server minion
# NGINX01 is a web server
config.vm.define :nginx01 do |node|

node.vm.hostname = 'nginx01.intranet'
node.vm.network :private_network, ip: '10.1.14.100'
node.vm.synced_folder 'salt/roots/', '/srv/'

set_host_aliases(node, %w(salt salt.intranet))

node.vm.provision :shell, :inline => 'sleep 60; salt-call state.highstate'

end

end
3 changes: 0 additions & 3 deletions salt/standalone-minion

This file was deleted.

0 comments on commit 0a7bc39

Please sign in to comment.