Giter Club home page Giter Club logo

vagrant-ansible-testing's Introduction

Vagrant Testing of Ansible Scripts

As we start to build out more and more roles at Blackbaud, we needed an easy way to test them. Since we maintain servers both in local data centers and in AWS we decided to use Vagrant be able to quickly test our ansible files against both environments.

The master branch includes a Vagrant file that will lanuch instances locally to VMware Fusion and to AWS. It is loosely based on Jeff Geerling's [ansible-role-test-vms repository] (https://github.com/geerlingguy/ansible-role-test-vms). The sts branch is geared towards an Amazon Only environment that utilizes role based cross account access via STS.

Testing a Role

Before Setting it up, you will need to define some environmental variable for the AWS portion to work correctly. In Master, you can set the individual environmental variables, or you can create an env.rb file in your local directory with the following:

# -*- mode: ruby -*-
# vi: set ft=ruby :
    
ENV['AWS_ACCESS_KEY_ID'] = 'XXXXXXXXXXXXXXXXXXXX'
ENV['AWS_SECRET_ACCESS_KEY'] = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
ENV['AWS_KEYPAIR_NAME'] = 'my-keypair'
ENV['MY_PRIVATE_AWS_SSH_KEY_PATH'] = '/Users/me/.ssh/my-keypair.pem'
ENV['AWS_SUBNET'] = 'subnet-xxxxxxxx'
ENV['AWS_SG'] = 'sg-xxxxxxxx'

In STS, the easiest thing to do is setup an env.rb file in your local directory, and add the following lines to it:

# -*- mode: ruby -*-
# vi: set ft=ruby :

ENV['AWS_PROFILE'] = 'my-aws-profile'
ENV['ROLE_ARN'] = 'arn:aws:iam::XXXXXXXXXXXX:role/platform-engineering'
ENV['AWS_KEYPAIR_NAME'] = 'my-keypair'
ENV['MY_PRIVATE_AWS_SSH_KEY_PATH'] = '/Users/me/.ssh/my-keypair.pem'
ENV['AWS_SUBNET'] = 'subnet-xxxxxxxx'
ENV['AWS_SG'] = 'sg-xxxxxxxx'

You will then need to add the role to the playbook.yml file and then run the command vagrant up. This will launch all of the instances defined and run the ansible against it.

After you have tested the role, you can destroy the instances wiht vagrant destroy -f. You can also just build one instance by identifying it by name in the vagrant up command: vagrant up ubuntu.

License

MIT

Author Information

Created in 2016 by Mark Honomichl.

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.