Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ spec/fixtures
modules/
/keys/private_key.pkcs7.pem
*.pyc
*Gemfile.lock

# Vagrant artifacts
vagrant/environments/*/ubuntu-xenial-16.04-cloudimg-console.log
Expand Down
281 changes: 262 additions & 19 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,285 @@
# GitLab CI configuration
# Example for a complete Puppet deployment workflow
# with separated pipelines for development, testing and production
# braches. Requires a fully configured PE-GitLab-CI runners
# environment to work.
#
#
stages:
- test
- deploy
- checks
- specs
- diffs
- integration
- live_runs
- version_check
- 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/
- vagrant/environments/ci/.vagrant/
tags:
- test_puppet
only:
- development
environment:
name: development
url: https://development.example.com

lint:
stage: checks
before_script:
- "bin/gitlab_before.sh"
script: "bin/puppet_lint.sh"
cache:
untracked: true
paths:
- modules/
- vagrant/environments/ci/.vagrant/
tags:
- test_puppet
only:
- development
allow_failure: true

rake_site:
stage: specs
before_script:
- "bin/gitlab_before.sh"
script: "bin/puppet_check_rake.sh site"
cache:
untracked: true
paths:
- modules/
- vagrant/environments/ci/.vagrant/
tags:
- test_puppet
only:
- development
allow_failure: true

rake_modules:
stage: specs
before_script:
- "bin/gitlab_before.sh"
script: "bin/puppet_check_rake.sh modules"
cache:
untracked: true
paths:
- modules/
- vagrant/environments/ci/.vagrant/
tags:
- test_puppet
only:
- development
allow_failure: true

catalog:
stage: test
catalog_diff:
stage: diffs
before_script:
- "bin/gitlab_before.sh"
script: "bin/gitlab_catalog_diff.sh"
script: "bin/gitlab_catalog_diff.sh development"
cache:
untracked: true
paths:
- modules/
tags:
- deploy_puppet
only:
- development
allow_failure: true

vagrant:
stage: test
catalog_preview:
stage: diffs
before_script:
- "bin/gitlab_before.sh"
script: "bin/vagrant_node_test.sh pe-centos7 pe"
script: "bin/gitlab_catalog_preview.sh development"
cache:
untracked: true
paths:
- modules/
tags:
- deploy_puppet # We run this on Puppet Server to compile catalogs
only:
- development
allow_failure: true

vagrant_setup:
stage: integration
before_script:
- "bin/gitlab_before.sh"
script: "bin/vagrant_node_test.sh oracle ci setup"
cache:
untracked: true
paths:
- modules/
- tests/
allow_failure: true
tags:
- test_puppet
only:
- development

vagrant_drift:
stage: integration
before_script:
- "bin/gitlab_before.sh"
script: "bin/vagrant_node_test.sh oracle ci drift"
cache:
untracked: true
paths:
- modules/
- tests/
tags:
- test_puppet
only:
- development

tp_test:
stage: integration
before_script:
- "bin/gitlab_before.sh"
script: "bin/gitlab_tp_test.sh development"
cache:
untracked: true
paths:
- modules/
- tests/
tags:
- test_puppet
only:
- development
allow_failure: true

verify_code_deploy_development:
stage: promote
script:
- "bin/codemanager_check_deploy.sh development"
tags:
- deploy_puppet
when: on_success
only:
- development

deploy_test:
stage: deploy
deploy_to_testing:
stage: promote
script:
- echo "Deploy to staging server"
- "bin/gitlab_create_merge_request.rb development testing"
- "bin/gitlab_accept_merge_request.rb development testing"
tags:
- deploy_puppet
when: on_success
only:
- development
environment:
name: staging
name: testing
url: https://staging.example.com

deploy_prod:
stage: deploy
# On testing branch
run_puppet_on_testing:
stage: live_runs
before_script:
- "bin/puppet_job_run.sh testing"
script:
- "bin/puppetdb_env_query.sh testing"
tags:
- deploy_puppet
when: on_success
only:
- testing
allow_failure: true

verify_code_deploy_testing:
stage: version_check
script:
- "bin/codemanager_check_deploy.sh testing"
tags:
- deploy_puppet
when: on_success
only:
- testing
allow_failure: true # TOREMOVE when fixed

merge_request_production:
stage: merge_request
script:
- echo "Deploy to production server"
- "bin/gitlab_create_merge_request.rb testing production"
when: on_success
tags:
- deploy_puppet
only:
- testing

merge_accept_production:
stage: promote
script:
- "bin/gitlab_accept_merge_request.rb testing production"
tags:
- deploy_puppet
when: manual
only:
- testing
environment:
name: production
url: https://example.com
when: manual

# Production
canary_run_on_production:
stage: live_runs
before_script:
- "bin/puppet_job_run.sh production"
script:
- "bin/puppetdb_env_query.sh production"
tags:
- deploy_puppet
when: on_success
only:
- production
allow_failure: true # TOREMOVE when fixed

verify_code_deploy_production:
stage: version_check
script:
- "bin/codemanager_check_deploy.sh production"
tags:
- deploy_puppet
when: on_success
only:
- production
- production
allow_failure: true # TOREMOVE when fixed

run_puppet_on_production:
stage: rollout
before_script:
- "bin/puppet_job_run.sh production"
script:
- "bin/puppetdb_env_query.sh production"
tags:
- deploy_puppet
when: on_success
only:
- production
allow_failure: true # TOREMOVE when fixed


test_post_run_on_production:
stage: postcheck
script:
- "bin/puppetdb_env_query.sh production"
tags:
- deploy_puppet
only:
- production
allow_failure: true # TOREMOVE when fixed


10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Release 0.4.6
## This control repo has nothing to do with earlier
## example42 puppet modules versions. Resetting versions.
- Added profiles and tools
- Added and improved scripts
- Added wide GitLab integration
- Added Puppet Enterprise integration and Vagrant environment

## Release 4.0.0.beta.3
- Widely improved scripting
- Aws role and relevant profiles and fab commands
Expand All @@ -10,9 +18,7 @@
- Added Docker building or role images (WIP)
- Several improvements


## Release 4.0.0.beta.1

- Introduced hiera-eyaml
- Hiera driven roles definition
- Resource defaults for tp
Expand Down
51 changes: 51 additions & 0 deletions Dangerfile
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



Loading