Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/travis #1

Merged
merged 6 commits into from Jan 12, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 46 additions & 0 deletions .kitchen.docker.yml
@@ -0,0 +1,46 @@
---
driver:
name: docker
privileged: true

provisioner:
name: chef_zero
# You may wish to disable always updating cookbooks in CI or other testing environments.
# For example:
# always_update_cookbooks: <%= !ENV['CI'] %>
always_update_cookbooks: true

verifier:
name: inspec

platforms:
- name: ubuntu-16.04
- name: centos-7
- name: amazonlinux
driver:
box: mvbcoding/awslinux
- name: debian-8
driver:
box: debian/jessie64

suites:
- name: default
run_list:
- recipe[chrony_ii_test::amazon_latest]
- recipe[chrony_ii::default]
verifier:
inspec_tests:
- test/smoke/default
attributes:
- name: amazon_time
run_list:
- recipe[chrony_ii_test::amazon_latest]
- recipe[chrony_ii::default]
verifier:
inspec_tests:
- test/smoke/amazon_time
attributes:
chrony_ii:
amazon_time_sync_service: true
includes:
- amazonlinux
2 changes: 2 additions & 0 deletions .kitchen.yml
Expand Up @@ -25,13 +25,15 @@ platforms:
suites:
- name: default
run_list:
- recipe[chrony_ii_test::amazon_latest]
- recipe[chrony_ii::default]
verifier:
inspec_tests:
- test/smoke/default
attributes:
- name: amazon_time
run_list:
- recipe[chrony_ii_test::amazon_latest]
- recipe[chrony_ii::default]
verifier:
inspec_tests:
Expand Down
3 changes: 3 additions & 0 deletions .rubocop.yml
@@ -0,0 +1,3 @@
AllCops:
Exclude:
- vendor/**/*
36 changes: 36 additions & 0 deletions .travis.yml
@@ -0,0 +1,36 @@
sudo: required

addons:
apt:
sources:
- chef-current-precise
packages:
- chefdk

services: docker

env:
matrix:
- INSTANCE=default-ubuntu-1604
- INSTANCE=default-centos-7
- INSTANCE=default-amazonlinux
- INSTANCE=default-debian-8
- INSTANCE=amazon-time-amazonlinux

install: echo "skip bundle install"

before_script:
# https://github.com/zuazo/kitchen-in-travis-native/issues/1#issuecomment-142230889
- sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
- eval "$(/opt/chefdk/bin/chef shell-init bash)"
- /opt/chefdk/embedded/bin/chef gem install kitchen-docker
- /opt/chefdk/embedded/bin/chef gem install rubocop
- /opt/chefdk/embedded/bin/chef gem install fauxhai
script:
- /opt/chefdk/embedded/bin/chef --version
- /opt/chefdk/embedded/bin/rubocop --version
- /opt/chefdk/embedded/bin/rubocop
- /opt/chefdk/embedded/bin/foodcritic --version
- /opt/chefdk/embedded/bin/foodcritic . --exclude spec -f any
- /opt/chefdk/embedded/bin/rspec
- KITCHEN_LOCAL_YAML=.kitchen.docker.yml /opt/chefdk/embedded/bin/kitchen verify ${INSTANCE}
4 changes: 4 additions & 0 deletions Berksfile
Expand Up @@ -3,3 +3,7 @@
source 'https://supermarket.chef.io'

metadata

group :integration do
cookbook 'chrony_ii_test', path: './test/cookbooks/chrony_ii_test'
end
32 changes: 32 additions & 0 deletions Gemfile
@@ -0,0 +1,32 @@
source 'https://rubygems.org'

group :rake do
gem 'rake'
gem 'tomlrb'
end

group :lint do
gem 'foodcritic'
gem 'rubocop', '~> 0.52'
end

group :unit do
gem 'berkshelf', '~> 6'
gem 'chefspec', '~> 7'
end

group :kitchen_common do
gem 'test-kitchen', '~> 1.19'
end

group :kitchen_vagrant do
gem 'kitchen-vagrant', '~> 1.2'
end

group :kitchen_inspec do
gem 'kitchen-inspec', '~> 0.20'
end

group :kitchen_docker do
gem 'kitchen-docker'
end
2 changes: 2 additions & 0 deletions README.md
@@ -1,4 +1,6 @@
# chrony_ii

