r10k 2.3.1 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.mkd +40 -13
  4. data/Gemfile +1 -2
  5. data/README.mkd +25 -0
  6. data/Rakefile +3 -0
  7. data/doc/dynamic-environments/configuration.mkd +91 -14
  8. data/doc/dynamic-environments/workflow-guide.mkd +3 -3
  9. data/doc/puppetfile.mkd +89 -40
  10. data/integration/Gemfile +2 -0
  11. data/integration/Rakefile +41 -0
  12. data/integration/tests/purging/content_not_purged_at_root.rb +89 -0
  13. data/integration/tests/purging/default_purging.rb +125 -0
  14. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module_ref.rb +1 -1
  15. data/lib/r10k.rb +8 -1
  16. data/lib/r10k/action/deploy/deploy_helpers.rb +3 -3
  17. data/lib/r10k/action/deploy/environment.rb +35 -14
  18. data/lib/r10k/action/deploy/module.rb +4 -4
  19. data/lib/r10k/action/puppetfile/check.rb +1 -1
  20. data/lib/r10k/action/puppetfile/install.rb +1 -1
  21. data/lib/r10k/action/runner.rb +3 -3
  22. data/lib/r10k/deployment.rb +8 -4
  23. data/lib/r10k/deployment/config.rb +1 -1
  24. data/lib/r10k/environment/base.rb +32 -3
  25. data/lib/r10k/environment/git.rb +19 -6
  26. data/lib/r10k/feature.rb +6 -6
  27. data/lib/r10k/forge/module_release.rb +4 -6
  28. data/lib/r10k/git.rb +7 -7
  29. data/lib/r10k/git/alternates.rb +1 -1
  30. data/lib/r10k/git/cache.rb +2 -2
  31. data/lib/r10k/git/rugged/bare_repository.rb +29 -9
  32. data/lib/r10k/git/rugged/credentials.rb +8 -8
  33. data/lib/r10k/git/rugged/thin_repository.rb +17 -3
  34. data/lib/r10k/git/rugged/working_repository.rb +12 -5
  35. data/lib/r10k/git/shellgit/thin_repository.rb +5 -1
  36. data/lib/r10k/git/shellgit/working_repository.rb +16 -2
  37. data/lib/r10k/git/stateful_repository.rb +33 -23
  38. data/lib/r10k/initializers.rb +1 -1
  39. data/lib/r10k/keyed_factory.rb +2 -2
  40. data/lib/r10k/logging.rb +1 -1
  41. data/lib/r10k/module.rb +4 -3
  42. data/lib/r10k/module/base.rb +3 -2
  43. data/lib/r10k/module/forge.rb +9 -4
  44. data/lib/r10k/module/git.rb +39 -22
  45. data/lib/r10k/module/local.rb +1 -1
  46. data/lib/r10k/module/metadata_file.rb +1 -1
  47. data/lib/r10k/module/svn.rb +3 -1
  48. data/lib/r10k/puppetfile.rb +72 -11
  49. data/lib/r10k/settings.rb +20 -0
  50. data/lib/r10k/settings/collection.rb +2 -2
  51. data/lib/r10k/settings/container.rb +1 -1
  52. data/lib/r10k/settings/enum_definition.rb +11 -3
  53. data/lib/r10k/settings/helpers.rb +2 -2
  54. data/lib/r10k/settings/list.rb +1 -1
  55. data/lib/r10k/settings/loader.rb +6 -6
  56. data/lib/r10k/settings/uri_definition.rb +1 -1
  57. data/lib/r10k/source/base.rb +2 -2
  58. data/lib/r10k/source/git.rb +4 -4
  59. data/lib/r10k/svn/working_dir.rb +1 -1
  60. data/lib/r10k/util/basedir.rb +9 -9
  61. data/lib/r10k/util/license.rb +3 -3
  62. data/lib/r10k/util/purgeable.rb +50 -24
  63. data/lib/r10k/util/setopts.rb +1 -1
  64. data/lib/r10k/util/subprocess.rb +3 -3
  65. data/lib/r10k/util/symbolize_keys.rb +1 -1
  66. data/lib/r10k/version.rb +1 -1
  67. data/locales/config.yaml +21 -0
  68. data/r10k.gemspec +3 -0
  69. data/spec/fixtures/unit/puppetfile/valid-forge-with-version/Puppetfile +1 -0
  70. data/spec/fixtures/unit/puppetfile/valid-forge-without-version/Puppetfile +1 -0
  71. data/spec/fixtures/unit/util/purgeable/managed_one/expected_1 +0 -0
  72. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_expected_1 +0 -0
  73. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_unmanaged_1 +0 -0
  74. data/spec/fixtures/unit/util/purgeable/managed_one/unmanaged_1 +0 -0
  75. data/spec/fixtures/unit/util/purgeable/managed_two/expected_2 +0 -0
  76. data/spec/fixtures/unit/util/purgeable/managed_two/unmanaged_2 +0 -0
  77. data/spec/integration/git/stateful_repository_spec.rb +39 -21
  78. data/spec/r10k-mocks/mock_config.rb +4 -0
  79. data/spec/spec_helper.rb +3 -0
  80. data/spec/unit/action/deploy/environment_spec.rb +71 -13
  81. data/spec/unit/environment/base_spec.rb +71 -0
  82. data/spec/unit/forge/module_release_spec.rb +7 -10
  83. data/spec/unit/git/stateful_repository_spec.rb +6 -6
  84. data/spec/unit/module/git_spec.rb +156 -5
  85. data/spec/unit/module_spec.rb +3 -3
  86. data/spec/unit/puppetfile_spec.rb +115 -0
  87. data/spec/unit/util/purgeable_spec.rb +230 -0
  88. metadata +45 -18
  89. data/integration/test_run_scripts/README.mkd +0 -5
  90. data/integration/test_run_scripts/all_tests-rugged-pe-centos6.sh +0 -20
  91. data/integration/test_run_scripts/all_tests-rugged-pe-rhel7.sh +0 -20
  92. data/integration/test_run_scripts/all_tests-rugged-pe-sles11.sh +0 -20
  93. data/integration/test_run_scripts/all_tests-rugged-pe-ubuntu1204.sh +0 -20
  94. data/integration/test_run_scripts/all_tests-rugged-pe-ubuntu1404.sh +0 -20
  95. data/integration/test_run_scripts/all_tests-shellgit-pe-centos6.sh +0 -20
  96. data/integration/test_run_scripts/all_tests-shellgit-pe-rhel7.sh +0 -20
  97. data/integration/test_run_scripts/all_tests-shellgit-pe-sles11.sh +0 -20
  98. data/integration/test_run_scripts/all_tests-shellgit-pe-ubuntu1204.sh +0 -20
  99. data/integration/test_run_scripts/all_tests-shellgit-pe-ubuntu1404.sh +0 -20
  100. data/integration/test_run_scripts/basic_functionality/all_tests-pe-centos6.sh +0 -20
  101. data/integration/test_run_scripts/command_line/all_tests-pe-centos6.sh +0 -20
  102. data/integration/test_run_scripts/git_source/all_tests-pe-centos6.sh +0 -20
  103. data/integration/test_run_scripts/user_scenario/basic_workflow/all_tests-pe-centos6.sh +0 -20
  104. data/integration/test_run_scripts/user_scenario/complex_workflow/all_tests-pe-centos6.sh +0 -20
