-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(DOC) Fixed controlrepo reference (Fixes #224)
- Loading branch information
Dylan Ratcliffe
committed
Feb 8, 2020
1 parent
55a45d4
commit 799b589
Showing
1,207 changed files
with
70,325 additions
and
1 deletion.
There are no files selected for viewing
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'yaml' | ||
require 'json' | ||
require 'puppet' | ||
|
||
logs = ARGV[-2] # Second last Arg | ||
report = ARGV[-1] # Last arg | ||
|
||
result = {} | ||
|
||
result['logs'] = JSON.load(File.read(logs)) if File.file?(logs) | ||
result['report'] = YAML.load_file(report) if File.file?(report) | ||
|
||
puts result.to_json |
9 changes: 9 additions & 0 deletions
9
spec/fixtures/bolt/.vagrant/puppetlabs/centos-6.6-64-nocm-0/.vagrant/rgloader/loader.rb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This file loads the proper rgloader/loader.rb file that comes packaged | ||
# with Vagrant so that encoded files can properly run with Vagrant. | ||
|
||
if ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"] | ||
require File.expand_path( | ||
"rgloader/loader", ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"]) | ||
else | ||
raise "Encoded files can't be read outside of the Vagrant installer." | ||
end |
7 changes: 7 additions & 0 deletions
7
spec/fixtures/bolt/.vagrant/puppetlabs/centos-6.6-64-nocm-0/Vagrantfile
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Vagrant.configure("2") do |config| | ||
config.vm.box = 'puppetlabs/centos-6.6-64-nocm' | ||
config.vm.boot_timeout = 600 | ||
config.ssh.insert_key = false | ||
|
||
config.vm.synced_folder ".", "/vagrant", disabled: true | ||
end |
11 changes: 11 additions & 0 deletions
11
spec/fixtures/bolt/.vagrant/puppetlabs/centos-6.6-64-nocm-0/ssh-config
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Host default | ||
HostName 127.0.0.1 | ||
User vagrant | ||
Port 2201 | ||
UserKnownHostsFile /dev/null | ||
StrictHostKeyChecking no | ||
PasswordAuthentication no | ||
IdentityFile /Users/dylan/.vagrant.d/insecure_private_key | ||
IdentitiesOnly yes | ||
LogLevel FATAL | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# module name | ||
|
||
## Module development setup | ||
|
||
Install all the require gems to run test code | ||
```shell | ||
bundle install (only need to do once) | ||
|
||
``` | ||
## Running Tests | ||
|
||
### Unit tests | ||
This type of testing is fast and should be the first thing you do before committing your code. Mistakes can be found | ||
in a matter of seconds vs minutes/hours. You can test your logic in a unit test. The downside is you need to learn | ||
how to write unit tests which can take some initial time getting used to. | ||
|
||
```shell | ||
bundle exec rake spec | ||
|
||
``` | ||
|
||
### Integration Testing | ||
This type of testing is somewhat manual and requires the use of vagrant and a test vm that is controlled by vagrant. | ||
You can find the list of available test vms by running `vagrant status` in the root of the module directory. There is | ||
at lot of magic happening in the vagrantfile that makes this easy. Windows support with this module has not been added yet. | ||
|
||
```shell | ||
|
||
$ vagrant status | ||
Current machine states: | ||
|
||
win2012r2 not created (vmware_fusion) | ||
win2008r2 not created (vmware_fusion) | ||
centos6 running (vmware_fusion) | ||
``` | ||
|
||
To run a test first you need to define the test code located in module_root/tests directory. This code is nothing more | ||
than a bunch of puppet code that uses your manifest code. You will be using puppet apply to run this code on the vm. | ||
Have a look inside the tests directory for examples. | ||
|
||
Example test file | ||
``` | ||
include profiles::default_linux | ||
file{'/tmp/test.txt': | ||
ensure => file, | ||
content => 'Hello World' | ||
} | ||
``` | ||
|
||
There are a few ways to run the test code against a test vm, both of which have the same outcome. | ||
|
||
```shell | ||
bundle exec rake spec_prep | ||
VAGRANT_MANIFEST=linux.pp vagrant provision centos6 | ||
``` | ||
|
||
or use the rake command which bundles the two commands together | ||
|
||
```shell | ||
bundle exec rake "vagrant_up[linux.pp,centos6]" | ||
``` | ||
|
||
### Acceptance Tests | ||
Acceptance testing is sorta like combining unit testing and integration testing where it tests the code on real systems | ||
automatically across a wide range of operating systems. This is an advanced topic, so you will want to master unit and | ||
integration testing first before writing acceptance tests. | ||
|
||
```shell | ||
bundle exec rake beaker | ||
|
||
``` | ||
|
||
|
||
## CI config doc | ||
https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/configuration/advanced-configuration.md |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
source "https://rubygems.org" | ||
|
||
group :test do | ||
gem "rake" | ||
gem "puppet", ENV['PUPPET_GEM_VERSION'] || '~> 4.10' | ||
gem "rspec-puppet" | ||
gem "puppetlabs_spec_helper" | ||
gem 'rspec-puppet-utils' | ||
gem "metadata-json-lint" | ||
gem 'puppet-syntax' | ||
gem 'puppet-lint' | ||
gem 'puppet-debugger' | ||
gem 'pry' | ||
end | ||
|
||
# to disable installing the 50+ gems this group contains run : bundle install --without integration | ||
# group :integration do | ||
# gem "beaker" | ||
# gem "beaker-rspec" | ||
# gem "vagrant-wrapper" | ||
# gem 'serverspec' | ||
# end | ||
|
||
group :development do | ||
gem "puppet-blacksmith" | ||
# This gem causes bundler install erorrs | ||
# gem "guard-rake" | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
[](https://travis-ci.org/nwops/puppet-debugger-module) | ||
|
||
# Puppet Debug | ||
This module contains a function called `debug::break()` and is for use with the | ||
[puppet-debugger gem](https://github.com/nwops/puppet-debugger). | ||
|
||
The function is used for starting the puppet debugger from inside the puppet code. | ||
|
||
Why is this important? Puppet code is getting more complex and in order to understand | ||
the code you need to get inside the compiler look around at the variables, scope and | ||
available functions. | ||
|
||
The debugger is extremely helpful in understanding the puppet language and your puppet code. | ||
Think ruby pry but for puppet code. | ||
|
||
The function will inject the scope, node and environment data into the debugger | ||
allowing you to poke around to see variables, functions, facts, classes, and resources defined in the current scope. | ||
|
||
## Requirements | ||
Ensure you have installed the puppet-debugger gem `gem install puppet-debugger` | ||
or place this in your Gemfile `gem 'puppet-debugger', '>= 0.4'` for your puppet module. | ||
|
||
This also requires puppet 3.8+ with future parser enabled. | ||
|
||
You will also want to include this module in your fixtures file if using for rspec-puppet | ||
unit testing. | ||
|
||
``` | ||
debug: | ||
repo: https://github.com/nwops/puppet-debug | ||
``` | ||
|
||
## Usage | ||
**DO NOT RUN THIS ON YOUR PUPPET SERVER OR IN PRODUCTION** | ||
|
||
Planes will fall out of the sky, and kittens will die. Do you really want that? | ||
Although there is a safety mechanism to prevent the this function from being called | ||
under a daemonized puppet run so it is not all that bad. | ||
|
||
In order to start the puppet-debugger from within code just place the `debug::break()` | ||
function inside your manifest code where you want the scope to be injected. | ||
This will automatically call the debugger `whereami` command and show where in the code | ||
the `debug::break()` function was called from. This makes it obvious where in the code | ||
you are evaluating from. This gives you the ability to step through your code. To goto | ||
the next iteration just use the `exit` command and the compiler will continue to compile where it previously left of. | ||
|
||
You can access variables just as you would when writing puppet code. So once inside | ||
the debugger session type `$some_var_name` | ||
|
||
Example: | ||
|
||
```puppet | ||
class debugger::debugger_test( | ||
$var1 = 'value1', | ||
$var2 = ['value1', 'value2', 'value3'] | ||
) | ||
{ | ||
# dummy resources so we can show list of resources | ||
file{'/tmp/test.txt': ensure => present, mode => '0755'} | ||
service{'httpd': ensure => running} | ||
# how to find values with an empheral scope | ||
$var2.each | String $item | { | ||
file{"/tmp/${item}": ensure => present} | ||
debug::break({'run_once' => true}) | ||
} | ||
debug::break({'run_once' => true}) | ||
if $var1 == 'value1' { | ||
debug::break({'run_once' => true}) | ||
} | ||
} | ||
``` | ||
|
||
Example Debugger session when inside the each block. Notice the item variable. | ||
|
||
```ruby | ||
Ruby Version: 2.3.1 | ||
Puppet Version: 4.7.0 | ||
Puppet Debugger Version: 0.4.0 | ||
Created by: NWOps <corey@nwops.io> | ||
Type "exit", "functions", "vars", "krt", "whereami", "facts", "resources", "classes", | ||
"play", "classification", "reset", or "help" for more information. | ||
|
||
8: service{'httpd': ensure => running} | ||
9: | ||
10: # how to find values with an empheral scope | ||
11: $var2.each | String $item | { | ||
12: file{"/tmp/${item}": ensure => present} | ||
=> 13: debug::break({'run_once' => false}) | ||
14: } | ||
15: debug::break({'run_once' => false}) | ||
16: if $var1 == 'value1' { | ||
17: debug::break({'run_once' => false}) | ||
18: } | ||
1:>> $item | ||
=> "value1" | ||
>> | ||
``` | ||
|
||
If using with rspec-puppet, only the facts you define in your test suite will be present in the debugger. | ||
|
||
For more information on how to use the puppet debugger please refer to the [documentation](https://github.com/nwops/puppet-debugger) | ||
|
||
## Troubleshooting | ||
This module and puppet-debugger gem are very new, there will be bugs. Please | ||
file them at [puppet-debugger gem](https://github.com/nwops/puppet-debugger/issues). |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
require 'puppetlabs_spec_helper/rake_tasks' | ||
require 'puppet-lint/tasks/puppet-lint' | ||
require 'puppet-syntax/tasks/puppet-syntax' | ||
|
||
# These two gems aren't always present, for instance | ||
# on Travis with --without development | ||
begin | ||
require 'puppet_blacksmith/rake_tasks' | ||
Blacksmith::RakeTask.new do |t| | ||
t.tag_pattern = "v%s" # Use a custom pattern with git tag. %s is replaced with the version number. | ||
end | ||
rescue LoadError | ||
end | ||
|
||
PuppetLint.configuration.relative = true | ||
PuppetLint.configuration.send("disable_80chars") | ||
PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}" | ||
PuppetLint.configuration.fail_on_warnings = true | ||
|
||
# Forsake support for Puppet 2.6.2 for the benefit of cleaner code. | ||
# http://puppet-lint.com/checks/class_parameter_defaults/ | ||
PuppetLint.configuration.send('disable_class_parameter_defaults') | ||
# http://puppet-lint.com/checks/class_inherits_from_params_class/ | ||
PuppetLint.configuration.send('disable_class_inherits_from_params_class') | ||
|
||
exclude_paths = [ | ||
"pkg/**/*", | ||
"vendor/**/*", | ||
"spec/**/*", | ||
] | ||
PuppetLint.configuration.ignore_paths = exclude_paths | ||
PuppetSyntax.exclude_paths = exclude_paths | ||
|
||
task :metadata do | ||
sh "metadata-json-lint metadata.json" | ||
end | ||
|
||
desc "Run syntax, lint, and spec tests." | ||
task :test => [ | ||
:syntax, | ||
:lint, | ||
:spec, | ||
:metadata, | ||
] | ||
def io_popen(command) | ||
IO.popen(command) do |io| | ||
io.each do |line| | ||
print line | ||
yield line if block_given? | ||
end | ||
end | ||
end | ||
|
||
desc 'Vagrant VM power up and provision' | ||
task :vagrant_up, [:manifest, :hostname] do |t, args| | ||
args.with_defaults(:manifest => 'init.pp', :hostname => '') | ||
Rake::Task['spec_prep'].execute | ||
ENV['VAGRANT_MANIFEST'] = args[:manifest] | ||
provision = false | ||
io_popen("vagrant up #{args[:hostname]}") do |line| | ||
provision = true if line =~ /is already running./ | ||
end | ||
io_popen("vagrant provision #{args[:hostname]}") if provision | ||
end | ||
|
||
# Cleanup vagrant environment | ||
desc 'Vagrant VM shutdown and fixtures cleanup' | ||
task :vagrant_destroy do | ||
Rake::Task['spec_prep'].execute | ||
`vagrant destroy -f` | ||
Rake::Task['spec_clean'].execute | ||
end |
Oops, something went wrong.