[![Build Status](https://travis-ci.com/elastic-infra/chrony_ii.svg?branch=feature%2Ftravis)](https://travis-ci.com/elastic-infra/chrony_ii)

TODO: Enter the cookbook description here.

2 changes: 1 addition & 1 deletion recipes/service.rb
Expand Up @@ -27,7 +27,7 @@
service 'chrony-daemon' do
service_name value_for_platform_family(
'rhel' => 'chronyd',
'amazon' => 'chrony',
'amazon' => 'chronyd',
'debian' => 'chrony'
)
supports restart: true, status: true, reload: true
Expand Down
22 changes: 22 additions & 0 deletions test/cookbooks/chrony_ii_test/.gitignore
@@ -0,0 +1,22 @@
.vagrant
*~
*#
.#*
\#*#
.*.sw[a-z]
*.un~

# Bundler
Gemfile.lock
gems.locked
bin/*
.bundle/*

# test kitchen
.kitchen/
.kitchen.local.yml

# Chef
Berksfile.lock
.zero-knife.rb
Policyfile.lock.json
5 changes: 5 additions & 0 deletions test/cookbooks/chrony_ii_test/Berksfile
@@ -0,0 +1,5 @@
# frozen_string_literal: true

source 'https://supermarket.chef.io'

metadata
21 changes: 21 additions & 0 deletions test/cookbooks/chrony_ii_test/LICENSE
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 Tomoya Kabe

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
3 changes: 3 additions & 0 deletions test/cookbooks/chrony_ii_test/README.md
@@ -0,0 +1,3 @@
# chrony_ii_test

Support cookbook for testing `chrony_ii`
107 changes: 107 additions & 0 deletions test/cookbooks/chrony_ii_test/chefignore
@@ -0,0 +1,107 @@
# Put files/directories that should be ignored in this file when uploading
# to a chef-server or supermarket.
# Lines that start with '# ' are comments.

# OS generated files #
######################
.DS_Store
Icon?
nohup.out
ehthumbs.db
Thumbs.db

# SASS #
########
.sass-cache

# EDITORS #
###########
\#*
.#*
*~
*.sw[a-z]
*.bak
REVISION
TAGS*
tmtags
*_flymake.*
*_flymake
*.tmproj
.project
.settings
mkmf.log

## COMPILED ##
##############
a.out
*.o
*.pyc
*.so
*.com
*.class
*.dll
*.exe
*/rdoc/

# Testing #
###########
.watchr
.rspec
spec/*
spec/fixtures/*
test/*
features/*
examples/*
Guardfile
Procfile
.kitchen*
.rubocop.yml
spec/*
Rakefile
.travis.yml
.foodcritic
.codeclimate.yml

# SCM #
#######
.git
*/.git
.gitignore
.gitmodules
.gitconfig
.gitattributes
.svn
*/.bzr/*
*/.hg/*
*/.svn/*

# Berkshelf #
#############
Berksfile
Berksfile.lock
cookbooks/*
tmp

# Policyfile #
##############
Policyfile.rb
Policyfile.lock.json

# Cookbooks #
#############
CONTRIBUTING*
CHANGELOG*
TESTING*
MAINTAINERS.toml

# Strainer #
############
Colanderfile
Strainerfile
.colander
.strainer

# Vagrant #
###########
.vagrant
Vagrantfile
11 changes: 11 additions & 0 deletions test/cookbooks/chrony_ii_test/metadata.rb
@@ -0,0 +1,11 @@
name 'chrony_ii_test'
maintainer 'Tomoya Kabe'
maintainer_email 'kabe@elastic-infra.com'
license 'MIT'
description 'Installs/Configures chrony_ii_test'
long_description 'Installs/Configures chrony_ii_test'
version '0.1.0'
chef_version '>= 12.1' if respond_to?(:chef_version)

issues_url 'https://github.com/elastic-infra/chrony_ii/issues'
source_url 'https://github.com/elastic-infra/chrony_ii'
35 changes: 35 additions & 0 deletions test/cookbooks/chrony_ii_test/recipes/amazon_latest.rb
@@ -0,0 +1,35 @@
#
# Cookbook:: chrony_ii_test
# Recipe:: amazon-latest
#
# The MIT License (MIT)
#
# Copyright:: 2018, Tomoya Kabe
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

# Should only run on amazon
if node['platform_family'] == 'amazon'
file '/etc/yum.conf' do
f = Chef::Util::FileEdit.new(path)
f.search_file_replace_line(/^#releasever=latest$/, 'releasever=latest')
content f.send(:editor).lines.join
only_if { /^#releasever=latest$/.match(IO.read(path)) }
end
end
25 changes: 25 additions & 0 deletions test/cookbooks/chrony_ii_test/recipes/default.rb
@@ -0,0 +1,25 @@
#
# Cookbook:: chrony_ii_test
# Recipe:: default
#
# The MIT License (MIT)
#
# Copyright:: 2018, Tomoya Kabe
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.