@@ -1,3 +1,5 @@
1
1
  source ENV['GEM_SOURCE'] || 'https://rubygems.org'
2
2
 
3
3
  gem 'beaker', '~> 2.7'
4
+ gem 'rototiller', '= 0.1.0'
5
+ gem 'beaker-hostgenerator', '~> 0.7.0'
@@ -0,0 +1,41 @@
1
+ require 'rototiller'
2
+
3
+ desc 'The acceptance tests for r10k, run in the beaker framework'
4
+ rototiller_task :acceptance => [:beaker_hostgenerator] do |t|
5
+
6
+ flags = [
7
+ {:name => '--hosts', :default => 'configs/generated', :override_env => 'BEAKER_HOST'},
8
+ {:name => '--keyfile', :default => "#{ENV['HOME']}/.ssh/id_rsa-acceptance", :override_env => 'BEAKER_KEYFILE'},
9
+ {:name => '--load-path', :default => 'lib'},
10
+ {:name => '--pre-suite', :default => 'pre-suite'},
11
+ {:name => '--tests', :default => 'tests', :override_env => 'BEAKER_TESTS'},
12
+ {:name => '--preserve-hosts', :default => 'onfail', :override_env => 'BEAKER_PRESERVE_HOSTS'},
13
+ ]
14
+ t.add_flag(*flags)
15
+
16
+ t.add_env do |env|
17
+ env.name = 'BEAKER_PE_DIR'
18
+ env.message = 'The location to download PE from example "http://neptune.puppetlabs.lan/2016.2/ci-ready"'
19
+ end
20
+
21
+ t.add_env do |env|
22
+ env.name = 'GIT_PROVIDER'
23
+ env.message = 'The git provider that r10k should use on a SUT'
24
+ end
25
+
26
+ t.add_command({:name => 'beaker --debug', :override_env => 'BEAKER_EXECUTABLE'})
27
+ end
28
+
29
+ desc 'Generate a host configuration used by Beaker'
30
+ rototiller_task :beaker_hostgenerator do |t|
31
+
32
+ t.add_command do |c|
33
+ c.name = 'beaker-hostgenerator'
34
+ c.argument = '> configs/generated'
35
+ end
36
+
37
+ #this is a hack :(
38
+ t.add_flag(:name => '', :default => 'centos6-64mdca-64.fa', :override_env => 'TEST_TARGET')
39
+
40
+ t.add_flag(:name => '--global-config', :default => '{forge_host=forge-aio01-petest.puppetlabs.com}', :override_env => 'BHG_GLOBAL_CONFIG')
41
+ end
@@ -0,0 +1,89 @@
1
+ require 'git_utils'
2
+ require 'r10k_utils'
3
+ require 'master_manipulator'
4
+ test_name 'RK-256 - C98049 - verify if non-module content is at root of dir, does not cause erroneous purging'
5
+
6
+ #Init
7
+ env_path = on(master, puppet('config print environmentpath')).stdout.rstrip
8
+ r10k_fqp = get_r10k_fqp(master)
9
+ git_environments_path = '/root/environments'
10
+ git_repo_path = '/git_repos'
11
+ git_repo_name = 'environments'
12
+ git_control_remote = File.join(git_repo_path, "#{git_repo_name}.git")
13
+ code_dir = '/etc/puppetlabs/code/environments/production'
14
+
15
+ last_commit = git_last_commit(master, git_environments_path)
16
+ git_provider = ENV['GIT_PROVIDER']
17
+ r10k_config_path = get_r10k_config_file_path(master)
18
+ r10k_config_bak_path = "#{r10k_config_path}.bak"
19
+ #In-line files
20
+ r10k_conf = <<-CONF
21
+ cachedir: '/var/cache/r10k'
22
+ git:
23
+ provider: '#{git_provider}'
24
+ sources:
25
+ control:
26
+ basedir: "#{env_path}"
27
+ remote: "#{git_control_remote}"
28
+ CONF
29
+
30
+ puppetfile = <<-EOS
31
+ mod 'non_module_object_1',
32
+ :install_path => './',
33
+ :git => 'https://github.com/puppetlabs/control-repo.git',
34
+ :branch => 'production'
35
+
36
+ mod 'non_module_object_2',
37
+ :install_path => '',
38
+ :git => 'https://github.com/puppetlabs/control-repo.git',
39
+ :branch => 'production'
40
+ EOS
41
+
42
+ puppetfile_2 = <<-EOS
43
+ mod 'puppetlabs-motd'
44
+ EOS
45
+
46
+ teardown do
47
+ step 'Restore Original "r10k" Config'
48
+ on(master, "mv #{r10k_config_bak_path} #{r10k_config_path}")
49
+
50
+ clean_up_r10k(master, last_commit, git_environments_path)
51
+ end
52
+
53
+ step 'Stub the forge'
54
+ stub_forge_on(master)
55
+
56
+ step 'Backup Current "r10k" Config'
57
+ on(master, "mv #{r10k_config_path} #{r10k_config_bak_path}")
58
+
59
+ step 'Update the "r10k" Config'
60
+ create_remote_file(master, r10k_config_path, r10k_conf)
61
+
62
+ step 'Ask r10k to deploy'
63
+ on(master, "#{r10k_fqp} deploy environment -p")
64
+
65
+ step 'Add puppetfile with non-module content at top of directory'
66
+ create_remote_file(master, "#{git_environments_path}/Puppetfile", puppetfile)
67
+ git_add_commit_push(master, 'production', 'add Puppetfile', git_environments_path)
68
+
69
+ step 'Deploy r10k'
70
+ on(master, "#{r10k_fqp} deploy environment -p")
71
+
72
+ step 'Add puppetfile #2'
73
+ create_remote_file(master, "#{git_environments_path}/Puppetfile", puppetfile_2)
74
+ git_add_commit_push(master, 'production', 'add Puppetfile to production', git_environments_path)
75
+
76
+ step 'Deploy r10k after adding puppetfile #2'
77
+ on(master, "#{r10k_fqp} deploy environment -p")
78
+
79
+ step 'Verify that non-module object 1 has not been purged'
80
+ on(master, "test -d #{code_dir}/non_module_object_1", :accept_all_exit_codes => true) do |result|
81
+ non_module_error = 'Non-module object was purged; should have been left alone'
82
+ assert(result.exit_code == 0, non_module_error)
83
+ end
84
+
85
+ step 'Verify that non-module object 2 has not been purged'
86
+ on(master, "test -d #{code_dir}/non_module_object_2", :accept_all_exit_codes => true) do |result|
87
+ non_module_error = 'Non-module object was purged; should have been left alone'
88
+ assert(result.exit_code == 0, non_module_error)
89
+ end
@@ -0,0 +1,125 @@
1
+ require 'git_utils'
2
+ require 'r10k_utils'
3
+ require 'master_manipulator'
4
+ test_name 'RK-256 - C98013 - verify default purging behavior'
5
+
6
+ #Init
7
+ env_path = on(master, puppet('config print environmentpath')).stdout.rstrip
8
+ r10k_fqp = get_r10k_fqp(master)
9
+ git_environments_path = '/root/environments'
10
+ git_repo_path = '/git_repos'
11
+ git_repo_name = 'environments'
12
+ git_control_remote = File.join(git_repo_path, "#{git_repo_name}.git")
13
+
14
+ last_commit = git_last_commit(master, git_environments_path)
15
+ git_provider = ENV['GIT_PROVIDER']
16
+ r10k_config_path = get_r10k_config_file_path(master)
17
+ r10k_config_bak_path = "#{r10k_config_path}.bak"
18
+ #In-line files
19
+ r10k_conf = <<-CONF
20
+ cachedir: '/var/cache/r10k'
21
+ git:
22
+ provider: '#{git_provider}'
23
+ sources:
24
+ control:
25
+ basedir: "#{env_path}"
26
+ remote: "#{git_control_remote}"
27
+ CONF
28
+
29
+ teardown do
30
+ step 'Restore Original "r10k" Config'
31
+ on(master, "mv #{r10k_config_bak_path} #{r10k_config_path}")
32
+
33
+ clean_up_r10k(master, last_commit, git_environments_path)
34
+ end
35
+
36
+ # initialize path name a....d (where it is)
37
+ code_dir_path = '/etc/puppetlabs/code'
38
+ fake_environment_path_a = [code_dir_path, 'environments'].join('/')
39
+ fake_environment_path_b = [code_dir_path,'environments', 'production'].join('/')
40
+ fake_environment_path_c = [code_dir_path, 'environments', 'production', 'modules'].join('/')
41
+ fake_environment_path_d = [code_dir_path, 'environments', 'production', 'modules', 'motd'].join('/') #not sure if need
42
+
43
+ # initalize directory name a...c (where it is, what it is called)
44
+ fake_dir_a_to_be_purged = "#{fake_environment_path_a}/fakedir1"
45
+ fake_dir_b_to_be_left_alone = "#{fake_environment_path_b}/fakedir2"
46
+ fake_dir_c_to_be_purged = "#{fake_environment_path_c}/fakedir3"
47
+
48
+ # initalize file name a...c (where it is, what it is called)
49
+ fake_file_a_to_be_purged = "#{fake_environment_path_a}/fakefile1.txt"
50
+ fake_file_b_to_be_left_alone = "#{fake_environment_path_b}/fakefile2.txt"
51
+ fake_file_c_to_be_purged = "#{fake_environment_path_c}/fakefile3.txt"
52
+
53
+ # initalize file content
54
+ step 'Stub the forge'
55
+ stub_forge_on(master)
56
+
57
+ step 'Backup Current "r10k" Config'
58
+ on(master, "mv #{r10k_config_path} #{r10k_config_bak_path}")
59
+
60
+ step 'Update the "r10k" Config'
61
+ create_remote_file(master, r10k_config_path, r10k_conf)
62
+
63
+ step 'Create content to be managed by r10k'
64
+ git_on(master, 'checkout production', git_environments_path)
65
+ create_remote_file(master, "#{git_environments_path}/Puppetfile", 'mod "puppetlabs-motd"')
66
+ git_add_commit_push(master, 'production', 'add Puppetfile to production', git_environments_path)
67
+
68
+ git_on(master, 'checkout production', git_environments_path)
69
+ git_on(master, 'checkout -b cats', git_environments_path)
70
+ create_remote_file(master, "#{git_environments_path}/Puppetfile", 'mod "puppetlabs-inifile"')
71
+ git_add_commit_push(master, 'cats', 'add Puppetfile to cats', git_environments_path)
72
+
73
+ step 'Ask r10k to deploy'
74
+ on(master, "#{r10k_fqp} deploy environment -p")
75
+
76
+ step 'Create fake file and directory at deployment level to be purged'
77
+ create_remote_file(master, fake_file_a_to_be_purged, "foobar nonsense")
78
+ on(master, "mkdir #{fake_dir_a_to_be_purged}")
79
+
80
+ step 'Create fake file and directory at environment level to be left alone'
81
+ create_remote_file(master, fake_file_b_to_be_left_alone, "foobar nonsense")
82
+ on(master, "mkdir #{fake_dir_b_to_be_left_alone}")
83
+
84
+ step 'Create fake file and directory at puppetfile level to be purged '
85
+ create_remote_file(master, fake_file_c_to_be_purged, "foobar nonsense")
86
+ on(master, "mkdir #{fake_dir_c_to_be_purged}")
87
+
88
+ step('Deploy r10k')
89
+ on(master, "#{r10k_fqp} deploy environment -p")
90
+
91
+ step('Assert to see if deployment level file is not there')
92
+ on(master, "test -f #{fake_file_a_to_be_purged}", :accept_all_exit_codes => true) do |result|
93
+ file_a_error = 'Puppet file purging was not observed'
94
+ assert(result.exit_code == 1, file_a_error)
95
+ end
96
+
97
+ step('Assert to see if deployment level directory is not there')
98
+ on(master, "test -d #{fake_dir_a_to_be_purged}", :accept_all_exit_codes => true) do |result|
99
+ dir_a_error = 'Puppet directory purging was not observed'
100
+ assert(result.exit_code == 1, dir_a_error)
101
+ end
102
+
103
+ step('Assert to see if environment level file is still there after second deployment')
104
+ on(master, "test -f #{fake_file_b_to_be_left_alone}", :accept_all_exit_codes => true) do |result|
105
+ file_b_error = 'Puppet file purging deleted this file when it should have left it alone :('
106
+ assert(result.exit_code == 0, file_b_error)
107
+ end
108
+
109
+ step('Assert to see if environment level directory is still there after second deployment')
110
+ on(master, "test -d #{fake_dir_b_to_be_left_alone}", :accept_all_exit_codes => true) do |result|
111
+ dir_b_error = 'Puppet directory purging deleted this directory when it should have left it alone :('
112
+ assert(result.exit_code == 0, dir_b_error)
113
+ end
114
+
115
+ step('Assert to see if puppetfile level file is not there')
116
+ on(master, "test -f #{fake_file_c_to_be_purged}", :accept_all_exit_codes => true) do |result|
117
+ file_c_error = 'Puppet file purging was not observed'
118
+ assert(result.exit_code == 1, file_c_error)
119
+ end
120
+
121
+ step('Assert to see if puppetfile level directory is not there')
122
+ on(master, "test -d #{fake_dir_c_to_be_purged}", :accept_all_exit_codes => true) do |result|
123
+ dir_c_error = 'Puppet directory purging was not observed'
124
+ assert(result.exit_code == 1, dir_c_error)
125
+ end
@@ -19,7 +19,7 @@ PUPPETFILE
19
19
  puppet_file_path = File.join(git_environments_path, 'Puppetfile')
