r10k 1.5.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +15 -0
  2. data/.travis.yml +0 -1
  3. data/CHANGELOG.mkd +63 -0
  4. data/Gemfile +2 -2
  5. data/README.mkd +1 -10
  6. data/doc/dynamic-environments/configuration.mkd +24 -6
  7. data/doc/dynamic-environments/quickstart.mkd +1 -1
  8. data/integration/Gemfile +1 -1
  9. data/integration/configs/pe/centos-5-64mda +25 -0
  10. data/integration/configs/pe/centos-6-64mda +1 -1
  11. data/integration/configs/pe/centos-7-64mda +1 -1
  12. data/integration/configs/pe/debian-6-64mda +1 -1
  13. data/integration/configs/pe/debian-7-64mda +1 -1
  14. data/integration/configs/pe/redhat-6-64mda +1 -1
  15. data/integration/configs/pe/redhat-7-64mda +1 -1
  16. data/integration/configs/pe/sles-11-64mda +1 -1
  17. data/integration/configs/pe/sles-12-64mda +25 -0
  18. data/integration/configs/pe/ubuntu-1004-64mda +1 -1
  19. data/integration/configs/pe/ubuntu-1204-64mda +1 -1
  20. data/integration/configs/pe/ubuntu-1404-64mda +1 -1
  21. data/integration/files/pre-suite/git_config.pp.erb +19 -0
  22. data/integration/pre-suite/01_git_config.rb +5 -17
  23. data/integration/pre-suite/02_pe_r10k.rb +0 -2
  24. data/integration/scripts/README.mkd +86 -0
  25. data/integration/scripts/setup_r10k_env_centos5.sh +23 -0
  26. data/integration/scripts/setup_r10k_env_centos6.sh +23 -0
  27. data/integration/scripts/setup_r10k_env_rhel7.sh +23 -0
  28. data/integration/scripts/setup_r10k_env_sles11.sh +23 -0
  29. data/integration/scripts/setup_r10k_env_sles12.sh +23 -0
  30. data/integration/scripts/setup_r10k_env_ubuntu1004.sh +23 -0
  31. data/integration/scripts/setup_r10k_env_ubuntu1204.sh +23 -0
  32. data/integration/scripts/setup_r10k_env_ubuntu1404.sh +23 -0
  33. data/integration/tests/basic_functionality/negative/neg_invalid_git_provider.rb +44 -0
  34. data/integration/tests/basic_functionality/rugged_git_provider_with_ssh.rb +106 -0
  35. data/integration/tests/basic_functionality/rugged_git_provider_without_ssh.rb +107 -0
  36. data/integration/tests/git_source/git_source_git.rb +1 -1
  37. data/integration/tests/git_source/git_source_ssh.rb +1 -1
  38. data/integration/tests/git_source/negative/neg_git_unauthorized_https.rb +1 -1
  39. data/integration/tests/git_source/negative/neg_git_unauthorized_ssh.rb +1 -1
  40. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_basedir.rb +1 -1
  41. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module.rb +8 -2
  42. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module_ref.rb +1 -1
  43. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_remote.rb +1 -1
  44. data/integration/tests/user_scenario/basic_workflow/negative/neg_branch_name_collision.rb +1 -1
  45. data/integration/tests/user_scenario/basic_workflow/negative/neg_disk_full.rb +5 -1
  46. data/integration/tests/user_scenario/basic_workflow/negative/neg_duplicate_module_names.rb +3 -3
  47. data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_puppet_file.rb +1 -1
  48. data/integration/tests/user_scenario/basic_workflow/negative/neg_read_only.rb +1 -1
  49. data/integration/tests/user_scenario/basic_workflow/single_env_10000_files.rb +4 -0
  50. data/integration/tests/user_scenario/basic_workflow/single_env_large_files.rb +4 -0
  51. data/integration/tests/user_scenario/complex_workflow/multi_env_unamanaged.rb +77 -0
  52. data/integration/tests/user_scenario/complex_workflow/single_env_git_module_update.rb +99 -0
  53. data/lib/r10k/action/deploy/display.rb +0 -1
  54. data/lib/r10k/action/runner.rb +20 -0
  55. data/lib/r10k/cli.rb +0 -3
  56. data/lib/r10k/cli/deploy.rb +0 -3
  57. data/lib/r10k/deployment.rb +1 -7
  58. data/lib/r10k/deployment/config.rb +15 -1
  59. data/lib/r10k/deployment/config/loader.rb +0 -11
  60. data/lib/r10k/environment/git.rb +0 -9
  61. data/lib/r10k/environment/svn.rb +0 -9
  62. data/lib/r10k/errors.rb +0 -3
  63. data/lib/r10k/feature.rb +24 -3
  64. data/lib/r10k/forge/module_release.rb +142 -0
  65. data/lib/r10k/git.rb +32 -11
  66. data/lib/r10k/module/forge.rb +25 -54
  67. data/lib/r10k/module_repository/forge.rb +2 -5
  68. data/lib/r10k/puppetfile.rb +1 -1
  69. data/lib/r10k/util/license.rb +20 -0
  70. data/lib/r10k/version.rb +1 -1
  71. data/lib/shared/puppet_forge/connection.rb +62 -0
  72. data/lib/shared/puppet_forge/error.rb +28 -0
  73. data/lib/shared/puppet_forge/tar.rb +10 -0
  74. data/lib/shared/puppet_forge/tar/mini.rb +81 -0
  75. data/lib/shared/puppet_forge/unpacker.rb +68 -0
  76. data/lib/shared/puppet_forge/v3.rb +13 -0
  77. data/lib/shared/puppet_forge/v3/module.rb +66 -0
  78. data/lib/shared/puppet_forge/v3/module_release.rb +73 -0
  79. data/lib/shared/puppet_forge/version.rb +3 -0
  80. data/r10k.gemspec +2 -2
  81. data/r10k.yaml.example +80 -5
  82. data/spec/spec_helper.rb +0 -12
  83. data/spec/unit/action/runner_spec.rb +53 -0
  84. data/spec/unit/deployment/config/loader_spec.rb +5 -19
  85. data/spec/unit/deployment/config_spec.rb +8 -0
  86. data/spec/unit/deployment_spec.rb +1 -1
  87. data/spec/unit/forge/module_release_spec.rb +130 -0
  88. data/spec/unit/git_spec.rb +5 -5
  89. data/spec/unit/module/forge_spec.rb +66 -116
  90. data/spec/unit/module_repository/forge_spec.rb +35 -5
  91. data/spec/unit/module_spec.rb +10 -10
  92. data/spec/unit/puppet_forge/connection_spec.rb +41 -0
  93. data/spec/unit/puppet_forge/tar/mini_spec.rb +87 -0
  94. data/spec/unit/puppet_forge/tar_spec.rb +9 -0
  95. data/spec/unit/puppet_forge/unpacker_spec.rb +59 -0
  96. data/spec/unit/puppet_forge/v3/module_release_spec.rb +68 -0
  97. data/spec/unit/puppet_forge/v3/module_spec.rb +67 -0
  98. metadata +48 -112
  99. data/lib/r10k/cli/environment.rb +0 -28
  100. data/lib/r10k/cli/environment/deploy.rb +0 -26
  101. data/lib/r10k/cli/environment/list.rb +0 -23
  102. data/lib/r10k/cli/environment/stale.rb +0 -24
  103. data/lib/r10k/cli/module.rb +0 -29
  104. data/lib/r10k/cli/module/deploy.rb +0 -27
  105. data/lib/r10k/cli/module/list.rb +0 -24
  106. data/lib/r10k/cli/synchronize.rb +0 -27
  107. data/lib/r10k/deployment/basedir.rb +0 -4
  108. data/lib/r10k/deployment/environment.rb +0 -20
  109. data/lib/r10k/deployment/source.rb +0 -37
  110. data/lib/r10k/git/commit.rb +0 -22
  111. data/lib/r10k/git/head.rb +0 -36
  112. data/lib/r10k/git/ref.rb +0 -66
  113. data/lib/r10k/git/remote_head.rb +0 -19
  114. data/lib/r10k/git/repository.rb +0 -158
  115. data/lib/r10k/git/tag.rb +0 -29
  116. data/lib/r10k/git/working_dir.rb +0 -186
  117. data/lib/r10k/registry.rb +0 -4
  118. data/lib/r10k/semver.rb +0 -128
  119. data/lib/r10k/task.rb +0 -12
  120. data/lib/r10k/task/deployment.rb +0 -164
  121. data/lib/r10k/task/environment.rb +0 -31
  122. data/lib/r10k/task/module.rb +0 -19
  123. data/lib/r10k/task/puppetfile.rb +0 -102
  124. data/lib/r10k/task_runner.rb +0 -72
  125. data/lib/r10k/util/monkey_patches.rb +0 -11
  126. data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/can_fetch_all_versions_of_a_given_module.yml +0 -187
  127. data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/can_fetch_the_latest_version_of_a_given_module.yml +0 -187
  128. data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/ignores_deleted_releases.yml +0 -190
  129. data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/it_handles_errors_from_forgeapi_puppetlabs_com/raises_an_error_for_a_non-existant_module.yml +0 -34
  130. data/spec/fixtures/vcr/cassettes/R10K_Module_Forge/and_the_expected_version_is_latest/sets_the_expected_version_based_on_the_latest_forge_version.yml +0 -103
  131. data/spec/shared-examples/git-ref.rb +0 -49
  132. data/spec/unit/deployment/environment_spec.rb +0 -25
  133. data/spec/unit/git/commit_spec.rb +0 -34
  134. data/spec/unit/git/head_spec.rb +0 -22
  135. data/spec/unit/git/ref_spec.rb +0 -45
  136. data/spec/unit/git/repository_spec.rb +0 -34
  137. data/spec/unit/git/tag_spec.rb +0 -32
  138. data/spec/unit/git/working_dir_spec.rb +0 -122
  139. data/spec/unit/util/monkey_patches_spec.rb +0 -20
