controlrepo 2.0.5 → 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -131
- data/controlrepo.gemspec +1 -1
- data/lib/controlrepo.rb +17 -4
- data/lib/controlrepo/rake_tasks.rb +16 -8
- data/lib/controlrepo/testconfig.rb +32 -33
- data/templates/spec_helper.rb.erb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fca8b974111f0429aa19983cbe5ec16c40949101
|
4
|
+
data.tar.gz: 9e13273d647f71d693933c8ec1271281e9cfdeb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8ce767884b96072657755a95cdd97da34abb221719f33b1f234bde60bedf4c956ae926ec0503582beea7e91e0c982452377287855d3c588d25713fe5da687bc
|
7
|
+
data.tar.gz: a0c4c56281e7e6d948e58ecb7ffc885c370d9bc88edbd203e71c93efbcdac8ca67a53ed3f66adb91dfaa0029f5e2f1de462cc6c4486dd2289bb573b9ef2780c9
|
data/README.md
CHANGED
@@ -84,9 +84,9 @@ This gem can just be installed using `gem install` however I would recommend usi
|
|
84
84
|
|
85
85
|
## Config Files
|
86
86
|
|
87
|
-
This project uses one main config file to determine what classes we should be testing and how, this is [controlrepo.yaml](#controlrepo.yaml). The `controlrepo.yaml` config file provides information about what classes to test when, however it needs more information than that:
|
87
|
+
This project uses one main config file to determine what classes we should be testing and how, this is [controlrepo.yaml](#controlrepo.yaml). The `controlrepo.yaml` config file provides information about what classes to test when, however it needs more information than that:
|
88
88
|
|
89
|
-
If we are doing spec testing we need sets of facts to compile the puppet code against, these are stored in [factsets](#factsets).
|
89
|
+
If we are doing spec testing we need sets of facts to compile the puppet code against, these are stored in [factsets](#factsets).
|
90
90
|
|
91
91
|
If we are doing acceptance testing then we need information about how to spin up VMs to do the testing on, these are configured in [nodesets](#nodesets).
|
92
92
|
|
@@ -94,7 +94,7 @@ There is one thing that is not configured using config files and that is the **e
|
|
94
94
|
|
95
95
|
`CONTROLREPO_env=development bundle exec rake controlrepo_spec`
|
96
96
|
|
97
|
-
### controlrepo.yaml
|
97
|
+
### controlrepo.yaml
|
98
98
|
|
99
99
|
`spec/controlrepo.yaml`
|
100
100
|
|
@@ -118,7 +118,7 @@ Hopefully this config file will be fairly self explanatory once you see it, but
|
|
118
118
|
{valid_option}: {value} # Check the doco for available options
|
119
119
|
```
|
120
120
|
|
121
|
-
Why an array of hashes? Well, that is so that we can refer to the same node or node group twice, which we may want/need to do. In the example below we have not referred to the same group twice but we have referred to `centos6a` and `centos7b` in all of out tests as they are in `all_nodes`, `non_windows_servers` and `centos_severs`. However we have left the more specific references to last. This is because entries in the test_matrix will override entries above them if applicable. Meaning that we are still only testing each class on the two centos servers once (Because the gem does de-duplication before running the tests), but also making sure we run `roles::frontend_webserver` twice before checking for idempotency.
|
121
|
+
Why an array of hashes? Well, that is so that we can refer to the same node or node group twice, which we may want/need to do. In the example below we have not referred to the same group twice but we have referred to `centos6a` and `centos7b` in all of out tests as they are in `all_nodes`, `non_windows_servers` and `centos_severs`. However we have left the more specific references to last. This is because entries in the test_matrix will override entries above them if applicable. Meaning that we are still only testing each class on the two centos servers once (Because the gem does de-duplication before running the tests), but also making sure we run `roles::frontend_webserver` twice before checking for idempotency.
|
122
122
|
|
123
123
|
A full example:
|
124
124
|
|
@@ -180,6 +180,8 @@ node_groups:
|
|
180
180
|
|
181
181
|
It's important to note that in order to reference a group using the *include/exclude* syntax is has to have been defined already i.e. it has to come above the group that references it (Makes sense right?)
|
182
182
|
|
183
|
+
**NOTE:** You can change where the gem creates it's temporary directory for running the tests by exporting the `CONTROLREPO_temp` environment variable.
|
184
|
+
|
183
185
|
#### Test Options
|
184
186
|
|
185
187
|
**check_idempotency** *Default: true*
|
@@ -321,7 +323,7 @@ This will do the following things:
|
|
321
323
|
## Using workarounds
|
322
324
|
|
323
325
|
There may be situations where you cannot test everything that is in your puppet code, some common reasons for this include:
|
324
|
-
|
326
|
+
|
325
327
|
- Code is destined for a Puppet Master but the VM image is not a Puppet Master which means we can't restart certain services etc.
|
326
328
|
- A file is being pulled from somewhere that is only accessible in production
|
327
329
|
- Something is trying to connect to something else that does not exist
|
@@ -373,122 +375,47 @@ Here we are specifying custom commands to run for starting, stopping and checkin
|
|
373
375
|
|
374
376
|
**NOTE:** If you need to run some pre_conditions during acceptance tests but not spec tests or vice versa you can check the status of the `$controlrepo_accpetance` variable. It will be `true` when run as an acceptance test and `undef` otherwise. If you want to limit pre_conditions to only certain nodes just use conditional logic based on facts like you normally would.
|
375
377
|
|
376
|
-
|
377
|
-
|
378
|
-
I have provided some extra tools to use if you would prefer to write your own tests which I will go over here.
|
379
|
-
|
380
|
-
### Accessing fact sets in a traditional RSpec test
|
381
|
-
|
382
|
-
We can access all of our fact sets using `Controlrepo.facts`. Normally it would be implemented something like this:
|
383
|
-
|
384
|
-
```ruby
|
385
|
-
Controlrepo.facts.each do |facts|
|
386
|
-
context "on #{facts['fqdn']}" do
|
387
|
-
let(:facts) { facts }
|
388
|
-
it { should compile }
|
389
|
-
end
|
390
|
-
end
|
391
|
-
```
|
392
|
-
|
393
|
-
### Accessing Roles in a traditional RSpec test
|
394
|
-
|
395
|
-
This gem allows us to easily and dynamically test all of the roles and profiles in our environment against fact sets from all of the nodes to which they will be applied. All we need to do is create a spec test that calls out to the `Controlrepo` ruby class:
|
378
|
+
### Other Rake tasks
|
396
379
|
|
397
|
-
|
398
|
-
require 'spec_helper'
|
399
|
-
require 'controlrepo'
|
400
|
-
|
401
|
-
Controlrepo.roles.each do |role|
|
402
|
-
describe role do
|
403
|
-
Controlrepo.facts.each do |facts|
|
404
|
-
context "on #{facts['fqdn']}" do
|
405
|
-
let(:facts) { facts }
|
406
|
-
it { should compile }
|
407
|
-
end
|
408
|
-
end
|
409
|
-
end
|
410
|
-
end
|
411
|
-
```
|
412
|
-
|
413
|
-
This will iterate over each role in the controlrepo and test that it compiles with each set of facts.
|
414
|
-
|
415
|
-
The same can also be done with profiles just by using the profiles method instead:
|
380
|
+
I have included a couple of little rake tasks to help get you started with testing your control repos. Set them up by adding this to your `Rakefile`
|
416
381
|
|
417
382
|
```ruby
|
418
|
-
require '
|
419
|
-
require 'controlrepo'
|
420
|
-
|
421
|
-
Controlrepo.profiles.each do |profile|
|
422
|
-
describe profile do
|
423
|
-
Controlrepo.facts.each do |facts|
|
424
|
-
context "on #{facts['fqdn']}" do
|
425
|
-
let(:facts) { facts }
|
426
|
-
it { should compile }
|
427
|
-
end
|
428
|
-
end
|
429
|
-
end
|
430
|
-
end
|
383
|
+
require 'controlrepo/rake_tasks'
|
431
384
|
```
|
432
385
|
|
433
|
-
|
434
|
-
|
435
|
-
Also since the `profiles`, `roles` and `facts` methods simply return arrays, you can iterate over them however you would like i.e. you could write a different set of tests for each profile and then just use the `facts` method to run those tests on every fact set.
|
436
|
-
|
437
|
-
### Filtering
|
438
|
-
|
439
|
-
You can also filter your fact sets based on the value of any fact, including structured facts. (It will drill down into nested hashes and match those too, it's not just a dumb equality match)
|
386
|
+
The tasks are as follows:
|
440
387
|
|
441
|
-
|
388
|
+
#### generate_controlrepo_yaml
|
442
389
|
|
443
|
-
|
444
|
-
require 'spec_helper'
|
445
|
-
require 'controlrepo'
|
446
|
-
|
447
|
-
describe 'profile::windows_appserver' do
|
448
|
-
Controlrepo.facts({
|
449
|
-
'kernel' => 'windows'
|
450
|
-
}).each do |facts|
|
451
|
-
context "on #{facts['fqdn']}" do
|
452
|
-
let(:facts) { facts }
|
453
|
-
it { should compile }
|
454
|
-
end
|
455
|
-
end
|
456
|
-
end
|
457
|
-
```
|
390
|
+
`bundle exec rake generate_controlrepo_yaml`
|
458
391
|
|
459
|
-
|
392
|
+
This will try to generate a `controlrepo.yaml` file, it will:
|
460
393
|
|
461
|
-
|
394
|
+
- Parse your environment.conf to work out where your roles and profiles might live
|
395
|
+
- Find your roles classes and pre-polulate them into the "classes" section
|
396
|
+
- Look though all of the factsets that ship with the gem, and also the ones you have created under `spec/factsets/*.json`
|
397
|
+
- Populate the "nodes" section with all of the factsets it finds
|
398
|
+
- Create node groups of windows and non-windows nodes
|
399
|
+
- Create a basic test_matrix
|
462
400
|
|
463
|
-
```ruby
|
464
|
-
require 'controlrepo'
|
465
401
|
|
466
|
-
|
467
|
-
c.hiera_config = Controlrepo.hiera_config_file
|
468
|
-
end
|
469
|
-
```
|
402
|
+
#### generate_nodesets
|
470
403
|
|
471
|
-
|
404
|
+
`bundle exec rake generate_nodesets`
|
472
405
|
|
473
|
-
|
406
|
+
This task will generate nodeset file required by beaker, based on the factsets that exist in the repository. If you have any fact sets for which puppetlabs has a compatible vagrant box (i.e. centos, debian, ubuntu) it will detect the version specifics and set up the nodeset file, complete with box URL. If it doesn't know how to deal with a fact set it will output a boilerplate nodeset section and comment it out.
|
474
407
|
|
475
|
-
|
476
|
-
repo = Controlrepo.new()
|
477
|
-
repo.role_regex = /.*/ # Tells the class how to find roles, will be applied to repo.classes
|
478
|
-
repo.profile_regex = /.*/ # Tells the class how to find profiles, will be applied to repo.classes
|
479
|
-
```
|
408
|
+
#### controlrepo_temp_create
|
480
409
|
|
481
|
-
|
410
|
+
This will create a directory including the Controlrepo and all required modules where the environment variable `CONTROLREPO_temp` is set to. This is designed to make it easier to rebuild a cache when you are caching the modules on a build server.
|
482
411
|
|
483
|
-
|
412
|
+
#### hiera_setup
|
484
413
|
|
485
|
-
|
414
|
+
`bundle exec rake hiera_setup`
|
486
415
|
|
487
|
-
|
488
|
-
require 'controlrepo/rake_tasks'
|
489
|
-
```
|
416
|
+
Automatically modifies your hiera.yaml to point at the hieradata relative to it's position.
|
490
417
|
|
491
|
-
|
418
|
+
This rake task will look for a hiera.yaml file (Using the same method we use for [this](#using-hiera-data)). It will then look for a hieradata directory in the root for your control repo (needs to match [this](http://rubular.com/?regex=%2Fhiera%28%3F%3A.%2Adata%29%3F%2Fi)). It will then modify the datadirs of any backends it finds in `hiera.yaml` to point at these directories.
|
492
419
|
|
493
420
|
#### generate_fixtures
|
494
421
|
|
@@ -529,32 +456,3 @@ fixtures:
|
|
529
456
|
```
|
530
457
|
|
531
458
|
Notice that the symlinks are not the ones that we provided in `environment.conf`? This is because the rake task will go into each of directories, find the modules and create a symlink for each of them (This is what rspec expects).
|
532
|
-
|
533
|
-
#### generate_controlrepo_yaml
|
534
|
-
|
535
|
-
`bundle exec rake generate_controlrepo_yaml`
|
536
|
-
|
537
|
-
This will try to generate a `controlrepo.yaml` file, it will:
|
538
|
-
|
539
|
-
- Parse your environment.conf to work out where your roles and profiles might live
|
540
|
-
- Find your roles classes and pre-polulate them into the "classes" section
|
541
|
-
- Look though all of the factsets that ship with the gem, and also the ones you have created under `spec/factsets/*.json`
|
542
|
-
- Populate the "nodes" section with all of the factsets it finds
|
543
|
-
- Create node groups of windows and non-windows nodes
|
544
|
-
- Create a basic test_matrix
|
545
|
-
|
546
|
-
|
547
|
-
#### generate_nodesets
|
548
|
-
|
549
|
-
`bundle exec rake generate_nodesets`
|
550
|
-
|
551
|
-
This task will generate nodeset file required by beaker, based on the factsets that exist in the repository. If you have any fact sets for which puppetlabs has a compatible vagrant box (i.e. centos, debian, ubuntu) it will detect the version specifics and set up the nodeset file, complete with box URL. If it doesn't know how to deal with a fact set it will output a boilerplate nodeset section and comment it out.
|
552
|
-
|
553
|
-
#### hiera_setup
|
554
|
-
|
555
|
-
`bundle exec rake hiera_setup`
|
556
|
-
|
557
|
-
Automatically modifies your hiera.yaml to point at the hieradata relative to it's position.
|
558
|
-
|
559
|
-
This rake task will look for a hiera.yaml file (Using the same method we use for [this](#using-hiera-data)). It will then look for a hieradata directory in the root for your control repo (needs to match [this](http://rubular.com/?regex=%2Fhiera%28%3F%3A.%2Adata%29%3F%2Fi)). It will then modify the datadirs of any backends it finds in `hiera.yaml` to point at these directories.
|
560
|
-
|
data/controlrepo.gemspec
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "controlrepo"
|
6
|
-
s.version = "2.0.
|
6
|
+
s.version = "2.0.6"
|
7
7
|
s.authors = ["Dylan Ratcliffe"]
|
8
8
|
s.email = ["dylan.ratcliffe@puppetlabs.com"]
|
9
9
|
s.homepage = "https://github.com/dylanratcliffe/controlrepo_gem"
|
data/lib/controlrepo.rb
CHANGED
@@ -16,10 +16,9 @@ class Controlrepo
|
|
16
16
|
attr_accessor :root
|
17
17
|
attr_accessor :puppetfile
|
18
18
|
attr_accessor :facts_files
|
19
|
+
attr_accessor :environmentpath
|
19
20
|
attr_accessor :role_regex
|
20
21
|
attr_accessor :profile_regex
|
21
|
-
attr_accessor :temp_environmentpath
|
22
|
-
attr_accessor :tempdir
|
23
22
|
attr_accessor :spec_dir
|
24
23
|
attr_accessor :temp_modulepath
|
25
24
|
attr_accessor :nodeset_file
|
@@ -87,6 +86,7 @@ class Controlrepo
|
|
87
86
|
raise e
|
88
87
|
end
|
89
88
|
@root = search_path
|
89
|
+
@environmentpath = 'etc/puppetlabs/code/environments'
|
90
90
|
@puppetfile = File.expand_path('./Puppetfile',@root)
|
91
91
|
@environment_conf = File.expand_path('./environment.conf',@root)
|
92
92
|
@facts_dir = File.expand_path('./spec/factsets',@root)
|
@@ -95,8 +95,7 @@ class Controlrepo
|
|
95
95
|
@nodeset_file = File.expand_path('./spec/acceptance/nodesets/controlrepo-nodes.yml',@root)
|
96
96
|
@role_regex = /role[s]?:{2}/
|
97
97
|
@profile_regex = /profile[s]?:{2}/
|
98
|
-
@
|
99
|
-
@tempdir = nil
|
98
|
+
@tempdir = nil || ENV['CONTROLREPO_temp']
|
100
99
|
$temp_modulepath = nil
|
101
100
|
@manifest = config['manifest'] ? File.expand_path(config['manifest'],@root) : nil
|
102
101
|
end
|
@@ -114,6 +113,20 @@ class Controlrepo
|
|
114
113
|
END
|
115
114
|
end
|
116
115
|
|
116
|
+
def tempdir
|
117
|
+
if ENV['CONTROLREPO_temp'] == ''
|
118
|
+
return nil
|
119
|
+
elsif ENV['CONTROLREPO_temp'] == nil
|
120
|
+
return nil
|
121
|
+
else
|
122
|
+
return File.absolute_path(ENV['CONTROLREPO_temp'])
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def tempdir=(dir)
|
127
|
+
ENV['CONTROLREPO_temp'] = dir
|
128
|
+
end
|
129
|
+
|
117
130
|
def roles
|
118
131
|
classes.keep_if { |c| c =~ @role_regex }
|
119
132
|
end
|
@@ -86,6 +86,13 @@ task :controlrepo_autotest_prep do
|
|
86
86
|
@config.acceptance_tests.each { |test| @config.verify_acceptance_test(@repo,test) }
|
87
87
|
end
|
88
88
|
|
89
|
+
puts Dir["#{@repo.tempdir}/*"]
|
90
|
+
# Only deploy r10k of we don't already have a directory
|
91
|
+
if Dir["#{@repo.tempdir}/*"].empty?
|
92
|
+
# Deploy r10k to a temp dir
|
93
|
+
@config.r10k_deploy_local(@repo)
|
94
|
+
end
|
95
|
+
|
89
96
|
# Deploy r10k to a temp dir
|
90
97
|
@config.r10k_deploy_local(@repo)
|
91
98
|
|
@@ -106,10 +113,13 @@ task :controlrepo_autotest_prep do
|
|
106
113
|
@config.write_spec_helper_acceptance("#{@repo.tempdir}/spec",@repo)
|
107
114
|
|
108
115
|
# Deduplicate and write the tests (Spec and Acceptance)
|
116
|
+
FileUtils.rm_rf("#{@repo.tempdir}/spec/classes")
|
117
|
+
FileUtils.mkdir("#{@repo.tempdir}/spec/classes")
|
109
118
|
Controlrepo::Test.deduplicate(@config.spec_tests).each do |test|
|
110
119
|
@config.write_spec_test("#{@repo.tempdir}/spec/classes",test)
|
111
120
|
end
|
112
121
|
|
122
|
+
FileUtils.rm_rf("#{@repo.tempdir}/spec/acceptance/*")
|
113
123
|
@config.write_acceptance_tests("#{@repo.tempdir}/spec/acceptance",Controlrepo::Test.deduplicate(@config.acceptance_tests))
|
114
124
|
|
115
125
|
# Parse the current hiera config, modify, and write it to the temp dir
|
@@ -118,11 +128,11 @@ task :controlrepo_autotest_prep do
|
|
118
128
|
hiera_config.each do |setting,value|
|
119
129
|
if value.is_a?(Hash)
|
120
130
|
if value.has_key?(:datadir)
|
121
|
-
hiera_config[setting][:datadir] = "#{@repo.
|
131
|
+
hiera_config[setting][:datadir] = "#{@repo.tempdir}/#{@repo.environmentpath}/production/#{value[:datadir]}"
|
122
132
|
end
|
123
133
|
end
|
124
134
|
end
|
125
|
-
File.write("#{@repo.
|
135
|
+
File.write("#{@repo.tempdir}/#{@repo.environmentpath}/production/hiera.yaml",hiera_config.to_yaml)
|
126
136
|
end
|
127
137
|
|
128
138
|
@config.create_fixtures_symlinks(@repo)
|
@@ -154,13 +164,11 @@ task :controlrepo_acceptance => [
|
|
154
164
|
:controlrepo_autotest_acceptance
|
155
165
|
]
|
156
166
|
|
157
|
-
|
158
|
-
|
159
|
-
task :r10k_deploy_local do
|
167
|
+
task :controlrepo_temp_create do
|
160
168
|
require 'controlrepo/testconfig'
|
161
|
-
|
162
|
-
|
163
|
-
|
169
|
+
repo = Controlrepo.new
|
170
|
+
config = Controlrepo::TestConfig.new("#{repo.spec_dir}/controlrepo.yaml")
|
171
|
+
FileUtils.rm_rf(repo.tempdir)
|
164
172
|
# Deploy r10k to a temp dir
|
165
173
|
config.r10k_deploy_local(repo)
|
166
174
|
end
|
@@ -16,7 +16,7 @@ class Controlrepo
|
|
16
16
|
attr_accessor :acceptance_tests
|
17
17
|
attr_accessor :environment
|
18
18
|
|
19
|
-
def initialize(file
|
19
|
+
def initialize(file)
|
20
20
|
begin
|
21
21
|
config = YAML.load(File.read(file))
|
22
22
|
rescue Errno::ENOENT
|
@@ -25,9 +25,6 @@ class Controlrepo
|
|
25
25
|
raise "Could not parse the YAML file, check that it is valid YAML and that the encoding is correct"
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
@environment = environment
|
30
|
-
@environment ||= 'production'
|
31
28
|
@classes = []
|
32
29
|
@nodes = []
|
33
30
|
@node_groups = []
|
@@ -102,37 +99,38 @@ class Controlrepo
|
|
102
99
|
puppetcode.join("\n")
|
103
100
|
end
|
104
101
|
|
105
|
-
def checkout_branch(working_dir, branch)
|
106
|
-
Dir.chdir(working_dir)
|
107
|
-
g = Git.open(working_dir)
|
108
|
-
|
109
|
-
# if we are already on the right branch do nothing
|
110
|
-
if ! g.branch.current == @environment then
|
111
|
-
if g.branches.include? branch
|
112
|
-
g.branch(@environment).checkout
|
113
|
-
else
|
114
|
-
puts "Unable to checkout requested environment #{@environment}: branch not found"
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
102
|
def r10k_deploy_local(repo = Controlrepo.new)
|
120
103
|
require 'controlrepo'
|
121
|
-
|
122
|
-
repo.tempdir
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
#
|
130
|
-
Dir.
|
131
|
-
|
104
|
+
require 'pathname'
|
105
|
+
if repo.tempdir == nil
|
106
|
+
repo.tempdir = Dir.mktmpdir('r10k')
|
107
|
+
else
|
108
|
+
FileUtils.mkdir_p(repo.tempdir)
|
109
|
+
end
|
110
|
+
|
111
|
+
# We need to do the copy to a tempdir then move the tempdir to the
|
112
|
+
# destination
|
113
|
+
temp_controlrepo = Dir.mktmpdir('controlrepo')
|
114
|
+
FileUtils.cp_r(Dir["#{repo.root}/*"], "#{temp_controlrepo}")
|
115
|
+
FileUtils.mkdir_p("#{repo.tempdir}/#{repo.environmentpath}/production")
|
116
|
+
FileUtils.mv(Dir["#{temp_controlrepo}/*"], "#{repo.tempdir}/#{repo.environmentpath}/production",:force => true)
|
117
|
+
FileUtils.rm_rf(temp_controlrepo)
|
118
|
+
|
119
|
+
# Pull the trigger! If it's not already been pulled
|
120
|
+
if repo.tempdir
|
121
|
+
if File.directory?(repo.tempdir)
|
122
|
+
if Dir["#{repo.tempdir}/#{repo.environmentpath}/production/modules/*"].empty?
|
123
|
+
Dir.chdir("#{repo.tempdir}/#{repo.environmentpath}/production") do
|
124
|
+
system("r10k puppetfile install --verbose")
|
125
|
+
end
|
126
|
+
end
|
127
|
+
else
|
128
|
+
raise "#{repo.tempdir} is not a directory"
|
129
|
+
end
|
132
130
|
end
|
133
131
|
|
134
|
-
# Return tempdir for use
|
135
|
-
tempdir
|
132
|
+
# Return repo.tempdir for use
|
133
|
+
repo.tempdir
|
136
134
|
end
|
137
135
|
|
138
136
|
def write_spec_test(location, test)
|
@@ -162,11 +160,11 @@ class Controlrepo
|
|
162
160
|
end
|
163
161
|
|
164
162
|
def write_spec_helper(location, repo)
|
165
|
-
environmentpath = repo.
|
163
|
+
environmentpath = "#{repo.tempdir}/#{repo.environmentpath}"
|
166
164
|
modulepath = repo.config['modulepath']
|
167
165
|
modulepath.delete("$basemodulepath")
|
168
166
|
modulepath.map! do |path|
|
169
|
-
"#{environmentpath}/#{
|
167
|
+
"#{environmentpath}/production/#{path}"
|
170
168
|
end
|
171
169
|
modulepath = modulepath.join(":")
|
172
170
|
repo.temp_modulepath = modulepath
|
@@ -178,6 +176,7 @@ class Controlrepo
|
|
178
176
|
end
|
179
177
|
|
180
178
|
def create_fixtures_symlinks(repo)
|
179
|
+
FileUtils.rm_rf("#{repo.tempdir}/spec/fixtures/modules")
|
181
180
|
FileUtils.mkdir_p("#{repo.tempdir}/spec/fixtures/modules")
|
182
181
|
repo.temp_modulepath.split(':').each do |path|
|
183
182
|
Dir["#{path}/*"].each do |mod|
|
@@ -4,6 +4,6 @@ RSpec.configure do |c|
|
|
4
4
|
c.parser = 'future'
|
5
5
|
c.environmentpath = '<%= environmentpath %>'
|
6
6
|
c.module_path = '<%= modulepath %>'
|
7
|
-
c.hiera_config = '<%= environmentpath
|
7
|
+
c.hiera_config = '<%= environmentpath %>/production/hiera.yaml'
|
8
8
|
c.manifest = '<%= repo.temp_manifest %>'
|
9
9
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: controlrepo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dylan Ratcliffe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|