r10k 3.3.3 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1c5e1d56a50eeaca95e17ebce9b11b29bf0566f3
4
- data.tar.gz: e823ba782b16a2a01e574b07452170f2142180bb
2
+ SHA256:
3
+ metadata.gz: 8fa591e05f2bcb8e3e7acb9b4ac018ef5a3471832bca677a49c5a409f358b5a8
4
+ data.tar.gz: 9d27ceb63bc53563b419140a3de96b744171bb790d8fb12a2a4c73e4b3feb2cf
5
5
  SHA512:
6
- metadata.gz: 89919d96fa8f6e0542112b6864cabde14244aba8986ad65d63940d1ccdcfd7209b79f24da6b23edd6a3d92c22c2e7a24f7a96f1ab96c5a2d2924dbed159ab665
7
- data.tar.gz: 38efbca6d8315176df86caeff0c60888f15798700e3733b104542baa82dd6ad3dc87c061bc341d4f577d9e4f9640a517a9106ce988dcd1c77fd8433283c3df1a
6
+ metadata.gz: 1cc2808331cbcb0f52ce418eaea05995a96ddec0bc5e523b7179969d4f51609745912ae7a8e621104a704a40f71a7502bdc809d10948ea39961cb288a81ddd9c
7
+ data.tar.gz: 418fcc583a83105d5953cd1df74e4ea09735b427765c67f2600d357c3daade952a7d1242f102d1bf2c34b71aa8bcd7cfeca7416274d97911b2916a28b7b03571
@@ -0,0 +1,32 @@
1
+ name: Docker test and publish
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+
8
+ jobs:
9
+ build-and-publish:
10
+ env:
11
+ PUPPERWARE_ANALYTICS_STREAM: production
12
+ IS_LATEST: true
13
+ DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
14
+ DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
15
+
16
+ runs-on: ubuntu-latest
17
+
18
+ steps:
19
+ - uses: actions/checkout@master
20
+ - name: Set up Ruby 2.6
21
+ uses: actions/setup-ruby@v1
22
+ with:
23
+ ruby-version: 2.6.x
24
+ - run: gem install bundler
25
+ - name: Build container
26
+ working-directory: docker
27
+ run: make lint build test
28
+ - name: Publish container
29
+ working-directory: docker
30
+ run: |
31
+ docker login -u "$DOCKERHUB_USERNAME" -p "$DOCKERHUB_PASSWORD"
32
+ make publish
@@ -12,6 +12,8 @@ jdk:
12
12
  before_install: gem install bundler -v '< 2' --no-document
13
13
  matrix:
14
14
  include:
15
+ - stage: r10k tests
16
+ rvm: 2.6.5
15
17
  - stage: r10k tests
16
18
  rvm: 2.5.0
17
19
  - stage: r10k tests
@@ -1,6 +1,12 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
+ 3.4.0
5
+ -----
6
+
7
+ - Switch to supported `colored2` gem
8
+ - Add YAML environment source types [#983](https://github.com/puppetlabs/r10k/pull/983), [#1002](https://github.com/puppetlabs/r10k/pull/1002). YAML source types use configuration files to define environments, rather than VCS branches, and support deploying modules to an environment without modifying a control-repo. YAML environment source types are experimental in this release
9
+
4
10
  3.3.3
5
11
  -----
6
12
 
data/CODEOWNERS CHANGED
@@ -1 +1,2 @@
1
+ * @puppetlabs/puppetserver-maintainers
1
2
  /docker/ @puppetlabs/pupperware
data/README.mkd CHANGED
@@ -17,7 +17,8 @@ implementation of Puppet [dynamic environments][workflow].
17
17
  Requirements
18
18
  ------------
19
19
 
20
- R10k supports the Ruby versions `>= 2.3.0`.
20
+ R10k supports the Ruby versions `>= 2.3.0`. It's tested on Ruby 2.3.0 up to
21
+ Ruby 2.6.0 + Jruby.
21
22
 
22
23
  R10k requires additional components, depending on how you plan on managing
23
24
  environments and modules.
data/bin/r10k CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'r10k/cli'
4
- require 'colored'
4
+ require 'colored2'
5
5
 
6
6
  begin
7
7
  R10K::CLI.command.run(ARGV)
@@ -263,7 +263,7 @@ After Puppetfile content for a given environment is deployed, r10k will
263
263
  recursively remove any content found in a directory managed by the Puppetfile
264
264
  which is not also declared in that Puppetfile. Directories considered to be
265
265
  managed by a Puppetfile include the configured `moduledir` (which defaults to
266
- "modules") as well as alternate directories specified as an `install\_path`
266
+ "modules") as well as alternate directories specified as an `install_path`
267
267
  option to any Puppetfile content declarations.
