Giter VIP home page Giter VIP logo

puppet-kitchen_template's Introduction

Overview

NOTE: Replace this text with your own description.

This project utilizes Test Kitchen to test puppetcode. You can use this template to write new puppet modules or to enhance existing modules.

Review the upstream documentation to find out how to use it in your own project

It provides the following aspects:

  • puppet template with demo code which installs a lighthttpd
  • convenient development environment
    • download and create a ubuntu and debian image in a virtualbox environment
    • download and create a ubuntu docker image
    • basic installation of puppet 4/5 client
    • automatic installation of puppet modules specified in the "Puppetfile" using librarian
  • check the setup using serverspec tests executed in the environment

Why do i need that?

  • provide convenient test setups for system development
  • reduce the need to develop on production or shared testsystems
    (sometimes you still need this, i.e. if you need special hardware to test your implementation)
  • test multiple variants of a setup on different operating systems
    (Ubuntu 14.04, 16.04, OpenSuse, ...)
  • prevent time consuming and git history polluting edit locally, commit/push, puppet execution roundtrips
  • automatically install needed puppet modules
  • easily test defined combinations of modules/roles
  • integrate automated tests to your ci-pipeline (i.e. jenkins)
  • reduce resource overhead by simply throwing away outdated setups
  • Execute tests remotely end very time efficient on AWS/EC2, Openstack, Vagrant, ...

Resources

How to start:

  • Install virtualbox: https://www.virtualbox.org/wiki/Linux_Downloads
  • Installation of vagrant
  • see: https://www.vagrantup.com/downloads.html
  • Download und Installation
    cd /tmp
    wget https://releases.hashicorp.com/vagrant/2.0.1/vagrant_2.0.1_x86_64.deb
    sudo dpkg -i vagrant_*_x86_64.deb
    
  • Install docker
  • see: https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#install-docker-ce
  • Download and installation (using "zesty" releas on "artful" because docker ubuntu repos not seem to be complete now)
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
      sudo add-apt-repository \
          "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
          zesty \
          stable"
    apt-get install docker-ce
    
  • Add yourself to the docker and vbox group and relogin to your desktop session
  • Clone the repo
    git clone https://github.com/scoopex/puppet-kitchen_template.git
    cd puppet-kitchen_template
    
  • Installation of RVM
    • Follow the offical installation procedure at https://rvm.io/, i.e.:

      gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
      \curl -sSL https://get.rvm.io | bash -s stable
      # source this or add this to your .bashrc
      source ~/.rvm/scripts/rvm
      exec bash
      # asks for root password and installs packages like libyaml-dev, libsqlite3-dev, libgdbm-dev, libncurses5-dev, bison, libreadline6-dev
      rvm install "ruby-2.4.1"
      
    • Configuration of RVM
      After the rvm installtion a configuration file (~/.rvmrc) should be created with the following content:

      echo "rvm_autoinstall_bundler_flag=1" >> ~/.rvmrc
      apt install ruby-dev libgmp-dev
      gem install bundler
      # Now the automatic invocation of bundler should install all the missing gems
      cd ..; cd puppet-kitchen_template
      

      This allows the convinient automatic installation of bundler.

    • Install Ruby, work with control repositories There are numerous possibilities to work with RVM - we are unsing the Gemfile procedure. see: Gemfile

      source 'https://rubygems.org'
      
      #ruby=2.0.0-p645
      #ruby-gemset=puppet-testing
      
      (...)
      

      The entries with the leading hashes (#) are not disabled entries. You have to install the configured ruby release in a manual procedure. You will get a notification "Required ruby-2.4.1 is not installed." if this step is missing.

      "test-kitchen": Serverspec Test mit Vagrant/Virtualbox/Docker

Cheat Sheet

Command                              Description
------------------------------------------------------------------------
kitchen list                         View all test suites
kitchen create                       Create the target system (Vagrant)
kitchen create <suite>
kitchen converge <suite>             Execute puppet (Puppet)
kitchen login <suite>                SSH Login
kitchen verify <suite>               Execute test suites (servespec)
kitchen test <suite>                 Create, test and destroy system
kitchen destroy                      Destroy all test systems
kitchen destroy <suite>              Destroy a certain test system

kitchen verify -l debug              Get enhanced debug information

librarian-puppet install --verbose   Debug librarian problems
librarian-puppet show --detailed     Show librarian dependencies

vagrant box list                     Show all vargrant boxes
vagrant box remove <box>             Remove a vagrant box to fetch 
                                     a new release on next 
                                     "kitchen create"
------------------------------------------------------------------------

Instance selection/handling:

  • Use "kitchen list" to identify instances
  • Modify the instances by editing '.kitchen.yml'
  • Kitchen automatically create all permutations of suites and platforms, see .kitchen.yml
  • Modify bootstrap code for the vagrant systems in './vagrantfiles'
  • Add the full name of the instances to a certain command
    • Kitches selects instances by regex matches, so think about naming schemes
    • If you do not specify the wildcard all regex ('.*')is automatically assumed

Develop and test puppet code

  • Change to the directory
    cd puppet-kitchen_template
    
  • Reset the environment
    (if you want to revert everything)
    kitchen destroy
    rm -rf Gemfile.lock Puppetfile.lock .kitchen .librarian/ .tmp/
    
  • Add Puppet modules and edit sourcecode
    vim Puppetfile 
    vim manifests/* 
    vim test/integration/default/serverspec/*
    
  • Deploy a test system and login to the system for debugging purposes
    kitchen list
    kitchen create <instance>
    kitchen login <instance>
       sudo bash
    
  • Execute puppet withe the current code
    kitchen converge <instance>
    
  • Execute serverspec tests
    kitchen verify <instance>
    
  • Destroy environment
    kitchen destroy <instance>
    
  • Inspect instance changes:
    • Login to instance, and become root
      kitchen login <instance name>
      sudo -i
      
    • Inspect changes
      cd /etc/
      git diff
      git checkout <file>
      

puppet-kitchen_template's People

Contributors

scoopex avatar

Watchers

James Cloos 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.