r10k 3.15.4 → 4.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +17 -0
  3. data/.github/workflows/docker.yml +4 -4
  4. data/.github/workflows/release.yml +2 -2
  5. data/.github/workflows/rspec_tests.yml +7 -11
  6. data/.github/workflows/stale.yml +1 -1
  7. data/CHANGELOG.mkd +19 -0
  8. data/Gemfile +2 -2
  9. data/README.mkd +3 -3
  10. data/doc/dynamic-environments/configuration.mkd +13 -1
  11. data/doc/puppetfile.mkd +9 -3
  12. data/integration/files/pre-suite/git_config.pp.erb +1 -1
  13. data/integration/pre-suite/10_git_config.rb +0 -3
  14. data/integration/tests/Puppetfile/HTTP_PROXY_affects_git_source.rb +5 -4
  15. data/integration/tests/basic_functionality/proxy_specified_in_configuration.rb +1 -1
  16. data/integration/tests/basic_functionality/proxy_with_puppetfile.rb +1 -1
  17. data/integration/tests/command_line/deploy_env_without_mod_update.rb +0 -3
  18. data/integration/tests/command_line/negative/neg_deploy_env_with_module_update.rb +0 -3
  19. data/integration/tests/git_source/HTTP_proxy_and_git_source.rb +5 -10
  20. data/integration/tests/git_source/git_source_git.rb +0 -3
  21. data/integration/tests/git_source/git_source_repeated_remote.rb +0 -3
  22. data/integration/tests/git_source/negative/neg_git_unauthorized_ssh.rb +1 -1
  23. data/integration/tests/purging/content_not_purged_at_root.rb +0 -3
  24. data/integration/tests/purging/default_purging.rb +0 -3
  25. data/integration/tests/purging/{does_not_purge_files_on_white_list.rb → does_not_purge_files_on_allowlist.rb} +2 -5
  26. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module.rb +0 -3
  27. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb +0 -3
  28. data/integration/tests/user_scenario/basic_workflow/multi_source_custom_forge_git_module.rb +0 -3
  29. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_forge_module.rb +0 -3
  30. data/integration/tests/user_scenario/basic_workflow/negative/neg_duplicate_module_names.rb +0 -3
  31. data/integration/tests/user_scenario/basic_workflow/negative/neg_inaccessible_forge.rb +3 -2
  32. data/integration/tests/user_scenario/basic_workflow/negative/neg_specify_deleted_forge_module.rb +1 -5
  33. data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_git_module.rb +0 -3
  34. data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_module.rb +0 -3
  35. data/integration/tests/user_scenario/basic_workflow/single_env_module_already_installed.rb +0 -3
  36. data/integration/tests/user_scenario/basic_workflow/single_env_purge_unmanaged_modules.rb +0 -3
  37. data/integration/tests/user_scenario/basic_workflow/single_env_switch_forge_git_module.rb +0 -3
  38. data/integration/tests/user_scenario/basic_workflow/single_env_upgrade_forge_mod_revert_change.rb +0 -3
  39. data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +0 -3
  40. data/lib/r10k/action/deploy/environment.rb +2 -19
  41. data/lib/r10k/action/deploy/module.rb +1 -0
  42. data/lib/r10k/action/puppetfile/check.rb +7 -0
  43. data/lib/r10k/action/puppetfile/install.rb +1 -0
  44. data/lib/r10k/cli/deploy.rb +15 -1
  45. data/lib/r10k/content_synchronizer.rb +7 -2
  46. data/lib/r10k/environment.rb +0 -1
  47. data/lib/r10k/git/rugged/bare_repository.rb +4 -3
  48. data/lib/r10k/git/rugged/working_repository.rb +7 -5
  49. data/lib/r10k/git/shellgit/working_repository.rb +1 -1
  50. data/lib/r10k/git/stateful_repository.rb +2 -2
  51. data/lib/r10k/module/base.rb +3 -3
  52. data/lib/r10k/module/git.rb +13 -4
  53. data/lib/r10k/module_loader/puppetfile.rb +0 -7
  54. data/lib/r10k/puppetfile.rb +1 -1
  55. data/lib/r10k/settings.rb +6 -7
  56. data/lib/r10k/version.rb +1 -1
  57. data/locales/r10k.pot +10 -6
  58. data/r10k.gemspec +4 -6
  59. metadata +18 -76
  60. data/docker/.gitignore +0 -1
  61. data/docker/.rspec +0 -4
  62. data/docker/Gemfile +0 -11
  63. data/docker/Makefile +0 -99
  64. data/docker/README.md +0 -28
  65. data/docker/docker-compose.yml +0 -18
  66. data/docker/r10k/Dockerfile +0 -68
  67. data/docker/r10k/adduser.sh +0 -13
  68. data/docker/r10k/docker-entrypoint.d/10-analytics.sh +0 -30
  69. data/docker/r10k/docker-entrypoint.sh +0 -10
  70. data/docker/r10k/release.Dockerfile +0 -55
  71. data/docker/spec/dockerfile_spec.rb +0 -37
  72. data/docker/spec/fixtures/Puppetfile +0 -2
  73. data/integration/tests/basic_functionality/install_pe_only_module_with_puppetfile.rb +0 -83
  74. data/integration/tests/basic_functionality/proxy_with_pe_only_module.rb +0 -128
  75. data/integration/tests/purging/invalid_whitelist_types.rb +0 -63
  76. data/integration/tests/user_scenario/basic_workflow/negative/neg_module_specified_at_deleted_release.rb +0 -49
  77. data/integration/tests/user_scenario/basic_workflow/single_env_module_last_release_deleted.rb +0 -68
  78. data/lib/r10k/environment/bare.rb +0 -13