268
268
 
269
269
  #### purge\_whitelist
@@ -509,3 +509,147 @@ This will create the following directory structure:
509
509
  |-- app1_production # app1 data repository, production branch
510
510
  |-- app1_develop # app1 data repository, develop branch
511
511
  ```
512
+
513
+ Experimental Features
514
+ ---------------------
515
+
516
+ ### YAML Environment Source
517
+
518
+ Dynamically deploying Puppet content based on the state of version control repositories can be powerful and efficient for development workflows. The linkage however is not advantageous when trying to build precision controls over deployment of previously-developed and tested content.
519
+
520
+ The YAML environment source type allows for a clear separation of tooling between development workflow, and deployment workflow. Development workflow creates new commits in the version control system. Deployment workflow consumes them.
521
+
522
+ To use the YAML environment source, configure r10k's sources with at least one entry using the yaml type.
523
+
524
+ ```yaml
525
+ # r10k.yaml
526
+ ---
527
+ sources:
528
+ puppet:
529
+ type: yaml
530
+ basedir: /etc/puppetlabs/code/environments
531
+ config: /etc/puppetlabs/r10k/environments.yaml # default
532
+ ```
533
+
534
+ When using the YAML source type, every environment is enumerated in a single yaml file. Each environment specifies a type, source, and version (typically a Git ref) to deploy. In the following example, two environments are defined, which are identical to each other.
535
+
536
+ ```yaml
537
+ ---
538
+ production:
539
+ type: git
540
+ remote: git@github.com:puppetlabs/control-repo.git
541
+ ref: 8820892
542
+
543
+ development:
544
+ type: git
545
+ remote: git@github.com:puppetlabs/control-repo.git
546
+ ref: 8820892
547
+ ```
548
+
549
+ ### YAMLdir Environment Source
550
+
551
+ Like the YAML environment source, but implemented as a conf.d pattern.
552
+
553
+ ```yaml
554
+ # r10k.yaml
555
+ ---
556
+ sources:
557
+ puppet:
558
+ type: yamldir
559
+ basedir: /etc/puppetlabs/code/environments
560
+ config: /etc/puppetlabs/r10k/environments.d # default
561
+ ```
562
+
563
+ Each environment is defined in a yaml file placed in the configuration directory. The filename, without the .yaml extension, will be the name of the environment.
564
+
565
+ ```
566
+ /etc/puppetlabs/r10k/environments.d
567
+ ├── production.yaml
568
+ └── development.yaml
569
+ ```
570
+
571
+ The contents of the file should be a hash specifying the enviornment type, and all other applicable environment options.
572
+
573
+ ```yaml
574
+ # production.yaml
575
+ ---
576
+ type: git
577
+ remote: git@github.com:puppetlabs/control-repo.git
578
+ ref: 8820892
579
+ ```
580
+
581
+ ### Environment Modules
582
+
583
+ The environment modules feature allows module content to be attached to an environment at environment definition time. This happens before modules specified in a Puppetfile are attached to an environment, which does not happen until deploy time. Environment module implementation depends on the environment source type.
584
+
585
+ For the YAML environment source type, attach modules to an environment by specifying a modules key for the environment, and providing a hash of modules to attach. Each module accepts the same arguments accepted by the `mod` method in a Puppetfile.
586
+
587
+ The example below includes two Forge modules and one module sourced from a Git repository. The two environments are almost identical. However, a new version of the stdlib module has been deployed in development (6.2.0), that has not yet been deployed to production.
588
+
589
+ ```yaml
590
+ ---
591
+ production:
592
+ type: git
593
+ remote: git@github.com:puppetlabs/control-repo.git
594
+ ref: 8820892
595
+ modules:
596
+ puppetlabs-stdlib: 6.0.0
597
+ puppetlabs-concat: 6.1.0
598
+ reidmv-xampl:
599
+ git: https://github.com/reidmv/reidmv-xampl.git
600
+ ref: 62d07f2
601
+
602
+ development:
603
+ type: git
604
+ remote: git@github.com:puppetlabs/control-repo.git
605
+ ref: 8820892
606
+ modules:
607
+ puppetlabs-stdlib: 6.2.0
608
+ puppetlabs-concat: 6.1.0
609
+ reidmv-xampl:
610
+ git: https://github.com/reidmv/reidmv-xampl.git
611
+ ref: 62d07f2
612
+ ```
613
+
614
+ An example of a single environment definition for the YAMLdir environment source type:
615
+
616
+ ```yaml
617
+ # production.yaml
618
+ ---
619
+ type: git
620
+ remote: git@github.com:puppetlabs/control-repo.git
621
+ ref: 8820892
622
+ modules:
623
+ puppetlabs-stdlib: 6.0.0
624
+ puppetlabs-concat: 6.1.0
625
+ reidmv-xampl:
626
+ git: https://github.com/reidmv/reidmv-xampl.git
627
+ ref: 62d07f2
628
+ ```
629
+
630
+ ### Bare Environment Type
631
+
632
+ A "control repository" typically contains a hiera.yaml, an environment.conf, a manifests/site.pp file, and a few other things. However, none of these are strictly necessary for an environment to be functional if modules can be deployed to it.
633
+
634
+ The bare environment type allows sources that support environment modules to operate without a control repo being required. Modules can be deployed directly.
635
+
636
+ ```yaml
637
+ ---
638
+ production:
639
+ type: bare
640
+ modules:
641
+ puppetlabs-stdlib: 6.0.0
642
+ puppetlabs-concat: 6.1.0
643
+ reidmv-xampl:
644
+ git: https://github.com/reidmv/reidmv-xampl.git
645
+ ref: 62d07f2
646
+
647
+ development:
648
+ type: bare
649
+ modules:
650
+ puppetlabs-stdlib: 6.0.0
651
+ puppetlabs-concat: 6.1.0
652
+ reidmv-xampl:
653
+ git: https://github.com/reidmv/reidmv-xampl.git
654
+ ref: 62d07f2
655
+ ```
@@ -6,13 +6,21 @@ build_date := $(shell date -u +%FT%T)
6
6
  hadolint_available := $(shell hadolint --help > /dev/null 2>&1; echo $$?)
7
7
  hadolint_command := hadolint --ignore DL3008 --ignore DL3018 --ignore DL3028 --ignore DL4000 --ignore DL4001
8
8
  hadolint_container := hadolint/hadolint:latest
9
- pwd := $(shell pwd)
10
- export BUNDLE_PATH = $(pwd)/.bundle/gems
11
- export BUNDLE_BIN = $(pwd)/.bundle/bin
12
- export GEMFILE = $(pwd)/Gemfile
9
+ export BUNDLE_PATH = $(PWD)/.bundle/gems
10
+ export BUNDLE_BIN = $(PWD)/.bundle/bin
11
+ export GEMFILE = $(PWD)/Gemfile
13
12
 
14
- version := $(shell command grep VERSION ../lib/r10k/version.rb | awk '{print $$3}' | sed "s/'//g")
15
- dockerfile := Dockerfile
13
+ ifeq ($(IS_RELEASE),true)
14
+ VERSION ?= $(shell echo $(git_describe) | sed 's/-.*//')
15
+ LATEST_VERSION ?= latest
16
+ dockerfile := release.Dockerfile
17
+ dockerfile_context := r10k
18
+ else
19
+ VERSION ?= edge
20
+ IS_LATEST := false
21
+ dockerfile := Dockerfile
22
+ dockerfile_context := $(PWD)/..
23
+ endif
16
24
 
17
25
  prep:
18
26
  @git fetch --unshallow 2> /dev/null ||:
@@ -27,37 +35,37 @@ else
27
35
  endif
28
36
 
29
37
  build: prep
30
- @docker build \
38
+ docker build \
31
39
  --pull \
32
40
  --build-arg vcs_ref=$(vcs_ref) \
33
41
  --build-arg build_date=$(build_date) \
34
- --build-arg version=$(version) \
42
+ --build-arg version=$(VERSION) \
35
43
  --build-arg pupperware_analytics_stream=$(PUPPERWARE_ANALYTICS_STREAM) \
36
44
  --file r10k/$(dockerfile) \
37
- --tag $(NAMESPACE)/r10k:$(version) $(pwd)/..
45
+ --tag $(NAMESPACE)/r10k:$(VERSION) $(dockerfile_context)
38
46
  ifeq ($(IS_LATEST),true)
39
- @docker tag $(NAMESPACE)/r10k:$(version) puppet/r10k:latest
47
+ @docker tag $(NAMESPACE)/r10k:$(VERSION) puppet/r10k:$(LATEST_VERSION)
40
48
  endif
41
49
 
42
50
  test: prep
43
51
  @bundle install --path $$BUNDLE_PATH --gemfile $$GEMFILE --with test
44
52
  @bundle update
45
- @PUPPET_TEST_DOCKER_IMAGE=$(NAMESPACE)/r10k:$(version) \
53
+ @PUPPET_TEST_DOCKER_IMAGE=$(NAMESPACE)/r10k:$(VERSION) \
46
54
  bundle exec --gemfile $$GEMFILE \
47
55
  rspec spec
48
56
 
49
57
  push-image: prep
50
- @docker push $(NAMESPACE)/r10k:$(version)
58
+ @docker push $(NAMESPACE)/r10k:$(VERSION)
51
59
  ifeq ($(IS_LATEST),true)
52
- @docker push $(NAMESPACE)/r10k:latest
60
+ @docker push $(NAMESPACE)/r10k:$(LATEST_VERSION)
53
61
  endif
54
62
 
55
63
  push-readme:
56
64
  @docker pull sheogorath/readme-to-dockerhub
57
65
  @docker run --rm \
58
66
  -v $(PWD)/README.md:/data/README.md \
59
- -e DOCKERHUB_USERNAME="$(DISTELLI_DOCKER_USERNAME)" \
60
- -e DOCKERHUB_PASSWORD="$(DISTELLI_DOCKER_PW)" \
67
+ -e DOCKERHUB_USERNAME="$(DOCKERHUB_USERNAME)" \
68
+ -e DOCKERHUB_PASSWORD="$(DOCKERHUB_PASSWORD)" \
61
69
  -e DOCKERHUB_REPO_PREFIX=puppet \
62
70
  -e DOCKERHUB_REPO_NAME=r10k \
63
71
  sheogorath/readme-to-dockerhub
@@ -1,7 +1,7 @@
1
1
  FROM alpine:3.9 as build
2
2
 
3
- RUN apk add --no-cache ruby git
4
- RUN mkdir /workspace
3
+ RUN apk add --no-cache ruby git && \
4
+ mkdir /workspace
5
5
  WORKDIR /workspace
6
6
  COPY . /workspace
7
7
  RUN gem build r10k.gemspec && \
@@ -15,32 +15,40 @@ ARG version="3.1.0"
15
15
  # Used by entrypoint to submit metrics to Google Analytics.
16
16
  # Published images should use "production" for this build_arg.
17
17
  ARG pupperware_analytics_stream="dev"
18
- ENV PUPPERWARE_ANALYTICS_STREAM="$pupperware_analytics_stream"
19
-
20
- ENV R10K_VERSION="$version"
21
18
 
22
19
  LABEL org.label-schema.maintainer="Puppet Release Team <release@puppet.com>" \
23
20
  org.label-schema.vendor="Puppet" \
24
21
  org.label-schema.url="https://github.com/puppetlabs/r10k" \
25
22
  org.label-schema.name="r10k" \
26
23
  org.label-schema.license="Apache-2.0" \
27
- org.label-schema.version="$R10K_VERSION" \
28
24
  org.label-schema.vcs-url="https://github.com/puppetlabs/r10k" \
29
- org.label-schema.vcs-ref="$vcs_ref" \
30
- org.label-schema.build-date="$build_date" \
31
25
  org.label-schema.schema-version="1.0" \
32
26
  org.label-schema.dockerfile="/Dockerfile"
33
27
 
34
- RUN apk add --no-cache ruby openssh-client git ruby-rugged curl ruby-dev make gcc musl-dev
35
- COPY --from=build /workspace/r10k.gem /
36
- RUN gem install --no-doc r10k.gem json etc && \
37
- rm -f r10k.gem
38
-
39
- COPY docker/r10k/docker-entrypoint.sh /
40
- RUN chmod +x /docker-entrypoint.sh
28
+ COPY docker/r10k/adduser.sh docker/r10k/docker-entrypoint.sh /
41
29
  COPY docker/r10k/docker-entrypoint.d /docker-entrypoint.d
42
30
 
43
31
  ENTRYPOINT ["/docker-entrypoint.sh"]
44
32
  CMD ["help"]
45
33
 
34
+ # dyanmic LABELs and ENV vars placed lower for the sake of Docker layer caching
35
+ ENV PUPPERWARE_ANALYTICS_STREAM="$pupperware_analytics_stream"
36
+
37
+ LABEL org.label-schema.version="$version" \
38
+ org.label-schema.vcs-ref="$vcs_ref" \
39
+ org.label-schema.build-date="$build_date"
40
+
41
+ COPY --from=build /workspace/r10k.gem /
42
+ RUN chmod a+x /adduser.sh && \
43
+ # Add a puppet user to run r10k as for consistency with puppetserver
44
+ /adduser.sh && \
45
+ chmod +x /docker-entrypoint.sh && \
46
+ chown -R puppet: /docker-entrypoint.d /docker-entrypoint.sh && \
47
+ apk add --no-cache ruby openssh-client git ruby-rugged curl ruby-dev make gcc musl-dev && \
48
+ gem install --no-doc /r10k.gem json etc && \
49
+ rm -f /r10k.gem
50
+
51
+ USER puppet
52
+ WORKDIR /home/puppet
53
+
46
54
  COPY docker/r10k/Dockerfile /
@@ -0,0 +1,13 @@
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
@@ -11,7 +11,7 @@ tid=UA-132486246-5
11
11
  # Application Name
12
12
  an=r10k
13
13
  # Application Version
14
- av=$R10K_VERSION
14
+ av=$(r10k version | cut -d ' ' -f 2)
15
15
  # Anonymous Client ID
16
16
  _file=/var/tmp/pwclientid
17
17
  cid=$(cat $_file 2>/dev/null || (cat /proc/sys/kernel/random/uuid | tee $_file))
@@ -0,0 +1,36 @@
1
+ FROM alpine:3.9
2
+
3
+ ARG vcs_ref
4
+ ARG build_date
5
+ ARG version="3.1.0"
6
+ # Used by entrypoint to submit metrics to Google Analytics.
7
+ # Published images should use "production" for this build_arg.
8
+ ARG pupperware_analytics_stream="dev"
9
+
10
+ LABEL org.label-schema.maintainer="Puppet Release Team <release@puppet.com>" \
11
+ org.label-schema.vendor="Puppet" \
12
+ org.label-schema.url="https://github.com/puppetlabs/r10k" \
13
+ org.label-schema.name="r10k" \
14
+ org.label-schema.license="Apache-2.0" \
15
+ org.label-schema.vcs-url="https://github.com/puppetlabs/r10k" \
16
+ org.label-schema.schema-version="1.0" \
17
+ org.label-schema.dockerfile="/release.Dockerfile"
18
+
19
+ COPY docker-entrypoint.sh /
20
+ COPY docker-entrypoint.d /docker-entrypoint.d
21
+
22
+ ENTRYPOINT ["/docker-entrypoint.sh"]
23
+ CMD ["help"]
24
+
25
+ # dyanmic LABELs and ENV vars placed lower for the sake of Docker layer caching
26
+ ENV PUPPERWARE_ANALYTICS_STREAM="$pupperware_analytics_stream"
27
+
28
+ LABEL org.label-schema.version="$version" \
29
+ org.label-schema.vcs-ref="$vcs_ref" \
30
+ org.label-schema.build-date="$build_date"
31
+
32
+ RUN chmod +x /docker-entrypoint.sh && \
33
+ apk add --no-cache ruby openssh-client git ruby-rugged curl ruby-dev make gcc musl-dev && \
34
+ gem install --no-doc r10k:"$version" json etc
35
+
36
+ COPY release.Dockerfile /