@@ -1,29 +0,0 @@
1
- require 'r10k/git/ref'
2
- require 'r10k/git/repository'
3
-
4
- # tag: A ref under refs/tags/ namespace that points to an object of an
5
- # arbitrary type (typically a tag points to either a tag or a commit object).
6
- # In contrast to a head, a tag is not updated by the commit command. A tag is
7
- # most typically used to mark a particular point in the commit ancestry chain.
8
- #
9
- # @deprecated This has been replaced by the ShellGit provider and the
10
- # StatefulRepository class and will be removed in 2.0.0
11
- #
12
- # @see https://www.kernel.org/pub/software/scm/git/docs/gitglossary.html
13
- # @api private
14
- class R10K::Git::Tag < R10K::Git::Ref
15
-
16
- # @!attribute [r] tag
17
- # @return [String] The git tag
18
- attr_reader :tag
19
- alias :ref :tag
20
-
21
- def initialize(tag, repository = nil)
22
- @tag = tag
23
- @repository = repository
24
- end
25
-
26
- def fetch?
27
- ! resolvable?
28
- end
29
- end
@@ -1,186 +0,0 @@
1
- require 'forwardable'
2
- require 'r10k/git'
3
- require 'r10k/git/cache'
4
-
5
- require 'r10k/git/working_dir'
6
- require 'r10k/git/ref'
7
- require 'r10k/git/tag'
8
- require 'r10k/git/head'
9
- require 'r10k/git/remote_head'
10
- require 'r10k/git/commit'
11
-
12
- # Implements sparse git repositories with shared objects
13
- #
14
- # Working directory instances use the git alternatives object store, so that
15
- # working directories only contain checked out files and all object files are
16
- # shared.
17
- #
18
- # @deprecated This has been replaced by the ShellGit provider and the
19
- # StatefulRepository class and will be removed in 2.0.0
20
- #
21
- # :nocov:
22
- class R10K::Git::WorkingDir < R10K::Git::Repository
23
-
24
- include R10K::Logging
25
-
26
- extend Forwardable
27
-
28
- # @!attribute [r] cache
29
- # @return [R10K::Git::Cache] The object cache backing this working directory
30
- attr_reader :cache
31
-
32
- # @!attribute [r] ref
33
- # @return [R10K::Git::Ref] The git reference to use check out in the given directory
34
- attr_reader :ref
35
-
36
- # @!attribute [r] remote
37
- # @return [String] The actual remote used as an upstream for this module.
38
- attr_reader :remote
39
-
40
- # Create a new shallow git working directory
41
- #
42
- # @param ref [String, R10K::Git::Ref]
43
- # @param remote [String]
44
- # @param basedir [String]
45
- # @param dirname [String]
46
- def initialize(ref, remote, basedir, dirname = nil)
47
-
48
- @remote = remote
49
- @basedir = basedir
50
- @dirname = dirname || ref
51
-
52
- @full_path = File.join(@basedir, @dirname)
53
- @git_dir = File.join(@full_path, '.git')
54
-
55
- @alternates = R10K::Git::Alternates.new(Pathname.new(@git_dir))
56
- @cache = R10K::Git::ShellGit::Cache.generate(@remote)
57
-
58
- if ref.is_a? String
59
- @ref = R10K::Git::Ref.new(ref, self)
60
- else
61
- @ref = ref
62
- @ref.repository = self
63
- end
64
- end
65
-
66
- # Synchronize the local git repository.
67
- def sync
68
- if not cloned?
69
- clone
70
- else
71
- update
72
- end
73
- end
74
-
75
- def update
76
- update_remotes if update_remotes?
77
-
78
- if ref_needs_fetch?
79
- fetch_from_cache
80
- checkout(@ref)
81
- elsif needs_checkout?
82
- checkout(@ref)
83
- end
84
- end
85
-
86
- # Determine if repo has been cloned into a specific dir
87
- #
88
- # @return [true, false] If the repo has already been cloned
89
- def cloned?
90
- File.directory? @git_dir
91
- end
92
- alias :git? :cloned?
93
-
94
- # Does a directory exist where we expect a working dir to be?
95
- # @return [true, false]
96
- def exist?
97
- File.directory? @full_path
98
- end
99
-
100
- # check out the given ref
101
- #
102
- # @param ref [R10K::Git::Ref] The git reference to check out
103
- def checkout(ref)
104
- git ["checkout", "--force", @ref.sha1], :path => @full_path
105
- rescue => e
106
- raise R10K::Git::GitError.wrap(e, "Cannot check out Git ref '#{@ref}'")
107
- end
108
-
109
- # The currently checked out HEAD
110
- #
111
- # @return [R10k::Git::Head]
112
- def current
113
- R10K::Git::Head.new('HEAD', self)
114
- end
115
-
116
- def outdated?
117
- @ref.fetch? or needs_checkout?
118
- end
119
-
120
- # Prefer remote heads from the 'cache' remote over the real remote
121
- def resolve_remote_head(pattern, remote = 'cache')
122
- super(pattern, remote)
123
- end
124
-
125
- private
126
-
127
- # Do we need to fetch additional objects and refs in order to resolve the given ref?
128
- # @return [true, false]
129
- def ref_needs_fetch?
130
- @ref.fetch?
131
- end
132
-
133
- def fetch_from_cache
134
- @cache.sync
135
- fetch('cache')
136
- end
137
-
138
- # Perform a non-bare clone of a git repository.
139
- def clone
140
- @cache.sync
141
-
142
- # We do the clone against the target repo using the `--reference` flag so
143
- # that doing a normal `git pull` on a directory will work.
144
- git ["clone", "--reference", @cache.git_dir, @remote, @full_path]
145
- git ["remote", "add", "cache", @cache.git_dir], :path => @full_path
146
- git ['fetch', 'cache'], :path => @full_path
147
- checkout(@ref)
148
- end
149
-
150
- def needs_fetch?
151
- ref.fetch?
152
- end
153
-
154
- # Does the expected ref match the actual ref?
155
- def needs_checkout?
156
- expected = ref.sha1
157
- actual = rev_parse('HEAD')
158
-
159
- !(expected == actual)
160
- end
161
-
162
- def update_remotes?
163
- real_remotes = remotes
164
-
165
- expected_origin = @remote
166
- expected_cache = @cache.git_dir
167
-
168
- !(expected_origin == real_remotes['origin'] and expected_cache == real_remotes['cache'])
169
- end
170
-
171
- def update_remotes
172
- # todo: remove all existing refs as they may belong to the old remote
173
- git ['remote', 'set-url', 'origin', remote], :path => @full_path
174
- git ['remote', 'set-url', 'cache', @cache.git_dir], :path => @full_path
175
- @alternates << File.join(@cache.git_dir, 'objects')
176
- logger.debug("Removing stale git tags from #{@full_path}")
177
- remove_tags
178
- end
179
-
180
- def remove_tags
181
- tags.each do |tag|
182
- git ['tag', '-d', tag], :path => @full_path
183
- end
184
- end
185
- end
186
- # :nocov:
@@ -1,4 +0,0 @@
1
- require 'r10k/instance_cache'
2
-
3
- # @deprecated
4
- R10K::Registry = R10K::InstanceCache
@@ -1,128 +0,0 @@
1
- # Ripped off from puppetlabs/puppet
2
-
3
- # We need to subclass Numeric to force range comparisons not to try to iterate over SemVer
4
- # and instead use numeric comparisons (eg >, <, >=, <=)
5
- # Ruby 1.8 already did this for all ranges, but Ruby 1.9 changed range include behavior
6
- module R10K
7
- # :nocov:
8
- class SemVer < Numeric
9
- include Comparable
10
-
11
- VERSION = /^v?(\d+)\.(\d+)\.(\d+)(-[0-9A-Za-z-]*|)$/
12
- SIMPLE_RANGE = /^v?(\d+|[xX])(?:\.(\d+|[xX])(?:\.(\d+|[xX]))?)?$/
13
-
14
- def self.valid?(ver)
15
- VERSION =~ ver
16
- end
17
-
18
- def self.find_matching(pattern, versions)
19
- versions.select { |v| v.matched_by?("#{pattern}") }.sort.last
20
- end
21
-
22
- def self.pre(vstring)
23
- vstring =~ /-/ ? vstring : vstring + '-'
24
- end
25
-
26
- def self.[](range)
27
- range.gsub(/([><=])\s+/, '\1').split(/\b\s+(?!-)/).map do |r|
28
- case r
29
- when SemVer::VERSION
30
- SemVer.new(pre(r)) .. SemVer.new(r)
31
- when SemVer::SIMPLE_RANGE
32
- r += ".0" unless SemVer.valid?(r.gsub(/x/i, '0'))
33
- SemVer.new(r.gsub(/x/i, '0'))...SemVer.new(r.gsub(/(\d+)\.x/i) { "#{$1.to_i + 1}.0" } + '-')
34
- when /\s+-\s+/
35
- a, b = r.split(/\s+-\s+/)
36
- SemVer.new(pre(a)) .. SemVer.new(b)
37
- when /^~/
38
- ver = r.sub(/~/, '').split('.').map(&:to_i)
39
- start = (ver + [0] * (3 - ver.length)).join('.')
40
-
41
- ver.pop unless ver.length == 1
42
- ver[-1] = ver.last + 1
43
-
44
- finish = (ver + [0] * (3 - ver.length)).join('.')
45
- SemVer.new(pre(start)) ... SemVer.new(pre(finish))
46
- when /^>=/
47
- ver = r.sub(/^>=/, '')
48
- SemVer.new(pre(ver)) .. SemVer::MAX
49
- when /^<=/
50
- ver = r.sub(/^<=/, '')
51
- SemVer::MIN .. SemVer.new(ver)
52
- when /^>/
53
- if r =~ /-/
54
- ver = [r[1..-1]]
55
- else
56
- ver = r.sub(/^>/, '').split('.').map(&:to_i)
57
- ver[2] = ver.last + 1
58
- end
59
- SemVer.new(ver.join('.') + '-') .. SemVer::MAX
60
- when /^</
61
- ver = r.sub(/^</, '')
62
- SemVer::MIN ... SemVer.new(pre(ver))
63
- else
64
- (1..1)
65
- end
66
- end.inject { |a,e| a & e }
67
- end
68
-
69
- attr_reader :major, :minor, :tiny, :special
70
-
71
- def initialize(ver)
72
- unless SemVer.valid?(ver)
73
- raise ArgumentError.new("Invalid version string '#{ver}'!")
74
- end
75
-
76
- @major, @minor, @tiny, @special = VERSION.match(ver).captures.map do |x|
77
- # Because Kernel#Integer tries to interpret hex and octal strings, which
78
- # we specifically do not want, and which cannot be overridden in 1.8.7.
79
- Float(x).to_i rescue x
80
- end
81
- end
82
-
83
- def <=>(other)
84
- other = SemVer.new("#{other}") unless other.is_a? SemVer
85
- return self.major <=> other.major unless self.major == other.major
86
- return self.minor <=> other.minor unless self.minor == other.minor
87
- return self.tiny <=> other.tiny unless self.tiny == other.tiny
88
-
89
- return 0 if self.special == other.special
90
- return 1 if self.special == ''
91
- return -1 if other.special == ''
92
-
93
- return self.special <=> other.special
94
- end
95
-
96
- def matched_by?(pattern)
97
- # For the time being, this is restricted to exact version matches and
98
- # simple range patterns. In the future, we should implement some or all of
99
- # the comparison operators here:
100
- # https://github.com/isaacs/node-semver/blob/d474801/semver.js#L340
101
-
102
- case pattern
103
- when SIMPLE_RANGE
104
- pattern = SIMPLE_RANGE.match(pattern).captures
105
- pattern[1] = @minor unless pattern[1] && pattern[1] !~ /x/i
106
- pattern[2] = @tiny unless pattern[2] && pattern[2] !~ /x/i
107
- [@major, @minor, @tiny] == pattern.map { |x| x.to_i }
108
- when VERSION
109
- self == SemVer.new(pattern)
110
- else
111
- false
112
- end
113
- end
114
-
115
- def inspect
116
- @vstring || "#{@major}.#{@minor}.#{@tiny}#{@special}"
117
- end
118
- alias :to_s :inspect
119
-
120
- MIN = SemVer.new('0.0.0-')
121
- MIN.instance_variable_set(:@vstring, 'vMIN')
122
-
123
- MAX = SemVer.new('8.0.0')
124
- MAX.instance_variable_set(:@major, (1.0/0)) # => Infinity
125
- MAX.instance_variable_set(:@vstring, 'vMAX')
126
- end
127
- # :nocov:
128
- end
@@ -1,12 +0,0 @@
1
- module R10K
2
- module Task
3
- # @deprecated
4
- class Base
5
- include R10K::Logging
6
-
7
- # @!attribute [r] task_runner
8
- # @return [R10K::TaskRunner] The task runner that's executing this command
9
- attr_accessor :task_runner
10
- end
11
- end
12
- end
@@ -1,164 +0,0 @@
1
- require 'r10k/task'
2
- require 'r10k/task_runner'
3
-
4
- require 'r10k/task/environment'
5
- require 'r10k/task/puppetfile'
6
-
7
- require 'r10k/util/basedir'
8
-
9
- module R10K
10
- module Task
11
- module Deployment
12
-
13
- # @deprecated
14
- module SharedBehaviors
15
-
16
- private
17
-
18
- def active_environments(names)
19
-
20
- active = []
21
-
22
- all_environments = @deployment.environments
23
- if names.empty?
24
- active = all_environments
25
- else
26
- # This has average case O(N^2) but N should remain relatively small, so
27
- # while this should be optimized that optimization can wait a while.
28
- names.each do |env_name|
29
-
30
- # Elsewhere, we sanitise the env.dirname to sub any \W to _
31
- # For this to match here (a single environment deploy where the
32
- # branch name has \W we need to sanitise the branch name to match
33
-
34
- safe_branch_name = env_name.gsub(/\W/,'_')
35
-
36
- matching = all_environments.select do |env|
37
- env.dirname == safe_branch_name
38
- end
39
-
40
- if matching.empty?
41
- logger.warn "Environment #{env_name} not found in any source"
42
- task_runner.succeeded = false
43
- else
44
- active.concat(matching)
45
- end
46
- end
47
- end
48
-
49
- active.reverse
50
- end
51
-
52
- # @param [Array<String>] names The list of environments to deploy.
53
- #
54
- def with_environments(names = [])
55
- active_environments(names).each do |env|
56
- yield env
57
- end
58
- end
59
- end
60
-
61
- # @deprecated
62
- class DeployEnvironments < R10K::Task::Base
63
-
64
- include SharedBehaviors
65
-
66
- # @!attribute environment_names
67
- # @return [Array<String>] A list of environments to deploy, by name.
68
- attr_accessor :environment_names
69
-
70
- # @!attribute update_puppetfile
71
- # @return [TrueClass, FalseClass] Whether to deploy modules in a puppetfile
72
- attr_accessor :update_puppetfile
73
-
74
- def initialize(deployment)
75
- @deployment = deployment
76
- @update_puppetfile = false
77
- @environment_names = []
78
- end
79
-
80
- def call
81
- @deployment.preload!
82
-
83
- with_environments(@environment_names) do |env|
84
- task = R10K::Task::Environment::Deploy.new(env)
85
- task.update_puppetfile = @update_puppetfile
86
- task_runner.insert_task_after(self, task)
87
- end
88
- end
89
- end
90
-
91
- # @deprecated
92
- class DeployModules < R10K::Task::Base
93
-
94
- include SharedBehaviors
95
-
96
- attr_accessor :module_names
97
-
98
- # @!attribute environment_names
99
- # @return [Array<String>] A list of environments to update modules
100
- attr_accessor :environment_names
101
-
102
- def initialize(deployment)
103
- @deployment = deployment
104
- @environment_names = []
105
- end
106
-
107
- def call
108
- with_environments(@environment_names) do |env|
109
- puppetfile = env.puppetfile
110
-
111
- task = R10K::Task::Puppetfile::DeployModules.new(puppetfile)
112
- task.module_names = module_names
113
-
114
- task_runner.insert_task_after(self, task)
115
- end
116
- end
117
- end
118
-
119
- # @deprecated
120
- class PurgeEnvironments < R10K::Task::Base
121
-
122
- def initialize(deployment)
123
- @deployment = deployment
124
- @basedirs = @deployment.sources.map { |x| x.basedir }.uniq
125
- end
126
-
127
- def call
128
- @basedirs.each do |path|
129
- basedir = R10K::Util::Basedir.from_deployment(path, @deployment)
130
- logger.info "Purging stale environments from #{path}"
131
- basedir.purge!
132
- end
133
- end
134
- end
135
-
136
- # @deprecated
137
- class Display < R10K::Task::Base
138
-
139
- attr_accessor :puppetfile
140
-
141
- def initialize(deployment)
142
- @deployment = deployment
143
- end
144
-
145
- def call
146
- @deployment.environments.each do |env|
147
-
148
- puts " - #{env.dirname}"
149
-
150
- if @puppetfile
151
- puppetfile = env.puppetfile
152
- puppetfile.load
153
-
154
- puppetfile.modules.each do |mod|
155
- puts " - #{mod.name} (#{mod.version})"
156
- end
157
- end
158
- end
159
- end
160
- end
161
- end
162
- end
163
- end
164
-