data/docker/Gemfile DELETED
@@ -1,11 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem 'pupperware',
4
- :git => 'https://github.com/puppetlabs/pupperware.git',
5
- :branch => 'main',
6
- :glob => 'gem/*.gemspec'
7
-
8
- group :test do
9
- gem 'rspec'
10
- gem 'rspec_junit_formatter'
11
- end
data/docker/Makefile DELETED
@@ -1,99 +0,0 @@
1
- PUPPERWARE_ANALYTICS_STREAM ?= dev
2
- NAMESPACE ?= puppet
3
- git_describe = $(shell git describe --tags)
4
- vcs_ref := $(shell git rev-parse HEAD)
5
- build_date := $(shell date -u +%FT%T)
6
- hadolint_available := $(shell hadolint --help > /dev/null 2>&1; echo $$?)
7
- hadolint_command := hadolint
8
- hadolint_container := ghcr.io/hadolint/hadolint:latest
9
- alpine_version := 3.14
10
- # --load (--output=type=docker) can only be used with a single arch / platform
11
- # https://github.com/docker/buildx/issues/59
12
- output_type := docker
13
- platform := linux/amd64
14
- export BUNDLE_PATH = $(PWD)/.bundle/gems
15
- export BUNDLE_BIN = $(PWD)/.bundle/bin
16
- export GEMFILE = $(PWD)/Gemfile
17
- export DOCKER_BUILDKIT ?= 1
18
-
19
- ifeq ($(IS_RELEASE),true)
20
- VERSION ?= $(shell echo $(git_describe) | sed 's/-.*//')
21
- PUBLISHED_VERSION ?= $(shell curl --silent 'https://rubygems.org/api/v1/gems/r10k.json' | jq '."version"' | tr -d '"')
22
- CONTAINER_EXISTS = $(shell DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect $(NAMESPACE)/r10k:$(VERSION) > /dev/null 2>&1; echo $$?)
23
- ifeq ($(CONTAINER_EXISTS),0)
24
- SKIP_BUILD ?= true
25
- else ifneq ($(VERSION),$(PUBLISHED_VERSION))
26
- SKIP_BUILD ?= true
27
- endif
28
-
29
- LATEST_VERSION ?= latest
30
- dockerfile := release.Dockerfile
31
- dockerfile_context := r10k
32
- else
33
- VERSION ?= edge
34
- IS_LATEST := false
35
- dockerfile := Dockerfile
36
- dockerfile_context := $(PWD)/..
37
- endif
38
-
39
- ifeq ($(IS_LATEST),true)
40
- latest_tag := --tag $(NAMESPACE)/r10k:$(LATEST_VERSION)
41
- endif
42
-
43
- prep:
44
- @git fetch --unshallow 2> /dev/null ||:
45
- @git fetch origin 'refs/tags/*:refs/tags/*'
46
- ifeq ($(SKIP_BUILD),true)
47
- @echo "SKIP_BUILD is true, exiting with 1"
48
- @exit 1
49
- endif
50
-
51
- lint:
52
- ifeq ($(hadolint_available),0)
53
- @$(hadolint_command) r10k/$(dockerfile)
54
- else
55
- @docker pull $(hadolint_container)
56
- @docker run --rm -v $(PWD)/r10k/$(dockerfile):/Dockerfile -i $(hadolint_container) $(hadolint_command) Dockerfile
57
- endif
58
-
59
- build: prep
60
- docker pull alpine:$(alpine_version)
61
- docker buildx build \
62
- ${DOCKER_BUILD_FLAGS} \
63
- --output=type=$(output_type) \
64
- --platform $(platform) \
65
- --build-arg alpine_version=$(alpine_version) \
66
- --build-arg vcs_ref=$(vcs_ref) \
67
- --build-arg build_date=$(build_date) \
68
- --build-arg version=$(VERSION) \
69
- --build-arg pupperware_analytics_stream=$(PUPPERWARE_ANALYTICS_STREAM) \
70
- --file r10k/$(dockerfile) \
71
- --tag $(NAMESPACE)/r10k:$(VERSION) $(latest_tag) $(dockerfile_context)
72
-
73
- test: prep
74
- @bundle install --path $$BUNDLE_PATH --gemfile $$GEMFILE --with test
75
- @bundle update
76
- @PUPPET_TEST_DOCKER_IMAGE=$(NAMESPACE)/r10k:$(VERSION) \
77
- bundle exec --gemfile $$GEMFILE \
78
- rspec spec
79
-
80
- # call build to produce multiple architectures
81
- # uses cached output from amd64 build target if it exists
82
- # registry output is equivalent to --push
83
- push-image: platform=linux/amd64,linux/arm64
84
- push-image: output_type=registry
85
- push-image: prep build
86
-
87
- push-readme:
88
- @docker pull sheogorath/readme-to-dockerhub
89
- @docker run --rm \
90
- -v $(PWD)/README.md:/data/README.md \
91
- -e DOCKERHUB_USERNAME="$(DOCKERHUB_USERNAME)" \
92
- -e DOCKERHUB_PASSWORD="$(DOCKERHUB_PASSWORD)" \
93
- -e DOCKERHUB_REPO_PREFIX=puppet \
94
- -e DOCKERHUB_REPO_NAME=r10k \
95
- sheogorath/readme-to-dockerhub
96
-
97
- publish: push-image push-readme
98
-
99
- .PHONY: lint build test prep publish push-image push-readme
data/docker/README.md DELETED
@@ -1,28 +0,0 @@
1
- # [puppetlabs/r10k](https://github.com/puppetlabs/r10k)
2
-
3
- r10k on a Docker image. Based on Alpine 3.8.
4
-
5
- ## Configuration
6
-
7
- The following environment variables are supported:
8
-
9
- - `PUPPERWARE_ANALYTICS_ENABLED`
10
-
11
- Set to 'true' to enable Google Analytics metrics. Defaults to 'false'.
12
-
13
- ## Analytics Data Collection
14
-
15
- The r10k container collects usage data. This is disabled by default. You can enable it by passing `--env PUPPERWARE_ANALYTICS_ENABLED=true`
16
- to your `docker run` command.
17
-
18
- ### What data is collected?
19
- * Version of the r10k container.
20
- * Anonymized IP address is used by Google Analytics for Geolocation data, but the IP address is not collected.
21
-
22
- ### Why does the r10k container collect data?
23
-
24
- We collect data to help us understand how the containers are used and make decisions about upcoming changes.
25
-
26
- ### How can I opt out of r10k container data collection?
27
-
28
- This is disabled by default.
@@ -1,18 +0,0 @@
1
- version: '3.7'
2
-
3
- services:
4
- r10k_check:
5
- image: ${R10K_IMAGE:-puppet/r10k}
6
- environment:
7
- - PUPPERWARE_ANALYTICS_ENABLED=${PUPPERWARE_ANALYTICS_ENABLED:-false}
8
- command: 'puppetfile check --verbose --trace --puppetfile test/Puppetfile'
9
- volumes:
10
- - ${SPEC_DIRECTORY}/fixtures:/home/puppet/test
11
-
12
- r10k_install:
13
- image: ${R10K_IMAGE:-puppet/r10k}
14
- environment:
15
- - PUPPERWARE_ANALYTICS_ENABLED=${PUPPERWARE_ANALYTICS_ENABLED:-false}
16
- command: 'puppetfile install --verbose --trace --puppetfile test/Puppetfile'
17
- volumes:
18
- - ${SPEC_DIRECTORY}/fixtures:/home/puppet/test
@@ -1,68 +0,0 @@
1
- ARG alpine_version=3.14
2
- FROM alpine:${alpine_version} as build
3
-
4
- # hadolint ignore=DL3018
5
- RUN apk add --no-cache ruby git && \
6
- mkdir /workspace
7
- WORKDIR /workspace
8
- COPY . /workspace
9
- RUN gem build r10k.gemspec && \
10
- mv r10k*.gem r10k.gem
11
-
12
- FROM alpine:${alpine_version}
13
-
14
- ARG vcs_ref
15
- ARG build_date
16
- ARG version="3.1.0"
17
- # Used by entrypoint to submit metrics to Google Analytics.
18
- # Published images should use "production" for this build_arg.
19
- ARG pupperware_analytics_stream="dev"
20
- # required to schedule runs of "r10k" in K8s
21
- ARG supercronic_version="0.1.9"
22
- ARG supercronic_sha1sum="5ddf8ea26b56d4a7ff6faecdd8966610d5cb9d85"
23
- ARG supercronic="supercronic-linux-amd64"
24
- ARG supercronic_url="https://github.com/aptible/supercronic/releases/download/v$supercronic_version/$supercronic"
25
-
26
- LABEL org.label-schema.maintainer="Puppet Release Team <release@puppet.com>" \
27
- org.label-schema.vendor="Puppet" \
28
- org.label-schema.url="https://github.com/puppetlabs/r10k" \
29
- org.label-schema.name="r10k" \
30
- org.label-schema.license="Apache-2.0" \
31
- org.label-schema.vcs-url="https://github.com/puppetlabs/r10k" \
32
- org.label-schema.schema-version="1.0" \
33
- org.label-schema.dockerfile="/Dockerfile"
34
-
35
- COPY docker/r10k/adduser.sh docker/r10k/docker-entrypoint.sh /
36
- COPY docker/r10k/docker-entrypoint.d /docker-entrypoint.d
37
-
38
- ENTRYPOINT ["/docker-entrypoint.sh"]
39
- CMD ["help"]
40
-
41
- # dynamic LABELs and ENV vars placed lower for the sake of Docker layer caching
42
- ENV PUPPERWARE_ANALYTICS_STREAM="$pupperware_analytics_stream"
43
-
44
- LABEL org.label-schema.version="$version" \
45
- org.label-schema.vcs-ref="$vcs_ref" \
46
- org.label-schema.build-date="$build_date"
47
-
48
- COPY --from=build /workspace/r10k.gem /
49
- SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
50
- # ignore apk and gem pinning
51
- # hadolint ignore=DL3018,DL3028
52
- RUN chmod a+x /adduser.sh /docker-entrypoint.sh /docker-entrypoint.d/*.sh && \
53
- # Add a puppet user to run r10k as for consistency with puppetserver
54
- /adduser.sh && \
55
- chown -R puppet: /docker-entrypoint.d /docker-entrypoint.sh && \
56
- apk add --no-cache ruby openssh-client git ruby-rugged curl ruby-json ruby-etc && \
57
- gem install --no-doc /r10k.gem && \
58
- rm -f /r10k.gem && \
59
- curl --fail --silent --show-error --location --remote-name "$supercronic_url" && \
60
- echo "${supercronic_sha1sum} ${supercronic}" | sha1sum -c - && \
61
- chmod +x "$supercronic" && \
62
- mv "$supercronic" "/usr/local/bin/${supercronic}" && \
63
- ln -s "/usr/local/bin/${supercronic}" /usr/local/bin/supercronic
64
-
65
- USER puppet
66
- WORKDIR /home/puppet
67
-
68
- COPY docker/r10k/Dockerfile /
@@ -1,13 +0,0 @@
1
- #!/bin/sh
2
-
3
- getent_string="$(getent group | grep -e ':999$')"
4
- exit_code=$?
5
-
6
- if [ "$exit_code" = '0' ]; then
7
- group="$(echo $getent_string | cut -d ':' -f1)"
8
- else
9
- addgroup -g 999 puppet
10
- group='puppet'
11
- fi
12
-
13
- adduser -G $group -D -u 999 puppet
@@ -1,30 +0,0 @@
1
- #!/bin/sh
2
-
3
- if [ "${PUPPERWARE_ANALYTICS_ENABLED}" != "true" ]; then
4
- # Don't print out any messages here since this is a CLI container
5
- exit 0
6
- fi
7
-
8
- # See: https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
9
- # Tracking ID
10
- tid=UA-132486246-5
11
- # Application Name
12
- an=r10k
13
- # Application Version
14
- av=$(r10k version | cut -d ' ' -f 2)
15
- # Anonymous Client ID
16
- _file=/var/tmp/pwclientid
17
- cid=$(cat $_file 2>/dev/null || (cat /proc/sys/kernel/random/uuid | tee $_file))
18
- # Event Category
19
- ec=${PUPPERWARE_ANALYTICS_STREAM:-dev}
20
- # Event Action
21
- ea=start
22
- # Anonymize ip
23
- aip=1
24
-
25
- _params="v=1&t=event&tid=${tid}&an=${an}&av=${av}&cid=${cid}&ec=${ec}&ea=${ea}&aip=${aip}"
26
- _url="http://www.google-analytics.com/collect?${_params}"
27
-
28
- # Don't print out any messages here since this is a CLI container
29
- curl --fail --silent --show-error --output /dev/null \
30
- -X POST -H "Content-Length: 0" $_url
@@ -1,10 +0,0 @@
1
- #! /bin/sh
2
-
3
- set -e
4
-
5
- for f in /docker-entrypoint.d/*.sh; do
6
- # Don't print out any messages here since this is a CLI container
7
- "$f"
8
- done
9
-
10
- exec /usr/bin/r10k "$@"
@@ -1,55 +0,0 @@
1
- ARG alpine_version=3.14
2
- FROM alpine:${alpine_version}
3
-
4
- ARG vcs_ref
5
- ARG build_date
6
- ARG version="3.1.0"
7
- # Used by entrypoint to submit metrics to Google Analytics.
8
- # Published images should use "production" for this build_arg.
9
- ARG pupperware_analytics_stream="dev"
10
- # required to schedule runs of "r10k" in K8s
11
- ARG supercronic_version="0.1.9"
12
- ARG supercronic_sha1sum="5ddf8ea26b56d4a7ff6faecdd8966610d5cb9d85"
13
- ARG supercronic="supercronic-linux-amd64"
14
- ARG supercronic_url="https://github.com/aptible/supercronic/releases/download/v$supercronic_version/$supercronic"
15
-
16
- LABEL org.label-schema.maintainer="Puppet Release Team <release@puppet.com>" \
17
- org.label-schema.vendor="Puppet" \
18
- org.label-schema.url="https://github.com/puppetlabs/r10k" \
19
- org.label-schema.name="r10k" \
20
- org.label-schema.license="Apache-2.0" \
21
- org.label-schema.vcs-url="https://github.com/puppetlabs/r10k" \
22
- org.label-schema.schema-version="1.0" \
23
- org.label-schema.dockerfile="/release.Dockerfile"
24
-
25
- COPY adduser.sh docker-entrypoint.sh /
26
- COPY docker-entrypoint.d /docker-entrypoint.d
27
-
28
- ENTRYPOINT ["/docker-entrypoint.sh"]
29
- CMD ["help"]
30
-
31
- # dyanmic LABELs and ENV vars placed lower for the sake of Docker layer caching
32
- ENV PUPPERWARE_ANALYTICS_STREAM="$pupperware_analytics_stream"
33
-
34
- LABEL org.label-schema.version="$version" \
35
- org.label-schema.vcs-ref="$vcs_ref" \
36
- org.label-schema.build-date="$build_date"
37
-
38
- SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
39
- # ignore apk and gem pinning
40
- # hadolint ignore=DL3018,DL3028
41
- RUN chmod a+x /adduser.sh /docker-entrypoint.sh /docker-entrypoint.d/*.sh && \
42
- /adduser.sh && \
43
- chown -R puppet: /docker-entrypoint.d /docker-entrypoint.sh && \
44
- apk add --no-cache ruby openssh-client git ruby-rugged curl ruby-dev make gcc musl-dev && \
45
- gem install --no-doc r10k:"$version" json etc && \
46
- curl --fail --silent --show-error --location --remote-name "$supercronic_url" && \
47
- echo "${supercronic_sha1sum} ${supercronic}" | sha1sum -c - && \
48
- chmod +x "$supercronic" && \
49
- mv "$supercronic" "/usr/local/bin/${supercronic}" && \
50
- ln -s "/usr/local/bin/${supercronic}" /usr/local/bin/supercronic
51
-
52
- USER puppet
53
- WORKDIR /home/puppet
54
-
55
- COPY release.Dockerfile /
@@ -1,37 +0,0 @@
1
- require 'rspec/core'
2
- require 'fileutils'
3
- require 'open3'
4
- include Pupperware::SpecHelpers
5
-
6
- ENV['SPEC_DIRECTORY'] = File.dirname(__FILE__)
7
- # unifies volume naming
8
- ENV['COMPOSE_PROJECT_NAME'] ||= 'r10k'
9
-
10
- RSpec.configure do |c|
11
- c.before(:suite) do
12
- ENV['R10K_IMAGE'] = require_test_image
13
- pull_images(['r10k_check','r10k_install'])
14
- teardown_cluster()
15
- # no certs to preload, but if the suite adds puppetserver, be explicit
16
- docker_compose_up(preload_certs: true)
17
- end
18
-
19
- c.after(:suite) do
20
- teardown_cluster()
21
- FileUtils.rm_rf(File.join(ENV['SPEC_DIRECTORY'], 'fixtures', 'modules'))
22
- end
23
- end
24
-
25
- describe 'r10k container' do
26
- {
27
- 'r10k_check': 'validate',
28
- 'r10k_install': 'install',
29
- }.each do |container, op|
30
- it "should #{op} the Puppetfile" do
31
- container = get_service_container(container)
32
- wait_on_container_exit(container)
33
- expect(get_container_exit_code(container)).to eq(0)
34
- emit_log(container)
35
- end
36
- end
37
- end
@@ -1,2 +0,0 @@
1
- moduledir '/tmp/modules'
2
- mod 'puppetlabs/ntp'
@@ -1,83 +0,0 @@
1
- require 'git_utils'
2
- require 'r10k_utils'
3
- require 'master_manipulator'
4
- test_name 'RK-158 - C92362 - Install a PE-only module from forge'
5
-
6
- #Init
7
- env_path = on(master, puppet('config print environmentpath')).stdout.rstrip
8
- r10k_fqp = get_r10k_fqp(master)
9
- master_certname = on(master, puppet('config', 'print', 'certname')).stdout.rstrip
10
-
11
- git_repo_path = '/git_repos'
12
- git_repo_name = 'environments'
13
- git_control_remote = File.join(git_repo_path, "#{git_repo_name}.git")
14
- git_environments_path = '/root/environments'
15
- last_commit = git_last_commit(master, git_environments_path)
16
- git_provider = ENV['GIT_PROVIDER'] || 'shellgit'
17
-
18
- r10k_config_path = get_r10k_config_file_path(master)
19
- r10k_config_bak_path = "#{r10k_config_path}.bak"
20
-
21
- #In-line files
22
- r10k_conf = <<-CONF
23
- cachedir: '/var/cache/r10k'
24
- git:
25
- provider: '#{git_provider}'
26
- sources:
27
- control:
28
- basedir: "#{env_path}"
29
- remote: "#{git_control_remote}"
30
- CONF
31
-
32
- #Manifest
33
- site_pp_path = File.join(git_environments_path, 'manifests', 'site.pp')
34
- site_pp = create_site_pp(master_certname, ' include peonly')
35
-
36
- # Verification
37
- notify_message_regex = /I am in the production environment, this is a PE only module/
38
-
39
- #Teardown
40
- teardown do
41
- step 'remove license file'
42
- on(master, 'rm -f /etc/puppetlabs/license.key')
43
-
44
- step 'Restore Original "r10k" Config'
45
- on(master, "mv #{r10k_config_bak_path} #{r10k_config_path}")
46
-
47
- step 'cleanup r10k'
48
- clean_up_r10k(master, last_commit, git_environments_path)
49
- end
50
-
51
- #Setup
52
- step 'Stub the forge'
53
- stub_forge_on(master)
54
-
55
- step 'Backup a Valid "r10k" Config'
56
- on(master, "mv #{r10k_config_path} #{r10k_config_bak_path}")
57
-
58
- step 'Update the "r10k" Config'
59
- create_remote_file(master, r10k_config_path, r10k_conf)
60
-
61
- step 'Download license file from artifactory'
62
- curl_on(master, 'https://artifactory.delivery.puppetlabs.net/artifactory/generic/r10k_test_license.key -o /etc/puppetlabs/license.key')
63
-
64
- step 'Inject New "site.pp" to the "production" Environment'
65
- inject_site_pp(master, site_pp_path, site_pp)
66
-
67
- step 'Copy Puppetfile to "production" Environment Git Repo'
68
- create_remote_file(master, "#{git_environments_path}/Puppetfile", 'mod "ztr-peonly"')
69
-
70
- step 'Push Changes'
71
- git_add_commit_push(master, 'production', 'add Puppetfile', git_environments_path)
72
-
73
- #Tests
74
- step 'Deploy "production" Environment via r10k'
75
- on(master, "#{r10k_fqp} deploy environment -p")
76
-
77
- agents.each do |agent|
78
- step "Run Puppet Agent"
79
- on(agent, puppet('agent', '--test', '--environment production'), :acceptable_exit_codes => 2) do |result|
80
- assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
81
- assert_match(notify_message_regex, result.stdout, 'Expected message not found!')
82
- end
83
- end
@@ -1,128 +0,0 @@
1
- require 'git_utils'
2
- require 'r10k_utils'
3
- require 'master_manipulator'
4
- test_name 'RK-242 '#'- C87652 - Specify the proxy in the r10k.yaml'
5
-
6
- confine(:to, :platform => ['el', 'sles'])
7
-
8
- #Init
9
- master_platform = fact_on(master, 'osfamily')
10
- master_certname = on(master, puppet('config', 'print', 'certname')).stdout.rstrip
11
- env_path = on(master, puppet('config print environmentpath')).stdout.rstrip
12
- r10k_fqp = get_r10k_fqp(master)
13
-
14
- git_repo_path = '/git_repos'
15
- git_repo_name = 'environments'
16
- git_control_remote = File.join(git_repo_path, "#{git_repo_name}.git")
17
- git_environments_path = '/root/environments'
18
- last_commit = git_last_commit(master, git_environments_path)
19
- git_provider = ENV['GIT_PROVIDER']
20
-
21
- local_files_root_path = ENV['FILES'] || 'files'
22
-
23
- git_manifest_template_path = File.join(local_files_root_path, 'pre-suite', 'git_config.pp.erb')
24
- git_manifest = ERB.new(File.read(git_manifest_template_path)).result(binding)
25
-
26
- r10k_config_path = get_r10k_config_file_path(master)
27
- r10k_config_bak_path = "#{r10k_config_path}.bak"
28
-
29
- case master_platform
30
- when 'RedHat'
31
- pkg_manager = 'yum'
32
- when 'Suse'
33
- pkg_manager = 'zypper'
34
- end
35
-
36
- install_squid = "#{pkg_manager} install -y squid"
37
- remove_squid = "#{pkg_manager} remove -y squid"
38
- squid_log = "/var/log/squid/access.log"
39
-
40
- #In-line files
41
- r10k_conf = <<-CONF
42
- cachedir: '/var/cache/r10k'
43
- git:
44
- provider: '#{git_provider}'
45
- sources:
46
- control:
47
- basedir: "#{env_path}"
48
- remote: "#{git_control_remote}"
49
- forge:
50
- proxy: "http://#{master.hostname}:3128"
51
- CONF
52
-
53
- #Manifest
54
- site_pp_path = File.join(git_environments_path, 'manifests', 'site.pp')
55
- site_pp = create_site_pp(master_certname, ' include peonly')
56
-
57
- #Verification
58
- squid_log_regex = /CONNECT forgeapi.puppetlabs.com:443/
59
- notify_message_regex = /I am in the production environment, this is a PE only module/
60
-
61
- #Teardown
62
- teardown do
63
- step 'remove license file'
64
- on(master, 'rm -f /etc/puppetlabs/license.key')
65
-
66
- step 'Restore "git" Package'
67
- on(master, puppet('apply'), :stdin => git_manifest, :acceptable_exit_codes => [0,2])
68
-
69
- step 'Restore Original "r10k" Config'
70
- on(master, "mv #{r10k_config_bak_path} #{r10k_config_path}")
71
-
72
- clean_up_r10k(master, last_commit, git_environments_path)
73
-
74
- step 'Remove Squid'
75
- on(master, puppet("apply -e 'service {'squid' : ensure => stopped}'"))
76
- on(master, remove_squid)
77
- end
78
-
79
- #Setup
80
- step 'Stub the forge'
81
- stub_forge_on(master)
82
-
83
- step 'Backup Current "r10k" Config'
84
- on(master, "mv #{r10k_config_path} #{r10k_config_bak_path}")
85
-
86
- step 'Update the "r10k" Config'
87
- create_remote_file(master, r10k_config_path, r10k_conf)
88
-
89
- step 'Download license file from artifactory'
90
- curl_on(master, 'https://artifactory.delivery.puppetlabs.net/artifactory/generic/r10k_test_license.key -o /etc/puppetlabs/license.key')
91
-
92
- step 'Checkout "production" Branch'
93
- git_on(master, 'checkout production', git_environments_path)
94
-
95
- step 'Inject New "site.pp" to the "production" Environment'
96
- inject_site_pp(master, site_pp_path, site_pp)
97
-
98
- step 'Copy Puppetfile to "production" Environment with PE only module'
99
- create_remote_file(master, "#{git_environments_path}/Puppetfile", 'mod "ztr-peonly"')
100
-
101
- step 'Push Changes'
102
- git_add_commit_push(master, 'production', 'add Puppetfile', git_environments_path)
103
-
104
- step 'Install and configure squid proxy'
105
- on(master, install_squid)
106
-
107
- step 'turn off the firewall'
108
- on(master, puppet("apply -e 'service {'iptables' : ensure => stopped}'"))
109
-
110
- step 'start squid proxy'
111
- on(master, puppet("apply -e 'service {'squid' : ensure => running}'"))
112
-
113
- #Tests
114
- step 'Deploy "production" Environment via r10k'
115
- on(master, "#{r10k_fqp} deploy environment -p")
116
-
117
- step 'Read the squid logs'
118
- on(master, "cat #{squid_log}") do |result|
119
- assert_match(squid_log_regex, result.stdout, 'Proxy logs did not indicate use of the proxy.')
120
- end
121
-
122
- agents.each do |agent|
123
- step "Run Puppet Agent"
124
- on(agent, puppet('agent', '--test', '--environment production'), :acceptable_exit_codes => [0,2]) do |result|
125
- assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
126
- assert_match(notify_message_regex, result.stdout, 'Expected message not found!')
127
- end
128
- end
@@ -1,63 +0,0 @@
1
- require 'git_utils'
2
- require 'r10k_utils'
3
- require 'master_manipulator'
4
- test_name 'RK-257 - C98043 - verify default whitelist only accepts strings or array of strings'
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
-
11
- git_repo_path = '/git_repos'
12
- git_repo_name = 'environments'
13
- git_control_remote = File.join(git_repo_path, "#{git_repo_name}.git")
14
-
15
- last_commit = git_last_commit(master, git_environments_path)
16
- git_provider = ENV['GIT_PROVIDER']
17
-
18
- r10k_config_path = get_r10k_config_file_path(master)
19
- r10k_config_bak_path = "#{r10k_config_path}.bak"
20
-
21
- #invalid content to test
22
- hash_whitelist = '{:cats => \'cats.txt\'}'
23
- invalid_array_content_whitelist = '[\'cats.txt\', [:broken]]'
24
-
25
- teardown do
26
- step 'Restore Original "r10k" Config'
27
- on(master, "mv #{r10k_config_bak_path} #{r10k_config_path}")
28
-
29
- clean_up_r10k(master, last_commit, git_environments_path)
30
- end
31
-
32
- # initalize file content
33
- step 'Stub the forge'
34
- stub_forge_on(master)
35
-
36
- step 'Backup Current "r10k" Config'
37
- on(master, "mv #{r10k_config_path} #{r10k_config_bak_path}")
38
-
39
- [hash_whitelist, invalid_array_content_whitelist].each do |whitelist_content|
40
- r10k_conf = <<-CONF
41
- cachedir: '/var/cache/r10k'
42
- git:
43
- provider: '#{git_provider}'
44
- sources:
45
- control:
46
- basedir: "#{env_path}"
47
- remote: "#{git_control_remote}"
48
- deploy:
49
- purge_whitelist: #{whitelist_content}
50
- CONF
51
-
52
- step 'Update the "r10k" Config'
53
- create_remote_file(master, r10k_config_path, r10k_conf)
54
-
55
- step 'Deploy r10k, and verify that invalid whitelist content causes error'
56
- on(master, "#{r10k_fqp} deploy environment -p", :accept_all_exit_codes => true) do |result|
57
- error = /did not find expected node content while parsing a flow node/
58
- error_message = 'whitelist content did not generate expected error'
59
- expect_failure('RK-263') do
60
- assert_no_match(result.stdout, error, error_message)
61
- end
62
- end
63
- end