diff --git a/.kitchen.yml b/.kitchen.yml new file mode 100644 index 0000000..7d9389c --- /dev/null +++ b/.kitchen.yml @@ -0,0 +1,21 @@ +--- +driver: + # using docker to test + name: docker + privileged: true + +provisioner: + # use an ansible playbook to provision our server + name: ansible_playbook + # name of the host + hosts: test-kitchen + # list ansible galaxy requirements from meta/main.yml + requirements_path: requirements.yml + + +platforms: + - name: ubuntu-14.04 + +suites: + # suites found at /test/integration/$test-name + - name: default diff --git a/.travis.yml b/.travis.yml index c656bda..a08f7b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,38 +1,15 @@ --- -language: python -python: "2.7" - -env: - - SITE=test-install.yml - -before_install: - - sudo apt-get update -qq - - sudo apt-get install -y curl +sudo: required +# docker is required to run tests +services: docker install: - # Install Ansible. - - pip install ansible - - # Add ansible.cfg to pick up roles path. - - "{ echo '[defaults]'; echo 'roles_path = ../'; } >> ansible.cfg" - - # Install dependencies - - ansible-galaxy install telusdigital.apt-repository + - bundle install script: - # Check the role/playbook's syntax. - - "ansible-playbook -i tests/inventory tests/$SITE --syntax-check" - - # Run the role/playbook with ansible-playbook. - - "ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo" - - # Run the role/playbook again, checking to make sure it's idempotent. - - > - fish -v - |& grep -q 'fish, version' - && (echo 'Fish installed') - || (echo 'Fish not installed') - - # Just for good measure - - fish -v + # run kitchen tests (destroy, create, converge, setup, verify and destroy) + - bundle exec kitchen test +notifications: + slack: + secure: K+Qf40Tui8xo71/0m6v6B+LYl8eTfiBYUu5u8+amGNIERtfbhtvzuYhIYBZGaa1cWJeQc8woAbdDvh4vh/Lj22TR3PsNG3UGgb75lSrYpJ9XJOiuBeyP35nXF1lhCOzFVhwziMdQWy1nfvl16dTIb73G/tFCZMotu9Jl2bZDl2G88bkFZlLtuX3rEXbmyqNIYiy3Z3f+3N5hujenBOABGblnui63vjROy4slM991UbdX++c/ogg+czzopl7C3zAqCPj4fqp7Wu5S0jwn15IFy1dgnJzVqlmvrpwxkzl7K3K9lvRnG/dk0louNlaUiIinzZ3npUqOPkY66e7SoiFhgjeXRHK/33it0UriifPcw1+f9ZvbzyULlYmvvIRAOyQyKikLC/SP4Q4X/Y55KdKmE8wB54q8bRKwSjlTtkDCLBmYiAApV58uyL1hyqHee7wQkYzLHZ1IkE35/mrBxDCoy8QrmCQBmdJv2H+dQVc8VhTWVSOMo+FLHr0d7jp/Kmngvo/OJYbAwPPQbl7vjOSHlLkbf9tqFRGsMzZsiqeTrRxWe4FVB599gA7h7KJ3CAzSsgtpugd+m9mk6/GBoYooouBDkxx4qD6LSMLjhYerYYCgHQCX5s1p9+A1cXtZ3T6DSUncQ7Hx0Q+beLWS8MOmFdqBNVt5K2CND5fdwiOBLqo= diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..3d5e43d --- /dev/null +++ b/Gemfile @@ -0,0 +1,6 @@ +source 'https://rubygems.org' + +gem 'test-kitchen' +gem 'serverspec' +gem 'kitchen-ansible' +gem 'kitchen-docker' diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..6cf150e --- /dev/null +++ b/requirements.yml @@ -0,0 +1,2 @@ +--- +- src: telusdigital.apt-repository diff --git a/test/integration/default/default.yml b/test/integration/default/default.yml new file mode 100644 index 0000000..86f7990 --- /dev/null +++ b/test/integration/default/default.yml @@ -0,0 +1,8 @@ +--- +# host to test against +- hosts: test-kitchen + remote_user: root + + roles: + # name of role to test + - role: ansible-fish diff --git a/test/integration/default/serverspec/localhost/default_spec.rb b/test/integration/default/serverspec/localhost/default_spec.rb new file mode 100644 index 0000000..d403800 --- /dev/null +++ b/test/integration/default/serverspec/localhost/default_spec.rb @@ -0,0 +1,9 @@ +require 'spec_helper' + +describe 'ansible-fish::default' do + + describe package('fish') do + it { should be_installed.by('apt') } + end + +end diff --git a/test/integration/default/serverspec/spec_helper.rb b/test/integration/default/serverspec/spec_helper.rb new file mode 100644 index 0000000..1bc5dc6 --- /dev/null +++ b/test/integration/default/serverspec/spec_helper.rb @@ -0,0 +1,5 @@ +require 'serverspec' + +# :backend can be either :exec or :ssh +# since we are running local we use :exec +set :backend, :exec diff --git a/tests/inventory b/tests/inventory deleted file mode 100644 index 2fbb50c..0000000 --- a/tests/inventory +++ /dev/null @@ -1 +0,0 @@ -localhost diff --git a/tests/test-install.yml b/tests/test-install.yml deleted file mode 100644 index c7248de..0000000 --- a/tests/test-install.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -- hosts: localhost - remote_user: root - roles: - - role: telusdigital.apt-repository - repository_key: "0x27557f056dc33ca5" - repository_url: "deb http://ppa.launchpad.net/fish-shell/release-2/ubuntu {{ ansible_distribution_release }} main" - - role: ansible-fish