GithubHelp home page GithubHelp logo

busser-ansiblespec's Introduction

Busser::RunnerPlugin::Ansiblespec

Gem Version Gem Downloads Build Status

A Busser runner plugin for Ansible.

By default this enables testing using the ansiblespec format. The serverspec tests are specified with the roles in the ansible repository.

  • Multiple hosts and multiple roles can be tested.
  • It also supports storing the spec tests in the spec directory and in test-kitchen style test/integration directory.
  • Serverspec using ssh to communicate with the server to be tested.
  • It reads the ansible playbook and inventory files to determine the hosts to test and the roles for each host.

test-kitchen, ansible and busser-ansiblespec

See ansible-sample-tdd

Usage

Directory

In the ansible repository specify:

  • spec files with the roles.

  • spec_helper in the spec folder (with code as below).

  • test/integration//ansiblespec containing config.yml and ssh private keys to access the servers.

See example https://github.com/neillturner/ansible_repo

.
+-- roles
¦   +-- mariadb
¦   ¦   +-- spec
¦   ¦   ¦   +-- mariadb_spec.rb
¦   ¦   +-- tasks
¦   ¦   ¦   +-- main.yml
¦   ¦   +-- templates
¦   ¦       +-- mariadb.repo
¦   +-- nginx
¦       +-- handlers
¦       ¦   +-- main.yml
¦       +-- spec
¦       ¦   +-- nginx_spec.rb
¦       +-- tasks
¦       ¦   +-- main.yml
¦       +-- templates
¦       ¦   +-- nginx.repo
¦       +-- vars
¦           +-- main.yml
+-- spec
    +-- spec_helper.rb
    +-- my_private_key.pem
+-- test
    +-- integration
        +-- default      # name of test-kitchen suite
            +-- ansiblespec
                +-- config.yml

spec_helper

require 'rubygems'
require 'bundler/setup'

require 'serverspec'
require 'pathname'
require 'net/ssh'

RSpec.configure do |config|
  set :host,  ENV['TARGET_HOST']
  # ssh options at http://net-ssh.github.io/ssh/v1/chapter-2.html
  #                https://net-ssh.github.io/ssh/v2/api/classes/Net/SSH/Config.html
  # change user from root if using ubuntu, vagrant etc
  # ssh via password
  set :ssh_options, :user => ENV['LOGIN_USER'], :paranoid => false, :verbose => :error, :password => ENV['LOGIN_PASSWORD'] if ENV['LOGIN_PASSWORD']
  # ssh via ssh key
  set :ssh_options, :user => ENV['LOGIN_USER'], :paranoid => false, :verbose => :error, :host_key => 'ssh-rsa', :keys => [ ENV['SSH_KEY'] ] if ENV['SSH_KEY']
  set :backend, :ssh
  set :request_pty, true
end

config.yml

This goes in directory test/integration/default/ansiblespec where default is the name of test-kitchen suite

---
-
  playbook: default.yml
  inventory: hosts
  kitchen_path: '/tmp/kitchen'
  pattern: 'ansiblespec'    # or spec or serverspec
  user: root
  ssh_key: 'spec/my_private_key.pem'
  login_password: 'myrootpassword'

Gemfile

To add additionl ruby gems create a Gemfile in directory test/integration/default/ansiblespec

source 'https://rubygems.org'

gem 'rake'
gem 'busser-ansiblespec', '<=0.6.5'

Development

Pull requests are very welcome! Make sure your patches are well tested. Ideally create a topic branch for every separate change you make. For example:

  1. Fork the repo
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Authors

Original busser-serverspec created and maintained by HIGUCHI Daisuke ([email protected])

modified by Neill Turner ([email protected])

License

Apache 2.0 (see LICENSE)

busser-ansiblespec's People

Contributors

neillturner avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.