20
20
 
21
21
  #Verification
22
- error_message_regex = /ERROR.*Unable to sync repo to unresolvable ref/
22
+ error_message_regex = /ERROR.*Could not resolve desired ref/
23
23
 
24
24
  #Teardown
25
25
  teardown do
@@ -1,4 +1,11 @@
1
- module R10K; end
1
+ require 'gettext-setup'
2
+
3
+ module R10K
4
+ GettextSetup.initialize(File.absolute_path('../locales', File.dirname(__FILE__)))
5
+
6
+ # Attempt to set the R10k error and log message locale
7
+ FastGettext.locale = ENV["LANG"]
8
+ end
2
9
 
3
10
  require 'r10k/version'
4
11
  require 'r10k/logging'
@@ -9,7 +9,7 @@ module R10K
9
9
  # @raise [SystemExit] If no config file was loaded
10
10
  def expect_config!
11
11
  if @config.nil?
12
- logger.fatal("No configuration file given, no config file found in current directory, and no global config present")
12
+ logger.fatal(_("No configuration file given, no config file found in current directory, and no global config present"))
13
13
  exit(8)
14
14
  end
15
15
  end
@@ -23,8 +23,8 @@ module R10K
23
23
  def check_write_lock!(config)
24
24
  write_lock = config.fetch(:deploy, {})[:write_lock]
