neillturner / kitchen-ansible

Ansible Provisioner for Test Kitchen
Other
350 stars 134 forks source link

ansiblespec-busser doesn't get passed in extra_vars #135

Closed jessechahal closed 8 years ago

jessechahal commented 8 years ago

I'm using kitchen-ansible to test individual roles that I've created. These roles may or may not depend on other roles. I've create a single playbook that can be used to test any ansible role and it's dependent roles. This is done by passing the role in as a variable. So the converge works exactly as expected, the role runs and whatever the role is supposed to do. Each role has a spec folder with a serverspec test. The verify step does not work as expected and I believe its because the variables I've passed in don't get propagated to the ansiblespec busser.

part of my .kitchen.yml

[....]
provisioner:
  name: ansible_playbook
  hosts: test-kitchen
  require_ruby_for_busser: false
  ansible_version: 1.9.4
  ansible_verbose: true
  playbook: test/default.yml

suites:
  - name: some_role
    attributes:
         extra_vars:
           ROLE: a_role
verifer:
  name: busser
  plugin:
  - Ansiblespec
  ruby_bindir: '/usr/bin'

default.yml

- name: "test-kitchen wrapper for converging an individual role"
  connection: local
  hosts: 127.0.0.1
  gather_facts: false
  tags:
  - kitchen
  - test
  vars:
    - rubyversion: "2.2.3"
  roles:
    - "{{ROLE}}"

test/some_role/ansiblespec/config.yml

-
  playbook: default.yml
  inventory: hosts
  kitchen_path: '/tmp/kitchen'
  pattern: 'ansiblespec'    # or spec or serverspec

kitchen verify output

-----> Running ansiblespec test suite
-----> Installing Serverspec..
Fetching: sfl-2.2.gem (100%)
Fetching: net-telnet-0.1.1.gem (100%)
Fetching: net-ssh-3.0.2.gem (100%)
Fetching: net-scp-1.2.1.gem (100%)
Fetching: specinfra-2.51.1.gem (100%)
Fetching: rspec-support-3.4.1.gem (100%)
Fetching: diff-lcs-1.2.5.gem (100%)
Fetching: rspec-expectations-3.4.0.gem (100%)
Fetching: rspec-core-3.4.2.gem (100%)
Fetching: rspec-its-1.2.0.gem (100%)
Fetching: rspec-mocks-3.4.1.gem (100%)
Fetching: rspec-3.4.0.gem (100%)
Fetching: multi_json-1.11.2.gem (100%)
Fetching: serverspec-2.29.2.gem (100%)
-----> serverspec installed (version 2.29.2)
       BASE_PATH: /tmp/verifier/suites/ansiblespec, KITCHEN_PATH /tmp/kitchen, PLAYBOOK: default.yml, INVENTORY: hosts, PATTERN: ansiblespec, LOGIN_USER: root, SSH_KEY: , LOGIN_PASSWORD:
       group: 127.0.0.1 host: 127.0.0.1 roles: ["{{ROLE}}"]
-----> Run serverspec host_1 for host: 127.0.0.1 roles: ["{{ROLE}}"]
       /opt/chef/embedded/bin/ruby -I/tmp/kitchen -I/tmp/verifier/gems/gems/rspec-support-3.4.1/lib:/tmp/verifier/gems/gems/rspec-core-3.4.2/lib /opt/chef/embedded/bin/rspec --pattern /tmp/kitchen/roles/\{\{\{ROLE\}\}\}/spec/\*_spec.rb --color --format documentation --default-path /tmp/kitchen
       No examples found.

       Finished in 0.0002 seconds (files took 0.04971 seconds to load)
       0 examples, 0 failures

So I've tested the setup using a single playbook per role approach and everything has worked fine. Its pretty far from ideal to create 1 playbook per role for all 500+ roles that we have. Is there something I'm missing?

neillturner commented 8 years ago

I think the attributes only get passed to the provisioner stage and are not accessible by the busser plugin that's why i create the config.yml. I am going to change to use a verifier instead of a busser which will make it easier to pass in parameters.

neillturner commented 8 years ago

I've deprecated busser-ansible-spec you can use https://github.com/neillturner/kitchen-verifier-serverspec. and there is a ansiblespec_runner.rb that can be easily customized.

closing for now