diff --git a/{{cookiecutter.role_name}}/.gitignore b/{{cookiecutter.role_name}}/.gitignore new file mode 100644 index 0000000..9ed9e61 --- /dev/null +++ b/{{cookiecutter.role_name}}/.gitignore @@ -0,0 +1,53 @@ +.kitchen/ +.kitchen.local.yml + +*.gem +*.rbc +/.config +/coverage/ +/InstalledFiles +/pkg/ +/spec/reports/ +/spec/examples.txt +/test/tmp/ +/test/version_tmp/ +/tmp/ + +# Used by dotenv library to load environment variables. +# .env + +## Specific to RubyMotion: +.dat* +.repl_history +build/ +*.bridgesupport +build-iPhoneOS/ +build-iPhoneSimulator/ + +## Specific to RubyMotion (use of CocoaPods): +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# vendor/Pods/ + +## Documentation cache and generated files: +/.yardoc/ +/_yardoc/ +/doc/ +/rdoc/ + +## Environment normalization: +/.bundle/ +/vendor/bundle +/lib/bundler/man/ + +# for a library or gem, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# Gemfile.lock +# .ruby-version +# .ruby-gemset + +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: +.rvmrc diff --git a/{{cookiecutter.role_name}}/.kitchen.yml b/{{cookiecutter.role_name}}/.kitchen.yml new file mode 100644 index 0000000..a70aadb --- /dev/null +++ b/{{cookiecutter.role_name}}/.kitchen.yml @@ -0,0 +1,35 @@ +--- +driver: + name: docker + require_chef_omnibus: false + require_ruby_for_busser: false + use_sudo: false + +platforms: + - name: ubuntu-14.04 + driver_config: + image: ubuntu:14.04 + platform: ubuntu + - name: ubuntu-16.04 + driver_config: + image: ubuntu:16.04 + platform: ubuntu + +provisioner: + ansible_connection: local + ansible_host_key_checking: false + ansible_version: latest + name: ansible_playbook + hosts: test-kitchen + idempotency_test: true + require_ansible_repo: true + require_chef_for_busser: false + require_ruby_for_busser: false + role_name: {{cookiecutter.role_name}} + roles_path: . + +suites: + - name: default + +verifier: + name: inspec diff --git a/{{cookiecutter.role_name}}/.travis.yml b/{{cookiecutter.role_name}}/.travis.yml new file mode 100644 index 0000000..168b38c --- /dev/null +++ b/{{cookiecutter.role_name}}/.travis.yml @@ -0,0 +1,15 @@ +--- +language: ruby +rvm: + - 2.3 +sudo: required + +services: + - docker + +before_install: "./test/scripts/before-install.sh" +install: "./test/scripts/install.sh" +script: "./test/scripts/test-role.sh" + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/{{cookiecutter.role_name}}/Gemfile b/{{cookiecutter.role_name}}/Gemfile new file mode 100644 index 0000000..3be4f3e --- /dev/null +++ b/{{cookiecutter.role_name}}/Gemfile @@ -0,0 +1,12 @@ +# frozen_string_literal: true +source "https://rubygems.org" + +if Gem::Version.new(Bundler::VERSION) < Gem::Version.new('1.13.0') + abort "Bundler version >= 1.13.0 is required" +end + +gem "test-kitchen" +gem "kitchen-docker" +gem "kitchen-ansible" +gem "inspec" +gem "kitchen-inspec" diff --git a/{{cookiecutter.role_name}}/defaults/main.yml b/{{cookiecutter.role_name}}/defaults/main.yml index e69de29..ed97d53 100644 --- a/{{cookiecutter.role_name}}/defaults/main.yml +++ b/{{cookiecutter.role_name}}/defaults/main.yml @@ -0,0 +1 @@ +--- diff --git a/{{cookiecutter.role_name}}/handlers/main.yml b/{{cookiecutter.role_name}}/handlers/main.yml index cd21505..ed97d53 100644 --- a/{{cookiecutter.role_name}}/handlers/main.yml +++ b/{{cookiecutter.role_name}}/handlers/main.yml @@ -1,2 +1 @@ --- - diff --git a/{{cookiecutter.role_name}}/meta/main.yml b/{{cookiecutter.role_name}}/meta/main.yml index e77f3cc..c867c34 100644 --- a/{{cookiecutter.role_name}}/meta/main.yml +++ b/{{cookiecutter.role_name}}/meta/main.yml @@ -1,31 +1,30 @@ --- -allow_duplicates: {{ cookiecutter.allow_duplicates }} +allow_duplicates: {{cookiecutter.allow_duplicates}} galaxy_info: - author: {{ cookiecutter.full_name }} - description: {{ cookiecutter.short_description }} + author: {{cookiecutter.full_name}} + description: {{cookiecutter.short_description}} license: 3-clause BSD license. - min_ansible_version: {{ cookiecutter.min_ansible_version }} + min_ansible_version: {{cookiecutter.min_ansible_version}} platforms: - name: Ubuntu versions: - 14.04 + - trusty + - xenial categories: - #- cloud - #- cloud:ec2 - #- cloud:gce - #- cloud:rax - #- clustering - #- database - #- database:nosql - #- database:sql - #- development - #- monitoring - #- networking - #- packaging - #- system - #- web - - + # - cloud + # - cloud:ec2 + # - cloud:gce + # - cloud:rax + # - clustering + # - database + # - database:nosql + # - database:sql + # - development + # - monitoring + # - networking + # - packaging + # - system + # - web diff --git a/{{cookiecutter.role_name}}/tasks/main.yml b/{{cookiecutter.role_name}}/tasks/main.yml index cd21505..ed97d53 100644 --- a/{{cookiecutter.role_name}}/tasks/main.yml +++ b/{{cookiecutter.role_name}}/tasks/main.yml @@ -1,2 +1 @@ --- - diff --git a/{{cookiecutter.role_name}}/test/integration/default/default.yml b/{{cookiecutter.role_name}}/test/integration/default/default.yml new file mode 100644 index 0000000..82131fb --- /dev/null +++ b/{{cookiecutter.role_name}}/test/integration/default/default.yml @@ -0,0 +1,4 @@ +--- +- hosts: all + roles: + - role: {{cookiecutter.role_name}} diff --git a/{{cookiecutter.role_name}}/test/integration/default/inspec/{{ cookiecutter.role_name }}.rb b/{{cookiecutter.role_name}}/test/integration/default/inspec/{{ cookiecutter.role_name }}.rb new file mode 100644 index 0000000..8428f95 --- /dev/null +++ b/{{cookiecutter.role_name}}/test/integration/default/inspec/{{ cookiecutter.role_name }}.rb @@ -0,0 +1,4 @@ +control "{{ cookiecutter.role_name }}" do + title "{{ cookiecutter.role_name }} role check" + +end diff --git a/{{cookiecutter.role_name}}/test/scripts/before-install.sh b/{{cookiecutter.role_name}}/test/scripts/before-install.sh new file mode 100755 index 0000000..fca4b9a --- /dev/null +++ b/{{cookiecutter.role_name}}/test/scripts/before-install.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# See https://github.com/travis-ci/travis-ci/issues/1066 +# Fail if one of the commands of this script fails +set -e + +gem install bundle +pip install ansible-lint +pip install yamllint + +set +e diff --git a/{{cookiecutter.role_name}}/test/scripts/install.sh b/{{cookiecutter.role_name}}/test/scripts/install.sh new file mode 100755 index 0000000..1e84922 --- /dev/null +++ b/{{cookiecutter.role_name}}/test/scripts/install.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# See https://github.com/travis-ci/travis-ci/issues/1066 +# Fail if one of the commands of this script fails +set -e + +bundle install + +set +e diff --git a/{{cookiecutter.role_name}}/test/scripts/test-role.sh b/{{cookiecutter.role_name}}/test/scripts/test-role.sh new file mode 100755 index 0000000..92d9bab --- /dev/null +++ b/{{cookiecutter.role_name}}/test/scripts/test-role.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# See https://github.com/travis-ci/travis-ci/issues/1066 +# Fail if one of the commands of this script fails +set -e + +ansible-lint . +yamllint . +kitchen diagnose --all +# Uncomment the --concurrency flag to run multiple tests in parallel +kitchen test #--concurrency + +set +e