25
25
  if write_lock
26
- logger.fatal("Making changes to deployed environments has been administratively disabled.")
27
- logger.fatal("Reason: #{write_lock}")
26
+ logger.fatal(_("Making changes to deployed environments has been administratively disabled."))
27
+ logger.fatal(_("Reason: %{write_lock}") % {write_lock: write_lock})
28
28
  exit(16)
29
29
  end
30
30
  end
@@ -13,9 +13,13 @@ module R10K
13
13
 
14
14
  include R10K::Action::Deploy::DeployHelpers
15
15
 
16
- def initialize(opts, argv, settings = {})
17
- @purge = true
16
+ def initialize(opts, argv, settings = nil)
17
+ settings ||= {}
18
+ @purge_levels = settings.fetch(:deploy, {}).fetch(:purge_levels, [])
19
+ @user_purge_whitelist = settings.fetch(:deploy, {}).fetch(:purge_whitelist, [])
20
+
18
21
  super
22
+
19
23
  @argv = @argv.map { |arg| arg.gsub(/\W/,'_') }
20
24
  end
21
25
 
@@ -45,13 +49,15 @@ module R10K
45
49
  undeployable = undeployable_environment_names(deployment.environments, @argv)
46
50
  if !undeployable.empty?
47
51
  @visit_ok = false
