Skip to content
This repository was archived by the owner on Mar 28, 2019. It is now read-only.

Commit 19a400c

Browse files
author
Zach Leslie
committed
Merge pull request #103 from danieldreier/add_vagrantfile
Add Vagrantfile, improve CONTRIBUTING.md
2 parents df5ba6e + 175144b commit 19a400c

File tree

2 files changed

+122
-4
lines changed

2 files changed

+122
-4
lines changed

CONTRIBUTING.md

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,67 @@ Testing
33

44
Tests on the puppet-puppet module can be run via `rake`.
55

6-
Run beaker acceptance tests:
6+
#### Beaker acceptance tests
77
```
8-
BEAKER_destroy=no BEAKER_provision=no rake acceptance
8+
BEAKER_destroy=no BEAKER_provision=onpass rake acceptance
99
```
1010

1111
Run beaker acceptance tests on debian 7:
1212
```
13-
BEAKER_set=debian-73-x64 BEAKER_destroy=no BEAKER_provision=no rake acceptance
13+
BEAKER_set=debian-73-x64 BEAKER_destroy=onpass BEAKER_provision=no rake acceptance
1414
```
1515
See spec/acceptance/nodesets for a list of possible node names; use the filename without .yml.
1616

17-
Run rspec-puppet tests:
17+
If a beaker test fails, you can SSH into the environment if you use BEAKER_PROVISION=onpass.
18+
The path of the vagrantfile will be `.vagrant/beaker_vagrant_files/debian-73-x64.yml`
19+
if you followed the above instructions, and slightly different if you used a
20+
different nodeset. `cd` to that directory and `vagrant ssh` to access the VM.
21+
The tests that ran are in /tmp with randomly generated filenames.
22+
```
23+
24+
#### rspec-puppet tests
1825
(note that these are run automatically by travis CI on pull requests)
1926
```
2027
rake spec
2128
```
2229
30+
Vagrant
31+
=======
32+
33+
This project includes a Vagrantfile to facilitate development. The purpose of
34+
the Vagrantfile is to give you an easy way to interactively edit code and run
35+
tests without polluting your workstation, and without having to worry about
36+
deploying code constantly to test minor changes.
37+
38+
The recommended way to use this for iteratively working out changes is:
39+
```
40+
rm -rf pkg
41+
rake build
42+
vagrant up shared_folder
43+
vagrant ssh shared_folder
44+
```
45+
46+
This will build a new package you could upload to puppetforge in the pkg
47+
directory. Vagrant will use that to install dependencies, but will mount the
48+
repository to /etc/puppet/modules/puppet so your changes take effect
49+
immediately.
50+
51+
A second vagrant environment exists for testing packages prior to puppetforge
52+
release. A typical workflow might be:
53+
```bash
54+
rm -rf pkg
55+
rake build
56+
vagrant up package_install
57+
vagrant ssh package_install
58+
```
59+
60+
Once in one of these systems, the tests in /vagrant/tests may be helpful for
61+
testing during development.
62+
63+
Finally, an agent VM is provided to help test client-server interaction:
64+
65+
```bash
66+
vagrant up agent
67+
vagrant ssh agent
68+
sudo puppet agent --test --waitforcert 10 --server puppet
69+
```

Vagrantfile

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
VAGRANTFILE_API_VERSION = "2"
5+
6+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
7+
### Define options for all VMs ###
8+
# Using vagrant-cachier improves performance if you run repeated yum/apt updates
9+
if defined? VagrantPlugins::Cachier
10+
config.cache.auto_detect = true
11+
end
12+
config.ssh.forward_agent = true
13+
14+
config.vm.provider :virtualbox do |vb|
15+
vb.customize ["modifyvm", :id, "--memory", "512", "--cpus", "4", "--ioapic", "on"]
16+
end
17+
# hack to avoid ubuntu/debian-specific 'stdin: is not a tty' error on startup
18+
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
19+
20+
# distro-agnostic puppet install script from https://github.com/danieldreier/puppet-installer
21+
config.vm.provision "shell", inline: "curl getpuppet.whilefork.com | bash"
22+
23+
PUPPETMASTER_IP = '192.168.37.23'
24+
25+
config.vm.define :package_install do |node|
26+
node.vm.box = 'puppetlabs/debian-7.4-64-nocm'
27+
node.vm.hostname = 'debian7.boxnet'
28+
node.vm.network :private_network, ip: PUPPETMASTER_IP
29+
30+
# hack to avoid ubuntu/debian-specific 'stdin: is not a tty' error on startup
31+
node.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
32+
33+
# distro-agnostic puppet install script from https://github.com/danieldreier/puppet-installer
34+
node.vm.provision "shell", inline: "curl getpuppet.whilefork.com | bash"
35+
36+
# use a packaged version of puppet-puppet to install dependencies via the forge
37+
# rm removes symlink from next step for vagrant provision idempotency
38+
node.vm.provision "shell",
39+
inline: "rm -rf /etc/puppet/modules/puppet"
40+
node.vm.provision "shell",
41+
inline: "if ls /vagrant/pkg/ploperations-puppet-*.tar.gz ; then puppet module install /vagrant/pkg/ploperations-puppet-*.tar.gz; fi"
42+
end
43+
44+
config.vm.define :shared_folder do |node|
45+
node.vm.box = 'puppetlabs/debian-7.4-64-nocm'
46+
node.vm.hostname = 'debian7.boxnet'
47+
node.vm.network :private_network, ip: PUPPETMASTER_IP
48+
49+
# use a packaged version of puppet-puppet to install dependencies via the forge
50+
# rm removes symlink from next step for vagrant provision idempotency
51+
node.vm.provision "shell",
52+
inline: "rm -rf /etc/puppet/modules/puppet"
53+
node.vm.provision "shell",
54+
inline: "if ls /vagrant/pkg/ploperations-puppet-*.tar.gz ; then puppet module install /vagrant/pkg/ploperations-puppet-*.tar.gz; rm -rf /etc/puppet/modules/puppet; fi"
55+
56+
# if this was done as a vagrant shared folder, the previous step either
57+
# wouldn't run or would overwrite files this approach allows using
58+
# puppet's facilities for installing dependencies while also keeping a
59+
# shared folder to simplify development
60+
node.vm.provision "shell",
61+
inline: "ln -s /vagrant /etc/puppet/modules/puppet"
62+
end
63+
64+
config.vm.define :agent do |node|
65+
node.vm.box = 'puppetlabs/debian-7.4-64-nocm'
66+
node.vm.hostname = 'debian7agent.boxnet'
67+
node.vm.network :private_network, ip: "192.168.37.25"
68+
node.vm.provision "shell",
69+
inline: "if ! grep #{PUPPETMASTER_IP} /etc/hosts; then echo '#{PUPPETMASTER_IP} puppet' >> /etc/hosts; fi"
70+
end
71+
end

0 commit comments

Comments
 (0)