Skip to content

Commit 23c71bb

Browse files
remicalixtetruthbk
authored andcommitted
Add vagrant-based testing environment (#462)
* Add vagrant-based testing environment with '#' will be ignored, and an empty message aborts the commit. * Update gitignore * Use versions in Puppetfile * Fix some paths in the readme * improve readme
1 parent 63dc51d commit 23c71bb

5 files changed

Lines changed: 61 additions & 0 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ Gemfile.lock
77

88
.rbenv-gemsets
99
.ruby-version
10+
11+
tests/.vagrant

tests/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Test setup
2+
3+
This is an example setup, based on vagrant + virtualbox, that allows to easily run puppet commands to test the module.
4+
5+
# Requirements
6+
7+
- vagrant > 2.0.0
8+
- virtualbox > 5.1.28
9+
10+
# Setup
11+
12+
in `puppet-datadog-agent/tests`:
13+
14+
- provision VM: `vagrant up`
15+
- connect to the VM to check the configuration: `vagrant ssh`
16+
- destroy VM when needed: `vagrant destroy -f`
17+
18+
## Module installation
19+
20+
- The default `Puppetfile` installs the latest released version of the module from Puppetforge.
21+
- To use your development branch instead edit the Puppetfile et replace the `datadog-datadog_agent` with:
22+
```
23+
mod 'datadog-datadog_agent',
24+
:git => 'https://github.com/DataDog/puppet-datadog-agent',
25+
:branch => '<my_branch>'
26+
```
27+
28+
- We can also build the module locally using the `puppet build` or `pdk build` command, upload the archive to the VM and install it with `sudo /opt/puppetlabs/bin/puppet module install datadog-datadog_agent-x.y.z.tar.gz --target-dir /home/vagrant/puppet/modules`
29+
30+
31+
## Manifest
32+
33+
The default manifest is `tests/environment/manifests/site.pp` and simply run the module with the default options.
34+
We can edit the manifest and run `vagrant up --provision` to upload the new version to the VM.
35+
36+
# Test
37+
38+
In the VM, run `sudo /opt/puppetlabs/bin/puppet apply --modulepath=./modules ./manifests/site.pp` in `/home/vagrant/puppet` to apply to manifest on the VM.

tests/Vagrantfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Vagrant.configure("2") do |config|
2+
config.vm.box = "puppetlabs/ubuntu-16.04-64-puppet"
3+
config.vm.box_version = "1.0.0"
4+
config.vm.provision "file", source: "./environment", destination: "$HOME/puppet"
5+
config.vm.provision "shell", inline: <<-SHELL
6+
/opt/puppetlabs/puppet/bin/gem install r10k -v 2.6.4
7+
cd /home/vagrant/puppet
8+
sudo /opt/puppetlabs/puppet/bin/r10k puppetfile install
9+
SHELL
10+
end

tests/environment/Puppetfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
mod 'datadog-datadog_agent'
2+
mod 'puppetlabs-apt', '2.4.0'
3+
mod 'puppetlabs-concat', '4.0.0'
4+
mod 'puppetlabs-puppetserver_gem', '1.0.0'
5+
mod 'puppetlabs-ruby', '1.0.0'
6+
mod 'puppetlabs-stdlib', '4.24.0'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node "localhost" {
2+
class { "datadog_agent":
3+
api_key => "somenonnullapikeythats32charlong",
4+
}
5+
}

0 commit comments

Comments
 (0)