48
- logger.error "Environment(s) \'#{undeployable.join(", ")}\' cannot be found in any source and will not be deployed."
52
+ logger.error _("Environment(s) \'%{environments}\' cannot be found in any source and will not be deployed.") % {environments: undeployable.join(", ")}
49
53
  end
50
54
 
51
55
  yield
52
56
 
53
- deployment.purge! if @purge
54
-
57
+ if @purge_levels.include?(:deployment)
58
+ logger.debug("Purging unmanaged environments for deployment...")
59
+ deployment.purge!
60
+ end
55
61
  ensure
56
62
  if (postcmd = @settings[:postrun])
57
63
  subproc = R10K::Util::Subprocess.new(postcmd)
@@ -66,45 +72,60 @@ module R10K
66
72
 
67
73
  def visit_environment(environment)
68
74
  if !(@argv.empty? || @argv.any? { |name| environment.dirname == name })
69
- logger.debug1("Environment #{environment.dirname} does not match environment name filter, skipping")
75
+ logger.debug1(_("Environment %{env_dir} does not match environment name filter, skipping") % {env_dir: environment.dirname})
70
76
  return
71
77
  end
72
78
 
73
79
  started_at = Time.new
74
80
 
75
81
  status = environment.status
76
- logger.info "Deploying environment #{environment.path}"
82
+ logger.info _("Deploying environment %{env_path}") % {env_path: environment.path}
77
83
 
