“It is not the strongest of the species that survive, nor the most intelligent, but the one most responsive to change.” — Charles Darwin

“DevOps is a set of practices that seeks to reduce the gap between software development and software operation.”

Automated Devops with Test-Kitchen, Ansible and AnsibleSpec

This demonstrates using test-kitchen, ansible and ansiblespec to build and verify an apache server.

Ansible and apache can be installed and configured on the same server.

Alternatively ansible and apache can be installed and configured on separate servers. In this case:
    -Everything is done via ssh from the Ansible/Serverspec server so nothing is installed on the apache server.
    -In this demonstration both servers are centos 7 running like Amazon EC2, or a Docker Container as long as they are accessible via ssh.
    -You can take an image of the server after it is build and no comfiguration software is install on the apache Server.
    -this is using ansible in ssh connection mode to do remote configuration.



Workstation Software Installation

The first thing you need to do is install the test-kitchen environment on your workstation.
A useful link is: http://misheska.com/blog/2013/12/26/set-up-a-sane-ruby-cookbook-authoring-environment-for-chef
The follow instructions are for Windows PC (it will be similar for Mac):

1. Download and install the Windows RubyInstaller for 32 bit Ruby 2.1 from http://rubyinstaller.org/downloads.
    Check the option to add ruby to your path.

2. Download and install the Windows Ruby DevKit for use with Ruby 2.0 and above (32bits version only) from http://rubyinstaller.org/downloads.

3. Configure the Ruby DevKit
    In the devkit directory run “ruby dk.rb init”.
    Check the config.yml generated has added the the path of the ruby install, if not add it manually.
    run “ruby dk.rb install” to bind it to the ruby installation.

4. Then install the following gems
    gem install test-kitchen
    gem install kitchen-ansible
    gem install kitchen-verifier-serverspec

5. Install a git client on your workstation and then git clone the repository     https://github.com/neillturner/ansible_ansiblespec_repo
and in a command window in the ansible_repo directory run command
    kitchen list
This will return a list if everything is correctly installed.

ansible and apache on the same server.

1. Create 1 linux server for both ansible and apache using a keypair using say AWS Cloud Formation.

2. In ansible_ansiblespec_repo update the inventory/hosts_ssh with IP address of linux server.

3. In the .kitchen.yml file
* Set the ssh_key to the aws keypair for linux server e.g. spec/test.pem
* Set the hostname to ip address of linux server e.g.'54.229.103.38'

4. create, converge, verify and destroy the ansible-centos-70 server

    kitchen create ansible-centos-70 -l debug
    kitchen converge ansible-centos-70 -l debug
    kitchen verify ansible-centos-70 -l debug
    kitchen destroy ansible-centos-70 -l debug

ansible and apache on separate servers.

1. Create 2 linux servers one for ansible and one for apache using a keypair using say AWS Cloud Formation.

2. In ansible_ansiblespec_repo update the inventory/hosts_ssh with IP address of apache server.

3. In the .kitchen.yml file
* Set the ssh_key to the aws keypair for ansible and apache server e.g. spec/test.pem
* Set the hostname to ip address of ansible server e.g.'54.229.103.38'

4. create, converge, verify and destroy the ansible-centos-70 server

    kitchen create ansible-centos-70 -l debug
    kitchen converge ansible-centos-70 -l debug
    kitchen verify ansible-centos-70 -l debug
    kitchen destroy ansible-centos-70 -l debug

0 comments:

Post a Comment