Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
212 changed files
with
18,921 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,78 @@ | ||
# GitLab CI configuration | ||
# Example for public Gitlab workflow | ||
# | ||
stages: | ||
- test | ||
- deploy | ||
- checks | ||
- specs | ||
- diffs | ||
- integration | ||
- live_runs | ||
- merge_request | ||
- promote | ||
- rollout | ||
- postcheck | ||
|
||
|
||
# Development branch | ||
syntax: | ||
stage: test | ||
stage: checks | ||
before_script: | ||
- "bin/gitlab_before.sh" | ||
script: "bin/puppet_check_syntax_fast.sh" | ||
cache: | ||
untracked: true | ||
paths: | ||
- modules/ | ||
tags: | ||
- test_puppet | ||
only: | ||
- development | ||
environment: | ||
name: development | ||
url: https://development.example.com | ||
|
||
catalog: | ||
stage: test | ||
lint: | ||
stage: checks | ||
before_script: | ||
- "bin/gitlab_before.sh" | ||
script: "bin/gitlab_catalog_diff.sh" | ||
script: "bin/puppet_lint.sh" | ||
cache: | ||
untracked: true | ||
paths: | ||
- modules/ | ||
tags: | ||
- test_puppet | ||
only: | ||
- development | ||
allow_failure: true | ||
|
||
vagrant: | ||
stage: test | ||
rake_site: | ||
stage: specs | ||
before_script: | ||
- "bin/gitlab_before.sh" | ||
script: "bin/vagrant_node_test.sh pe-centos7 pe" | ||
|
||
|
||
|
||
deploy_test: | ||
stage: deploy | ||
script: | ||
- echo "Deploy to staging server" | ||
environment: | ||
name: staging | ||
url: https://staging.example.com | ||
script: "bin/puppet_check_rake.sh site" | ||
cache: | ||
untracked: true | ||
paths: | ||
- modules/ | ||
tags: | ||
- test_puppet | ||
only: | ||
- development | ||
allow_failure: true | ||
|
||
deploy_prod: | ||
stage: deploy | ||
script: | ||
- echo "Deploy to production server" | ||
environment: | ||
name: production | ||
url: https://example.com | ||
when: manual | ||
rake_modules: | ||
stage: specs | ||
before_script: | ||
- "bin/gitlab_before.sh" | ||
script: "bin/puppet_check_rake.sh modules" | ||
cache: | ||
untracked: true | ||
paths: | ||
- modules/ | ||
tags: | ||
- test_puppet | ||
only: | ||
- production | ||
- development | ||
allow_failure: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
|
||
# Identify changes type | ||
has_danger_changes = !git.modified_files.grep(/^manifests\/.pp$|^hieradata\/common.yaml$/).empty? | ||
has_puppet_changes = !git.modified_files.grep(/.pp$/).empty? | ||
has_spec_changes = !git.modified_files.grep(/spec/).empty? | ||
is_version_bump = git.modified_files.sort == ["metadata.json", "lib/danger/version.rb"].sort | ||
|
||
# Puppet code changes without test changes | ||
if has_puppet_changes && !has_spec_changes | ||
warn("There're changes in manifests, but not tests. That's OK as long as you're refactoring existing code.", sticky: false) | ||
end | ||
|
||
# Tests changes without code changes | ||
if !has_puppet_changes && has_spec_changes | ||
message('We really puppetreciate pull requests that demonstrate issues, even without a fix. That said, the next step is to try and fix the failing tests!', sticky: false) | ||
end | ||
|
||
# Have you updated CHANGELOG.md? | ||
changelog.check | ||
|
||
# Add a CHANGELOG entry for puppet changes | ||
if !git.modified_files.include?("CHANGELOG.md") && has_puppet_changes && is_version_bump | ||
warn("Please include a CHANGELOG entry when changing version).") | ||
message "Note, we hard-wrap at 80 chars and use 2 spaces after the last line." | ||
end | ||
|
||
# Changes in files with large impact | ||
if has_danger_changes | ||
warn("This change may impact many systems. Double check what you are doing.", sticky: false) | ||
end | ||
|
||
|
||
# Ensure a clean commits history | ||
if git.commits.any? { |c| c.message =~ /^Merge branch/ } | ||
warn('Please rebase to get rid of the merge commits in this PR') | ||
end | ||
|
||
# Large PR | ||
warn('Big PR') if git.lines_of_code > @SDM_DANGER_BIG_PR_LINES | ||
|
||
|
||
# GitHub | ||
warn "PR is classed as Work in Progress" if github.pr_title.include? "[WIP]" | ||
|
||
if github.pr_body.length < 5 | ||
warn "Please provide a summary in the Pull Request description" | ||
end | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# puppet lint plugins | ||
# https://puppet.community/plugins/#puppet-lint | ||
gem 'puppet-lint-appends-check', | ||
:git => 'https://github.com/voxpupuli/puppet-lint-appends-check.git', | ||
:require => false | ||
gem 'puppet-lint-classes_and_types_beginning_with_digits-check', | ||
:git => 'https://github.com/voxpupuli/puppet-lint-classes_and_types_beginning_with_digits-check.git', | ||
:require => false | ||
gem 'puppet-lint-empty_string-check', | ||
:git => 'https://github.com/voxpupuli/puppet-lint-empty_string-check.git', | ||
:require => false | ||
gem 'puppet-lint-file_ensure-check', | ||
:git => 'https://github.com/voxpupuli/puppet-lint-file_ensure-check.git', | ||
:require => false | ||
gem 'puppet-lint-leading_zero-check', | ||
:git => 'https://github.com/voxpupuli/puppet-lint-leading_zero-check.git', | ||
:require => false | ||
gem 'puppet-lint-numericvariable', | ||
:git => 'https://github.com/fiddyspence/puppetlint-numericvariable.git', | ||
:require => false | ||
gem 'puppet-lint-resource_reference_syntax', | ||
:git => 'https://github.com/voxpupuli/puppet-lint-resource_reference_syntax.git', | ||
:require => false | ||
gem 'puppet-lint-spaceship_operator_without_tag-check', | ||
:git => 'https://github.com/voxpupuli/puppet-lint-spaceship_operator_without_tag-check.git', | ||
:require => false | ||
gem 'puppet-lint-trailing_comma-check', | ||
:git => 'https://github.com/voxpupuli/puppet-lint-trailing_comma-check.git', | ||
:require => false | ||
gem 'puppet-lint-undef_in_function-check', | ||
:git => 'https://github.com/voxpupuli/puppet-lint-undef_in_function-check.git', | ||
:require => false | ||
gem 'puppet-lint-unquoted_string-check', | ||
:git => 'https://github.com/voxpupuli/puppet-lint-unquoted_string-check.git', | ||
:require => false | ||
gem 'puppet-lint-variable_contains_upcase', | ||
:git => 'https://github.com/fiddyspence/puppetlint-variablecase.git', | ||
:require => false | ||
gem 'puppet-lint-version_comparison-check', | ||
:git => 'https://github.com/voxpupuli/puppet-lint-version_comparison-check.git', | ||
:require => false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
repo_dir="$(dirname $0)/.." | ||
. "${repo_dir}/bin/functions" | ||
|
||
env=$1 | ||
|
||
echo_title "Deployment status on ${env}" | ||
sudo cat /etc/puppetlabs/code/environments/$env/.r10k-deploy.json | ||
|
||
deployed_commit=$(sudo /usr/bin/cat /etc/puppetlabs/code/environments/$env/.r10k-deploy.json | grep signature | awk '{ print $2}' | sed -e 's/"//g' | sed -e 's/,//') | ||
echo_title "Deployed commit on Puppet Server: ${deployed_commit}" | ||
git show --no-abbrev-commit -s ${deployed_commit} | ||
|
||
local_commit=$(git rev-parse HEAD) | ||
echo_title "Latest commit on local runner repo: ${local_commit}" | ||
git show --no-abbrev-commit -s ${local_commit} | ||
|
||
if [[ "${deployed_commit}" == "${local_commit}" ]]; then | ||
echo_success "Code correctly deployed to Puppet Server" | ||
exit 0 | ||
else | ||
echo_failure "Code not correctly deployed to Puppet Server !!!" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
environment: production | ||
classes: | ||
- profile::base::pre | ||
parameters: | ||
env: development | ||
role: default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env ruby | ||
require 'gitlab' | ||
GITLAB_CONFIG='/etc/gitlab-cli.conf' | ||
config = {} | ||
File.foreach GITLAB_CONFIG do |line| | ||
k = line.split("=")[0].gsub("\n",'') if line =~/=/ | ||
v = line.split("=")[1].gsub("\n",'') if line =~/=/ | ||
config.store(k,v) | ||
end | ||
last_commit=`git log -1 --oneline` | ||
source_branch = ARGV[0] ? ARGV[0] : 'none' | ||
destination_branch = ARGV[1] ? ARGV[1] : 'master' | ||
mr_title = ARGV[2] ? ARGV[2] : "Merged: #{last_commit} from #{source_branch} to #{destination_branch}" | ||
project_id = config['GITLAB_API_PROJECT_ID'] | ||
endpoint = config['GITLAB_API_ENDPOINT'] | ||
private_token = config['GITLAB_API_PRIVATE_TOKEN'] | ||
httparty = config['GITLAB_API_HTTPARTY_OPTIONS'].gsub("'",'') | ||
|
||
Gitlab.endpoint = endpoint | ||
Gitlab.private_token = private_token | ||
Gitlab.httparty = eval(httparty) | ||
merge_requests = Gitlab.merge_requests(project_id, { page: 1 }) | ||
mr_id = merge_requests.first.to_h['id'] | ||
Gitlab.accept_merge_request(project_id,mr_id, { merge_commit_message: "#{mr_title}" }) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,46 @@ | ||
#!/usr/bin/env bash | ||
repo_dir="$(dirname $0)/.." | ||
. "${repo_dir}/bin/functions" | ||
test -f /etc/gitlab-ci.conf && . /etc/gitlab-ci.conf | ||
default_nodes=$catalag_diff_default_nodes | ||
always_nodes=$catalag_diff_always_nodes | ||
|
||
node='git.lan' | ||
diff_commits_number=1 | ||
|
||
PUPPET=$(which puppet) | ||
ERB=$(which erb) | ||
RUBY=$(which ruby) | ||
global_exit=0 | ||
if [[ "x$1" != "x" ]]; then | ||
git checkout $1 | ||
git pull | ||
fi | ||
diff_commits_number=$(git log production..$1 --pretty=oneline | wc -l) | ||
echo "Checking for files in the last $diff_commits_number commits" | ||
for changedfile in $(git diff HEAD~$diff_commits_number --name-only); do | ||
node='' | ||
if [[ $(echo "$changedfile" | grep -q 'hieradata/hostname'; echo $?) -eq 0 ]]; then | ||
node=$(echo $changedfile | sed -e "s/^hieradata\/hostname\///" -e "s/\.yaml//") | ||
fi | ||
if [[ $(echo "$changedfile" | grep -q 'hieradata/role'; echo $?) -eq 0 ]]; then | ||
role=$(echo $changedfile | sed -e "s/^hieradata\/role\///" -e "s/\.yaml//") | ||
fi | ||
|
||
octocatalog-diff -n $node | ||
exit $global_exit | ||
if [[ "x$node" != "x" ]]; then | ||
echo | ||
echo "Catalog diff on ${node} - Check based on commits" | ||
octocatalog-diff -n $node | ||
fi | ||
|
||
if [[ "x$role" != "x" ]]; then | ||
echo | ||
echo "Catalog diff on role ${role} - Check based on commits" | ||
octocatalog-diff -n $role.$(facter domain) | ||
fi | ||
done | ||
|
||
for node in $default_nodes; do | ||
echo | ||
echo "Catalog diff on ${node} - Default check" | ||
octocatalog-diff -n $node | ||
done | ||
|
||
for node in $always_nodes; do | ||
echo | ||
echo "Catalog diff on ${node} - Check always done" | ||
octocatalog-diff -n $node | ||
done |
Oops, something went wrong.