78
84
  environment.sync
79
- logger.info "Environment #{environment.dirname} is now at #{environment.signature}"
85
+ logger.info _("Environment %{env_dir} is now at %{env_signature}") % {env_dir: environment.dirname, env_signature: environment.signature}
80
86
 
81
87
  if status == :absent || @puppetfile
82
88
  if status == :absent
83
- logger.debug("Environment #{environment.dirname} is new, updating all modules")
89
+ logger.debug(_("Environment %{env_dir} is new, updating all modules") % {env_dir: environment.dirname})
84
90
  end
85
91
 
86
92
  yield
87
93
  end
88
94
 
89
- write_environment_info!(environment, started_at)
95
+ if @purge_levels.include?(:environment)
96
+ if @visit_ok
97
+ logger.debug("Purging unmanaged content for environment '#{environment.dirname}'...")
98
+ environment.purge!(:recurse => true, :whitelist => environment.whitelist(@user_purge_whitelist))
99
+ else
100
+ logger.debug("Not purging unmanaged content for environment '#{environment.dirname}' due to prior deploy failures.")
101
+ end
102
+ end
103
+
104
+ write_environment_info!(environment, started_at, @visit_ok)
90
105
  end
91
106
 
92
107
  def visit_puppetfile(puppetfile)
93
108
  puppetfile.load
