release_manager 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.bash_profile +27 -0
- data/.dockerignore +1 -0
- data/.env +3 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/CHANGELOG.md +55 -0
- data/Dockerfile +14 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +72 -0
- data/LICENSE.txt +21 -0
- data/README.md +311 -0
- data/Rakefile +6 -0
- data/app_startup_script.sh +4 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docker-compose.yml +37 -0
- data/exe/bump-changelog +5 -0
- data/exe/deploy-mod +5 -0
- data/exe/release-mod +5 -0
- data/exe/sandbox-create +13 -0
- data/lib/release_manager.rb +33 -0
- data/lib/release_manager/changelog.rb +130 -0
- data/lib/release_manager/cli/deploy_mod_cli.rb +44 -0
- data/lib/release_manager/cli/release_mod_cli.rb +43 -0
- data/lib/release_manager/cli/sandbox_create_cli.rb +138 -0
- data/lib/release_manager/control_mod.rb +83 -0
- data/lib/release_manager/control_repo.rb +35 -0
- data/lib/release_manager/errors.rb +13 -0
- data/lib/release_manager/git/credentials.rb +98 -0
- data/lib/release_manager/git/utilites.rb +263 -0
- data/lib/release_manager/logger.rb +52 -0
- data/lib/release_manager/module_deployer.rb +77 -0
- data/lib/release_manager/puppet_module.rb +211 -0
- data/lib/release_manager/puppetfile.rb +148 -0
- data/lib/release_manager/release.rb +174 -0
- data/lib/release_manager/sandbox.rb +272 -0
- data/lib/release_manager/vcs_manager.rb +22 -0
- data/lib/release_manager/vcs_manager/gitlab_adapter.rb +112 -0
- data/lib/release_manager/vcs_manager/vcs_adapter.rb +22 -0
- data/lib/release_manager/version.rb +3 -0
- data/lib/release_manager/workflow_action.rb +5 -0
- data/release_manager.gemspec +38 -0
- data/setup_repos.rb +95 -0
- metadata +175 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 29e40c47ad25725e971c4fd352be640e3c099aa1
|
4
|
+
data.tar.gz: 262a70fdf287925fca29d271163b5b13a0681225
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8abb760003a84f0be08fcc20cd7705b238f033aa9c5a0eece9d73c60b5b1514e0ad5ec3b96e7439414cd5cf07faef492a6fa82ec6818b7a8d9f2e9a29880382e
|
7
|
+
data.tar.gz: f44e93faaa946b2732adb4654db2a37f85539d6a395d697961fe52a55926ea83ab54d86c3043d45e2b643da6f240ae25df330cd84cca4615ea3468b6045b53da
|
data/.bash_profile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
#
|
3
|
+
# setup ssh-agent
|
4
|
+
#
|
5
|
+
export PATH=~/.gems/bin:$PATH
|
6
|
+
|
7
|
+
# set environment variables if user's agent already exists
|
8
|
+
[ -z "$SSH_AUTH_SOCK" ] && SSH_AUTH_SOCK=$(ls -l /tmp/ssh-*/agent.* 2> /dev/null | grep $(whoami) | awk '{print $9}')
|
9
|
+
[ -z "$SSH_AGENT_PID" -a -z `echo $SSH_AUTH_SOCK | cut -d. -f2` ] && SSH_AGENT_PID=$((`echo $SSH_AUTH_SOCK | cut -d. -f2` + 1))
|
10
|
+
[ -n "$SSH_AUTH_SOCK" ] && export SSH_AUTH_SOCK
|
11
|
+
[ -n "$SSH_AGENT_PID" ] && export SSH_AGENT_PID
|
12
|
+
|
13
|
+
# start agent if necessary
|
14
|
+
if [ -z $SSH_AGENT_PID ] && [ -z $SSH_TTY ]; then # if no agent & not in ssh
|
15
|
+
eval `ssh-agent -s` > /dev/null
|
16
|
+
fi
|
17
|
+
|
18
|
+
# setup addition of keys when needed
|
19
|
+
if [ -z "$SSH_TTY" ] ; then # if not using ssh
|
20
|
+
ssh-add -l > /dev/null # check for keys
|
21
|
+
if [ $? -ne 0 ] ; then
|
22
|
+
alias ssh='ssh-add -l > /dev/null || ssh-add && unalias ssh ; ssh'
|
23
|
+
if [ -f "/usr/lib/ssh/x11-ssh-askpass" ] ; then
|
24
|
+
SSH_ASKPASS="/usr/lib/ssh/x11-ssh-askpass" ; export SSH_ASKPASS
|
25
|
+
fi
|
26
|
+
fi
|
27
|
+
fi
|
data/.dockerignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.bundle
|
data/.env
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Release Manager
|
2
|
+
## Unreleased
|
3
|
+
|
4
|
+
## v0.3.0
|
5
|
+
* Fixes color with fatal errors
|
6
|
+
* Changes PuppetModule to use rugged commit commands
|
7
|
+
* Auto corrects bad source attribute with metadata.json
|
8
|
+
* Adds new methods to git utilities
|
9
|
+
* Fixes error when fetching remotes that do not exist
|
10
|
+
* Fixes issue where pushing of remotes via url failed
|
11
|
+
* Adds automatic fetching or remote before creating branch from remote
|
12
|
+
* Fixes #11 - Add output during dry run for deploy-mod
|
13
|
+
## v0.2.4
|
14
|
+
* Fixes puppetfile not return instance of controlmod
|
15
|
+
## v0.2.3
|
16
|
+
* Allows the user to add new modules when they don't already exist
|
17
|
+
* Sets the upstream url based on the module source defined in metadata
|
18
|
+
## v0.2.2
|
19
|
+
* Fixes issue when existing branch exists on remote but not local
|
20
|
+
* improves docker setup
|
21
|
+
* Fixes issue where module branch was not pushed
|
22
|
+
## v0.2.1
|
23
|
+
* Improves docker setup
|
24
|
+
* Removes ability to push upon deploying module
|
25
|
+
* Fixes issue with git source not updating when deploying module
|
26
|
+
* Refactors cli into individual files
|
27
|
+
* Removes checking of modules before sandbox creation
|
28
|
+
|
29
|
+
## v0.2.0
|
30
|
+
* adds the ability to auto generate a complete r10k sandbox
|
31
|
+
* adds gitlab adapter
|
32
|
+
* adds rugged git dependency
|
33
|
+
## v0.1.8
|
34
|
+
* Fix pinning of version to puppetfile
|
35
|
+
* adds more testing
|
36
|
+
|
37
|
+
## v0.1.7
|
38
|
+
* Adds more tests
|
39
|
+
* Fixes typos
|
40
|
+
* Fixes issue with push and commit during deployment
|
41
|
+
* Fixes stack level issue when calling upstream
|
42
|
+
* Adds ability to easily add upstream remote
|
43
|
+
## v0.1.6
|
44
|
+
* add dry run to deploy-mod
|
45
|
+
|
46
|
+
## v0.1.5
|
47
|
+
* Fixes an issue where the latest tag was not being selected correctly
|
48
|
+
|
49
|
+
## v0.1.4
|
50
|
+
* Fixes #8 - upstream does not exist
|
51
|
+
* Fixes #9 - bump changelog assumes changelog exists
|
52
|
+
* Fixes #10 - executable scripts should communicate options more clearly
|
53
|
+
|
54
|
+
## v0.1.0
|
55
|
+
* initial implementation
|
data/Dockerfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
FROM ruby:2.3.4
|
2
|
+
RUN apt-get update && apt-get install -y libssh2-1-dev tree git zsh libssh2-1 vim cmake && apt-get clean
|
3
|
+
RUN useradd -m appuser && su - appuser -c 'ssh-keygen -t rsa -N "password" -f /home/appuser/.ssh/id_rsa' && mkdir /app \
|
4
|
+
&& chown appuser:appuser /app
|
5
|
+
COPY ./Gemfile* /app/
|
6
|
+
COPY .bash_profile /home/appuser/.bash_profile
|
7
|
+
RUN su - appuser -c 'git config --global user.email "user@example.com"' && \
|
8
|
+
su - appuser -c 'git config --global user.name "Example User"' && \
|
9
|
+
chown -R appuser:appuser /home/appuser/ && \
|
10
|
+
chown -R appuser:appuser /app
|
11
|
+
RUN su - appuser -c "BUNDLE_PATH='/home/appuser/.bundle' GEM_HOME='/home/appuser/.gems' bundle install --gemfile=/app/Gemfile" \
|
12
|
+
&& rm -f /app/*
|
13
|
+
# update PATH to find local gems
|
14
|
+
USER appuser
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source ENV['GEM_SOURCE'] ||'https://rubygems.org'
|
2
|
+
# Specify your gem's dependencies in release_manager.gemspec
|
3
|
+
gem 'gitlab', '~> 3.7.0'
|
4
|
+
gem 'rugged'
|
5
|
+
|
6
|
+
group :test do
|
7
|
+
gem 'pry'
|
8
|
+
gem 'rubocop'
|
9
|
+
gem 'rake'
|
10
|
+
gem 'rspec'
|
11
|
+
gem 'bundler'
|
12
|
+
# when docker compiles this it cannot find release manager until we mount the volume
|
13
|
+
gem 'release_manager', path: '.' if File.exists?(File.join('release_manager.gemspec'))
|
14
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
release_manager (0.3.0)
|
5
|
+
gitlab (~> 3.7.0)
|
6
|
+
rugged
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
ast (2.3.0)
|
12
|
+
coderay (1.1.1)
|
13
|
+
diff-lcs (1.3)
|
14
|
+
gitlab (3.7.0)
|
15
|
+
httparty (~> 0.13.0)
|
16
|
+
terminal-table
|
17
|
+
httparty (0.13.7)
|
18
|
+
json (~> 1.8)
|
19
|
+
multi_xml (>= 0.5.2)
|
20
|
+
json (1.8.6)
|
21
|
+
method_source (0.8.2)
|
22
|
+
multi_xml (0.6.0)
|
23
|
+
parser (2.4.0.0)
|
24
|
+
ast (~> 2.2)
|
25
|
+
powerpack (0.1.1)
|
26
|
+
pry (0.10.4)
|
27
|
+
coderay (~> 1.1.0)
|
28
|
+
method_source (~> 0.8.1)
|
29
|
+
slop (~> 3.4)
|
30
|
+
rainbow (2.2.1)
|
31
|
+
rake (10.5.0)
|
32
|
+
rspec (3.5.0)
|
33
|
+
rspec-core (~> 3.5.0)
|
34
|
+
rspec-expectations (~> 3.5.0)
|
35
|
+
rspec-mocks (~> 3.5.0)
|
36
|
+
rspec-core (3.5.4)
|
37
|
+
rspec-support (~> 3.5.0)
|
38
|
+
rspec-expectations (3.5.0)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.5.0)
|
41
|
+
rspec-mocks (3.5.0)
|
42
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
+
rspec-support (~> 3.5.0)
|
44
|
+
rspec-support (3.5.0)
|
45
|
+
rubocop (0.48.1)
|
46
|
+
parser (>= 2.3.3.1, < 3.0)
|
47
|
+
powerpack (~> 0.1)
|
48
|
+
rainbow (>= 1.99.1, < 3.0)
|
49
|
+
ruby-progressbar (~> 1.7)
|
50
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
51
|
+
ruby-progressbar (1.8.1)
|
52
|
+
rugged (0.25.1.1)
|
53
|
+
slop (3.6.0)
|
54
|
+
terminal-table (1.7.3)
|
55
|
+
unicode-display_width (~> 1.1.1)
|
56
|
+
unicode-display_width (1.1.3)
|
57
|
+
|
58
|
+
PLATFORMS
|
59
|
+
ruby
|
60
|
+
|
61
|
+
DEPENDENCIES
|
62
|
+
bundler
|
63
|
+
gitlab (~> 3.7.0)
|
64
|
+
pry
|
65
|
+
rake
|
66
|
+
release_manager!
|
67
|
+
rspec
|
68
|
+
rubocop
|
69
|
+
rugged
|
70
|
+
|
71
|
+
BUNDLED WITH
|
72
|
+
1.14.6
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Corey Osman
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,311 @@
|
|
1
|
+
```shell
|
2
|
+
|
3
|
+
__________ .__ _____
|
4
|
+
\______ \ ____ | | ____ _____ ______ ____ / \ _____ ____ _____ ____ ___________
|
5
|
+
| _// __ \| | _/ __ \\__ \ / ___// __ \ / \ / \\__ \ / \\__ \ / ___\_/ __ \_ __ \
|
6
|
+
| | \ ___/| |_\ ___/ / __ \_\___ \\ ___/ / Y \/ __ \| | \/ __ \_/ /_/ > ___/| | \/
|
7
|
+
|____|_ /\___ >____/\___ >____ /____ >\___ > \____|__ (____ /___| (____ /\___ / \___ >__|
|
8
|
+
\/ \/ \/ \/ \/ \/ \/ \/ \/ \//_____/ \/
|
9
|
+
```
|
10
|
+
|
11
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
12
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
13
|
+
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
|
14
|
+
|
15
|
+
- [ReleaseManager](#releasemanager)
|
16
|
+
- [Installation](#installation)
|
17
|
+
- [Install directly from source](#install-directly-from-source)
|
18
|
+
- [The workflow problem](#the-workflow-problem)
|
19
|
+
- [R10k Sandbox Creation Steps (the hard way)](#r10k-sandbox-creation-steps-the-hard-way)
|
20
|
+
- [R10k Sandbox Creation steps (the easy way)](#r10k-sandbox-creation-steps-the-easy-way)
|
21
|
+
- [Usage](#usage)
|
22
|
+
- [sandbox-create](#sandbox-create)
|
23
|
+
- [release-mod](#release-mod)
|
24
|
+
- [deploy-mod](#deploy-mod)
|
25
|
+
- [bump-changelog](#bump-changelog)
|
26
|
+
- [Configuration Settings](#configuration-settings)
|
27
|
+
- [Sandbox-create environment variables](#sandbox-create-environment-variables)
|
28
|
+
- [Development](#development)
|
29
|
+
- [Contributing](#contributing)
|
30
|
+
- [License](#license)
|
31
|
+
|
32
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
33
|
+
|
34
|
+
# ReleaseManager
|
35
|
+
|
36
|
+
This gem provides workflow automations around releasing and deploying puppet modules within r10k environments.
|
37
|
+
|
38
|
+
## Installation
|
39
|
+
|
40
|
+
Add this line to your application's Gemfile:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
gem 'release_manager'
|
44
|
+
```
|
45
|
+
|
46
|
+
And then execute:
|
47
|
+
|
48
|
+
$ bundle
|
49
|
+
|
50
|
+
Or install it yourself as:
|
51
|
+
|
52
|
+
$ gem install release_manager
|
53
|
+
|
54
|
+
### Install directly from source
|
55
|
+
If you don't have access to a gem server you can use the `specific_install` gem. This will install the latest version
|
56
|
+
directly from source.
|
57
|
+
|
58
|
+
```
|
59
|
+
gem install specific_install # unless already installed
|
60
|
+
gem specific_install <git url to release manager>
|
61
|
+
|
62
|
+
ie. gem specific_install git@github.com/nwops/release_manager.git
|
63
|
+
```
|
64
|
+
|
65
|
+
|
66
|
+
## The workflow problem
|
67
|
+
R10k allows us to create a puppet environment for each branch on the r10k-control repository. This makes isolating code deployments
|
68
|
+
simple to use because each branch corresponds to a puppet environment. However, this workflow implies that you will fork
|
69
|
+
all the modules you work on and create branches on those forks. Additionally, you then need to update the r10k-control Puppetfile
|
70
|
+
to use those new branches and forks. This can be a huge burden and consume some of your time. Below is an example of that workflow.
|
71
|
+
|
72
|
+
### R10k Sandbox Creation Steps (the hard way)
|
73
|
+
1. fork r10k-control
|
74
|
+
2. clone r10k-control fork
|
75
|
+
3. create new branch called my_sandbox on r10k-control fork
|
76
|
+
4. Decide which module(s) you need to work on (ie. roles, profiles, sqlserver) for a given sandbox (branch)
|
77
|
+
5. Fork the roles repo
|
78
|
+
6. Fork the profiles repo
|
79
|
+
7. Fork the sqlserver repo
|
80
|
+
8. Clone all three of the forked repos above
|
81
|
+
9. Create a branch called my_sandbox on each of the repos above
|
82
|
+
10. Update the puppetfile in r10k-control to use your fork and branch for each module above
|
83
|
+
11. Commit the puppetfile
|
84
|
+
12. Push the commit to the r10k-control
|
85
|
+
13. Add the upstream remote for all of the repos you just cloned
|
86
|
+
14. Add members to your forked projects
|
87
|
+
15. push new branch on each forked project
|
88
|
+
|
89
|
+
Yikes! This is a long list of things to do. It is human nature to skip some or all of these steps to save time even though
|
90
|
+
it is in our best interest to follow these steps. As humans we will always resort to the path of least resistance.
|
91
|
+
|
92
|
+
In an effort to force good practices and reduce time and effort, release-manager will automate almost all of the tasks into
|
93
|
+
a single command called `sandbox-create`.
|
94
|
+
|
95
|
+
Additionally there are other commands that help with the release and deploy process of modules to the r10k-control repository.
|
96
|
+
|
97
|
+
### R10k Sandbox Creation steps (the easy way)
|
98
|
+
`sandbox-create -n my_sandbox --modules='roles,profiles,hieradata,sqlserver'`
|
99
|
+
|
100
|
+
## Usage
|
101
|
+
|
102
|
+
Release manager provides the following commands to help you create sandboxes, release and deploy puppet code.
|
103
|
+
|
104
|
+
### sandbox-create
|
105
|
+
The sandbox-create command wraps all the git, git cloning, and git forking tasks into a single command. Usage of this command
|
106
|
+
will save you a great deal of time upon each run.
|
107
|
+
|
108
|
+
Please note: this requires the usage of [ssh-agent](#ssh-agent-usage).
|
109
|
+
|
110
|
+
|
111
|
+
```
|
112
|
+
Usage: sandbox-create [options]
|
113
|
+
|
114
|
+
Summary: Creates a new r10k sandbox by forking and creating a new branch on r10k-control,
|
115
|
+
creates a fork and branch for each module passed in, adds the upstream remote
|
116
|
+
for each module, updates the r10k-control Puppetfile to use those forks and branches
|
117
|
+
and pushes the branch to the upstream r10k-control.
|
118
|
+
|
119
|
+
Example: sandbox-create -n my_sandbox -m "roles,profiles,developer"
|
120
|
+
Example: sandbox-create -n my_sandbox -m "roles,profiles,developer" --members="p1dksk2, p2ksdafs,devops,ci_runner"
|
121
|
+
|
122
|
+
|
123
|
+
Note: If you already have any of these modules cloned, this script will attempt to update those modules
|
124
|
+
using git fetch and git checkout -b sandbox_name upstream/master. So this should not destroy anything.
|
125
|
+
|
126
|
+
--members DEFAULT_MEMBERS A comman seperated list of members to add to forked projects
|
127
|
+
-n, --name NAME The name of your sandbox
|
128
|
+
--control-url R10K_REPO_URL git url to the r10k-control repo, defaults to R10K_CONTROL_URL env variable
|
129
|
+
-m, --modules MODULES A comma separated list of modules names from the Puppetfile to fork and branch
|
130
|
+
-r, --repos-dir [REPOS_PATH] The repos path to clone modules to. Defaults to: /home/appuser/repos
|
131
|
+
-c, --control-dir [CONTROL_DIR] The r10k-control repo path. Defaults to: /home/appuser/repos/r10k-control
|
132
|
+
--verbose Extra logging
|
133
|
+
|
134
|
+
|
135
|
+
```
|
136
|
+
|
137
|
+
Example Run
|
138
|
+
|
139
|
+
```shell
|
140
|
+
appuser@28523330e507:/app$ export DEFAULT_MODULES=gitlab
|
141
|
+
appuser@28523330e507:/app$ export DEFAULT_MEMBERS=r10k_user,ci_runner
|
142
|
+
appuser@28523330e507:/app$ sandbox-create -n sdafsd -m r10k
|
143
|
+
|
144
|
+
INFO - ReleaseManager: Resetting upstream remote to git@web:cosman/control-repo.git for /home/appuser/repos/r10k-control
|
145
|
+
INFO - ReleaseManager: Fetching upstream from git@web:cosman/control-repo.git
|
146
|
+
INFO - ReleaseManager: Resetting upstream remote to git@web:devops/control-repo.git for /home/appuser/repos/r10k-control
|
147
|
+
INFO - ReleaseManager: Fetching upstream from git@web:devops/control-repo.git
|
148
|
+
INFO - ReleaseManager: Checking out branch: upstream/dev for /home/appuser/repos/r10k-control
|
149
|
+
INFO - ReleaseManager: Fetching upstream from git@web:cosman/r10k.git
|
150
|
+
INFO - ReleaseManager: Fetching upstream from git@web:cosman/r10k.git
|
151
|
+
INFO - ReleaseManager: Updating r10k-control Puppetfile to use fork: git@web:cosman/r10k.git with branch: sdafsd
|
152
|
+
INFO - ReleaseManager: Adding member r10k_user to project cosman/puppet-gitlab
|
153
|
+
INFO - ReleaseManager: Adding member ci_runner to project cosman/puppet-gitlab
|
154
|
+
INFO - ReleaseManager: Resetting upstream remote to git@web:cosman/puppet-gitlab.git for /home/appuser/repos/gitlab
|
155
|
+
INFO - ReleaseManager: Fetching upstream from git@web:cosman/puppet-gitlab.git
|
156
|
+
INFO - ReleaseManager: Fetching upstream from git@web:cosman/puppet-gitlab.git
|
157
|
+
INFO - ReleaseManager: Updating r10k-control Puppetfile to use fork: git@web:cosman/puppet-gitlab.git with branch: sdafsd
|
158
|
+
INFO - ReleaseManager: Checking out branch: sdafsd for /home/appuser/repos/r10k-control
|
159
|
+
INFO - ReleaseManager: Committing Puppetfile changes to r10k-control branch: sdafsd
|
160
|
+
|
161
|
+
```
|
162
|
+
|
163
|
+
**Note: This script assumes you will have the following environment variables set:**
|
164
|
+
|
165
|
+
You can throw this in your .bash_profile or .zprofile and have this set automatically for each run.
|
166
|
+
|
167
|
+
Example Only:
|
168
|
+
|
169
|
+
```
|
170
|
+
export GITLAB_API_ENDPOINT='http://web/api/v3'
|
171
|
+
export GITLAB_API_PRIVATE_TOKEN='A_zJJfgE8P-8mFGK2_r9'
|
172
|
+
export R10K_REPO_URL="git@web:devops/control-repo.git"
|
173
|
+
|
174
|
+
```
|
175
|
+
|
176
|
+
### release-mod
|
177
|
+
The `release-mod` command will help you release new module and r10k-control repo code by doing the following
|
178
|
+
1. increment the version in the metadata.json file version field
|
179
|
+
2. increment the version in the changelog file
|
180
|
+
3. create a commit with the above changes
|
181
|
+
4. create a git tag with the name as the version ie. v0.1.4
|
182
|
+
5. push the changes and tag to the upstream repo using the metadata.json's source field
|
183
|
+
|
184
|
+
```
|
185
|
+
Usage: release-mod [options]
|
186
|
+
|
187
|
+
Summary: Bumps the module version to the next revision and
|
188
|
+
updates the changelog.md file with the new
|
189
|
+
version by reading the metadata.json file. This should
|
190
|
+
be run inside a module directory.
|
191
|
+
|
192
|
+
-d, --dry-run Do a dry run, without making changes
|
193
|
+
-a, --auto Run this script without interaction
|
194
|
+
-m, --module-path The path to the module, defaults to current working directory
|
195
|
+
-b, --no-bump Do not bump the version in metadata.json
|
196
|
+
-r, --repo [REPO] The repo to use, defaults to repo found in the metadata source
|
197
|
+
--verbose Extra logging
|
198
|
+
```
|
199
|
+
|
200
|
+
### deploy-mod
|
201
|
+
The `deploy-mod` command assists you with updating an r10k environment with the new module version by doing the following.
|
202
|
+
1. search the r10k-control repo's Puppetfile for a module with a similar name of the current module
|
203
|
+
2. removes the branch or ref argument from the "mod" declaration
|
204
|
+
3. adds a tag argument with the latest version defined in the module's metadata.json file.
|
205
|
+
|
206
|
+
You can also optionally pass in the `--commmit` flag to create a commit.
|
207
|
+
|
208
|
+
Additonally if you wish to push the current branch you can also
|
209
|
+
pass in the `--push` and `--remote r10k-control` option.
|
210
|
+
|
211
|
+
```
|
212
|
+
Usage: deploy-mod [options]
|
213
|
+
|
214
|
+
Summary: Gets the version of your module found in the metadata
|
215
|
+
and populates the r10k-control Puppetfile with the updated
|
216
|
+
tag version. Revmoes any branch or ref reference and replaces
|
217
|
+
with tag. Currently it is up to you to commit and push the Puppetfile change.
|
218
|
+
|
219
|
+
-p, --puppetfile PUPPETFILE Path to R10k Puppetfile, defaults to ~/repos/r10k-control/Puppetfile
|
220
|
+
-m, --modulepath MODULEPATH Path to to module, defaults to: /home/p1cxom2/repos/release_manager
|
221
|
+
-c, --commit Commit the Puppetfile change
|
222
|
+
-u, --push Push the changes to the remote
|
223
|
+
-r, --remote REMOTE Remote name or url to push changes to
|
224
|
+
```
|
225
|
+
|
226
|
+
### bump-changelog
|
227
|
+
The `bump-changelog` command simply changes 'Unreleased' section with the version string found the in the module's metadata file
|
228
|
+
and creates a new 'Unrelease Section on top
|
229
|
+
1. increment version in changelog
|
230
|
+
2. create commit with change
|
231
|
+
|
232
|
+
If using the `release-mod` command there is no need to run the `bump-changelog`command as it is part of the process already.
|
233
|
+
|
234
|
+
|
235
|
+
## Configuration Settings
|
236
|
+
The following environment variables will automatically set required parameters and defaults. It is suggested you put
|
237
|
+
this in your shell script like .bash_profile or .zprofile
|
238
|
+
|
239
|
+
### Sandbox-create environment variables
|
240
|
+
|
241
|
+
GITLAB_API_ENDPOINT - The api path to the gitlab server (ie. https://gitlab.com/api/v3)
|
242
|
+
|
243
|
+
GITLAB_API_PRIVATE_TOKEN - The gitlab user api token
|
244
|
+
|
245
|
+
DEFAULT_MODULES - The default set of modules to use when creating a sandbox (ie. hieradata)
|
246
|
+
|
247
|
+
R10K_REPO_URL - The git repo url to r10k-control (ie. git@gitlab.com:nwops/r10k-control.git)
|
248
|
+
|
249
|
+
DEFAULT_MEMBERS - The default members each forked project should add permissions to (ie, 'ci_runner', 'r10k_user')
|
250
|
+
|
251
|
+
## Ssh agent usage
|
252
|
+
In order to use sandbox-create you need to ensure you have ssh-agent running in the background and the following
|
253
|
+
environment variables are exported. In some cases you might have this automated via a shell login script.
|
254
|
+
|
255
|
+
* SSH_AUTH_SOCK
|
256
|
+
* SSH_AGENT_PID
|
257
|
+
|
258
|
+
Automated usage
|
259
|
+
|
260
|
+
```
|
261
|
+
#!/usr/bin/env bash
|
262
|
+
#
|
263
|
+
# setup ssh-agent
|
264
|
+
#
|
265
|
+
# set environment variables if user's agent already exists
|
266
|
+
[ -z "$SSH_AUTH_SOCK" ] && SSH_AUTH_SOCK=$(ls -l /tmp/ssh-*/agent.* 2> /dev/null | grep $(whoami) | awk '{print $9}')
|
267
|
+
[ -z "$SSH_AGENT_PID" -a -z `echo $SSH_AUTH_SOCK | cut -d. -f2` ] && SSH_AGENT_PID=$((`echo $SSH_AUTH_SOCK | cut -d. -f2` + 1))
|
268
|
+
[ -n "$SSH_AUTH_SOCK" ] && export SSH_AUTH_SOCK
|
269
|
+
[ -n "$SSH_AGENT_PID" ] && export SSH_AGENT_PID
|
270
|
+
|
271
|
+
# start agent if necessary
|
272
|
+
if [ -z $SSH_AGENT_PID ] && [ -z $SSH_TTY ]; then # if no agent & not in ssh
|
273
|
+
eval `ssh-agent -s` > /dev/null
|
274
|
+
fi
|
275
|
+
|
276
|
+
# setup addition of keys when needed
|
277
|
+
if [ -z "$SSH_TTY" ] ; then # if not using ssh
|
278
|
+
ssh-add -l > /dev/null # check for keys
|
279
|
+
if [ $? -ne 0 ] ; then
|
280
|
+
alias ssh='ssh-add -l > /dev/null || ssh-add && unalias ssh ; ssh'
|
281
|
+
if [ -f "/usr/lib/ssh/x11-ssh-askpass" ] ; then
|
282
|
+
SSH_ASKPASS="/usr/lib/ssh/x11-ssh-askpass" ; export SSH_ASKPASS
|
283
|
+
fi
|
284
|
+
fi
|
285
|
+
fi
|
286
|
+
|
287
|
+
```
|
288
|
+
Manual Usage
|
289
|
+
|
290
|
+
```
|
291
|
+
ssh-agent bash
|
292
|
+
ssh-add
|
293
|
+
# this should prompt for password if your ssh key is protected
|
294
|
+
|
295
|
+
```
|
296
|
+
|
297
|
+
## Development
|
298
|
+
|
299
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
300
|
+
|
301
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
302
|
+
|
303
|
+
## Contributing
|
304
|
+
|
305
|
+
Bug reports and pull requests are welcome on release_manager.
|
306
|
+
|
307
|
+
|
308
|
+
## License
|
309
|
+
|
310
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
311
|
+
|