109
+
94
110
  yield
95
- puppetfile.purge!
111
+
112
+ if @purge_levels.include?(:puppetfile)
113
+ logger.debug("Purging unmanaged Puppetfile content for environment '#{puppetfile.environment.dirname}'...")
114
+ puppetfile.purge!
115
+ end
96
116
  end
97
117
 
98
118
  def visit_module(mod)
99
- logger.info "Deploying module #{mod.path}"
119
+ logger.info _("Deploying Puppetfile content %{mod_path}") % {mod_path: mod.path}
100
120
  mod.sync
101
121
  end
102
122
 
103
- def write_environment_info!(environment, started_at)
123
+ def write_environment_info!(environment, started_at, success)
104
124
  File.open("#{environment.path}/.r10k-deploy.json", 'w') do |f|
105
125
  deploy_info = environment.info.merge({
106
126
  :started_at => started_at,
107
127
  :finished_at => Time.new,
128
+ :deploy_success => success,
108
129
  })
109
130
 
110
131
  f.puts(JSON.pretty_generate(deploy_info))
@@ -121,7 +142,7 @@ module R10K
121
142
  end
122
143
 
123
144
  def allowed_initialize_opts
124
- super.merge(puppetfile: :self, cachedir: :self, purge: true)
145
+ super.merge(puppetfile: :self, cachedir: :self)
125
146
  end
126
147
  end
127
148
  end
@@ -35,9 +35,9 @@ module R10K
35
35
 
36
36
  def visit_environment(environment)
37
37
  if @opts[:environment] && (@opts[:environment] != environment.dirname)
38
- logger.debug1("Only updating modules in environment #{@opts[:environment]}, skipping environment #{environment.path}")
38
+ logger.debug1(_("Only updating modules in environment %{opt_env} skipping environment %{env_path}") % {opt_env: @opts[:environment], env_path: environment.path})
39
39
  else
40
- logger.debug1("Updating modules #{@argv.inspect} in environment #{environment.path}")
40
+ logger.debug1(_("Updating modules %{modules} in environment %{env_path}") % {modules: @argv.inspect, env_path: environment_path})
41
41
  yield
42
42
  end
43
43
  end
@@ -49,10 +49,10 @@ module R10K
49
49
 
50
50
  def visit_module(mod)
51
51
  if @argv.include?(mod.name)
52
- logger.info "Deploying module #{mod.path}"
52
+ logger.info _("Deploying module %{mod_path}") % {mod_path: mod.path}
53
53
  mod.sync
54
54
  else
55
- logger.debug1("Only updating modules #{@argv.inspect}, skipping module #{mod.name}")
55
+ logger.debug1(_("Only updating modules %{modules}, skipping module %{mod_name}") % {modules: @argv.inspect, mod_name: mod.name})
56
56
  end
57
57
  end
58
58
 
@@ -11,7 +11,7 @@ module R10K
11
11
  pf = R10K::Puppetfile.new(@root, @moduledir, @path)
12
12
  begin
13
13
  pf.load!
14
- $stderr.puts "Syntax OK"
14
+ $stderr.puts _("Syntax OK")
15
15
  true
16
16
  rescue => e
17
17
  $stderr.puts R10K::Errors::Formatting.format_exception(e, @trace)