• Stars
    star
    104
  • Rank 330,604 (Top 7 %)
  • Language
    Ruby
  • Created over 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Test Kitchen Provisioner for Puppet

Kitchen Puppet

Gem Version Gem Downloads Build Status

kitchen-puppet

A Test Kitchen Provisioner for Puppet

The providers supports both puppet apply and puppet agent clients and puppet bolt.

The PuppetApply provider works by passing the puppet repository based on attributes in .kitchen.yml & calling puppet apply.

The PuppetAgent provider works by passing the puppetmaster and other attributes in .kitchen.yml & calling puppet agent.

The PuppetBolt provider works by passing the puppet bolt commands based on attributes in .kitchen.yml & calling puppet bolt.

This provider has been tested against the Ubuntu 1604 and Centos 7 boxes running in docker and vagrant/virtualbox.

Template

Template project for using kitchen for puppet development:

https://github.com/scoopex/puppet-kitchen_template

Resources

Install

  1. install the latest Ruby on your workstations (for windows see https://rubyinstaller.org/downloads/)

  2. From a Command prompt:

  • gem install librarian-puppet
  • gem install test-kitchen (or gem install test-kitchen -v 1.16.0 if using ruby version less than 2.3)
  • gem install kitchen-puppet

Requirements

It is recommended to have a metadata.json file of your puppet module. It is used by kitchen-puppet to configure the module path. The puppet docs describe (https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html#write-a-metadatajson-file) how to create one.

You'll need a driver box without a chef installation so puppet can be installed. Puppet have one at http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box or http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box.

For PuppetAgent a server with a puppet master is required that can resolve the hostname ip address of the server. The server must also be able to resolve the hostname ip address of the puppet master.

You can also use the PuppetApply driver with a docker container, provided the necessary box requirements to install puppet are included inside the container. The easiest way to do this is to supply Kitchen-Docker with a custom dockerfile to install the needed dependencies for puppet installation.

Windows Support

There is windows/winrm support, currently not all functionality is supported.

  • require_chef_for_busser: false (it is possible to call rspec over winrm to run the tests)
  • resolve_with_librarian_puppet: false (librarian-puppet is not working on windows server)

Sample Puppet Repositories

Using Environments

In the root directory for your puppet repository:

Create a .kitchen.yml, much like one the described above:

    ---
    driver:
      name: vagrant

    provisioner:
      name: puppet_apply
      puppet_environment: dev
# the puppet environmnt files can be in this repository
      puppet_environment_config_path: environment/dev/environment.conf
      manifests_path:  environment/dev/manifests
      modules_path: environment/dev/modules_mycompany
# or external to this repository as long as they are accessible
#     puppet_environment_config_path: /my_environments/dev/environment.conf
#     manifests_path:                 /my_environments/dev/manifests
#     modules_path:                   /my_environments/dev/modules_mycompany
      hiera_data_path: /repository/puppet_repo/hieradata

    platforms:
    - name: nocm_ubuntu-12.04
      driver_plugin: vagrant
      driver_config:
        box: nocm_ubuntu-12.04
        box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box

    suites:
     - name: default

Sample Puppet Repositories

Test-Kitchen Serverspec

To run the verify step with the test-kitchen serverspec setup your puppet repository as follows:

In the root directory for your puppet repository:

Create a .kitchen.yml, much like one the described above:

    ---
    driver:
      name: vagrant

    provisioner:
      name: puppet_apply
      manifests_path: /repository/puppet_repo/manifests
      modules_path: /repository/puppet_repo/modules-mycompany
      hiera_data_path: /repository/puppet_repo/hieradata

    platforms:
    - name: nocm_ubuntu-12.04
      driver_plugin: vagrant
      driver_config:
        box: nocm_ubuntu-12.04
        box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box

    suites:
     - name: default

Then for serverspec:

  mkdir -p test/integration/default/serverspec/localhost
  echo "require 'serverspec'" >> test/integration/default/serverspec/spec_helper.rb
  echo "set :backend, :exec" >> test/integration/default/serverspec/spec_helper.rb

Create your serverspec tests in test/integration/default/serverspec/localhost/xxxxxx_spec.rb:

  require 'spec_helper'

  if os[:family] == 'ubuntu'
        describe '/etc/lsb-release' do
          it "exists" do
              expect(file('/etc/lsb-release')).to be_file
          end
        end
  end

  if os[:family] == 'redhat'
    describe '/etc/redhat-release' do
      it "exists" do
          expect(file('/etc/redhat-release')).to be_file
      end
    end
  end

Test-Kitchen Beaker

test-kitchen normally uses tests setup in test/integration/.... directory. Beaker format puts the tests with the spec/acceptance directory in the puppet repository and the spec_helper.rb under the spec directory which is more logical.

For examples see:

To implement this with test-kitchen setup the puppet repository with:

  • the spec files with the spec/acceptance directory.

  • the spec_helper in the spec folder.

  • install kitchen-verifier-serverspec on your workstation i.e. 'gem install kitchen-verifier-serverspec'

See examples:

.
+-- spec
¦   +-- acceptance
¦   ¦   +-- mariadb_spec.rb
¦   ¦   +-- nginx_spec.rb
¦   ¦
    +-- spec_helper.rb

In the root directory for your puppet repository create a .kitchen.yml with

  • a verifier of 'serverspec'
  • a pattern parameter with the spec tests to run
verifier:
  name: serverspec

suites:
  - name: base
    verifier:
      patterns:
      - modules/mycompany_base/spec/acceptance/base_spec.rb

See kitchen-verifier-serverspec

hiera_writer_files option

Allows creation of arbitrary YAML files in the target instance's hieradata/ dir in test-kitchen configuration (eg kitchen.yml). Like setting chef attributes in kitchen.yml, except for Hiera YAML files.

set hiera_writer_files in kitchen.yml

---
driver:
  name: vagrant

provisioner:
  name: puppet_apply
  manifests_path: /repository/puppet_repo/manifests
  modules_path: /repository/puppet_repo/modules-mycompany
  hiera_data_path: /repository/puppet_repo/hieradata
  hiera_writer_files:
    - datacenter/vagrant.yaml:
        logstash_servers: []
        hosts:
          10.1.2.3:
          - puppet
          - puppetdb

platforms:
- name: nocm_ubuntu-12.04
  driver_plugin: vagrant
  driver_config:
    box: nocm_ubuntu-12.04
    box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box

suites:
 - name: default

The above configuration will result in the creation of a file on the guest named ${hieradata}/datacenter/vagrant.yaml containing:

---
logstash_servers: []
  hosts:
    10.1.2.3:
    - puppet
    - puppetdb

It will overwrite any existing Hiera YAML files with the same name (on the guest), not merge.

Provisioner Options

Please see the Provisioner Options (https://github.com/neillturner/kitchen-puppet/blob/master/provisioner_options.md).

Contributing

To contribute to the repository, please follow the Fork / PR model:

  1. Fork The Repository
  2. Work on epic changes
  3. Write tests for your changes, see TESTING
  4. Update Documentation
  5. Commit
  6. Push
  7. Create PR
  8. Profit(?)

More Repositories

1

kitchen-ansible

Ansible Provisioner for Test Kitchen
Ruby
350
star
2

cfndsl_examples

Cloud Formation examples for cfndsl ruby coding
Ruby
59
star
3

terraform-aws-lambda-scheduler

Stop and start EC2 and RDS instances according to schedule via lambda and terraform
Python
54
star
4

kitchen-verifier-serverspec

A Test Kitchen Serverspec Verifer without having to transit the Busser layer
Ruby
39
star
5

omnibus-ansible

Install latest Ansible via pip + dependencies via a shell script
Shell
27
star
6

terraform-github-actions

terraform github action workflow example with tests
HCL
24
star
7

kitchen-ssh

ssh and ssh_gzip driver for test-kitchen for any running server with an ip address
Ruby
21
star
8

ec2dream

Build and Manage Cloud Servers - Agile DevOps for the Cloud
Ruby
20
star
9

ansible_repo

ansible_repo for testing ansible using test kitchen
Ruby
17
star
10

kitchen-cloudformation

A Test Kitchen Driver for Amazon AWS CloudFormation.
Ruby
16
star
11

kitchen-verifier-awspec

test kitchen verifier for awspec
Ruby
16
star
12

knife-cfn

CloudFormation Support for Chef's Knife Command
Ruby
10
star
13

terraform-aws-centralised-logs

Centralised logging using AWS elasticsearch service, lambda and cloudwatch logs
HCL
6
star
14

terraform-aws-autospotting

Automatically convert your existing AutoScaling groups to significantly cheaper spot instances with minimal(often zero) configuration changes
HCL
6
star
15

terraform-aws-elb-logs-to-elasticsearch

Send ELB logs from S3 bucket to ElasticSearch using AWS Lambda
HCL
5
star
16

puppet-pm2

Puppet Module to deploy a nodejs application using PM2
Shell
4
star
17

terraform-aws-alb-logs-to-elasticsearch

Send ALB logs from S3 bucket to ElasticSearch using AWS Lambda
HCL
4
star
18

aws-alb-logs-to-elasticsearch

JavaScript
4
star
19

cloudwatch-monitoring

Install Amazon AWS Cloud Watch Monitoring Scripts
Ruby
4
star
20

cross-account-managed-prometheus

HCL
4
star
21

ansible_ansiblespec_repo

ansible repo for testing ansible using test kitchen
Ruby
4
star
22

terraform-aws-adclient

Create Active Directory Client instance to manage AWS Directory Service
HCL
3
star
23

terraform-aws-microsoftad

Create a Microsoft Active Directory AWS Directory Service
HCL
2
star
24

terraform-aws-populate_nlb_tg_with_rds

populate network load balancer target group with RDS IP address. This can be in fact any DNS resolvable to an instance like redshift DNS.
Python
2
star
25

terraform-aws-simplead

Create a Simple Active Directory AWS Directory Service
HCL
2
star
26

terraform-aws-lambda-es-cleanup

AWS Elasticsearch Lambda Curator
HCL
2
star
27

kitchen-softlayer

test kitchen driver for softlayer
Ruby
2
star
28

flux-examples

Flux V2 kubernetes examples
2
star
29

puppet-cloudwatch_monitoring

reports custom metric data about Linux performance to Amazon CloudWatch
Shell
1
star
30

ansible_windows_repo

ansible repo for windows support
1
star
31

lambda_aws_scheduler

DEPRECATED: See terraform-aws-lambda-scheduler
Python
1
star
32

ansible_exec_repo

Ansible Repository to demonstrate using kitchen-ansible with exec driver
Ruby
1
star
33

puppet_docker_repo

Puppet Repository to demonstrate using kitchen-puppet with Docker
Puppet
1
star
34

terraform-aws-ssm-adjoin

SSM Document to join Instance to AD Domain of AWS Directory Service
HCL
1
star
35

serverspec-runners

Runner scripts for kitchen-verifier-serverspec
Ruby
1
star
36

kitchen-gzip

Test Kitchen gzip transport plugin to speed up tests.
1
star
37

ansible_awx_repo

Ansible Repository to demonstrate using kitchen-ansible with Ansible AWX and vagrant driver
1
star
38

puppet_repo

Puppet Repo with serverspec acceptance tests via ssh to a server.
Puppet
1
star
39

cloudformation_repo

kitchen-cloudformation example repository
1
star
40

puppet_vagrant_repo

Puppet Repository to demonstrate using kitchen-puppet with Vagrant
Puppet
1
star
41

chef-nano

test-kitchen with chef and Windows Nano Server
Ruby
1
star
42

aws_helper

Aws Helper for an instance - Allows functions on EBS volumes, snapshots, IP addresses and more
Ruby
1
star
43

terraform-list-backends

List Status of Terraform States in Backend AWS S3
Go
1
star
44

ansible_vagrant_repo

Ansible Repository to demonstrate using kitchen-ansible with Vagrant
Ruby
1
star
45

aws-cfn-scheduler

Creates and deletes cloudformation stacks using a JSON based schedule
Python
1
star
46

puppet-aws_scheduler

Install aws scheduler - stop and start server instances according to schedule
HTML
1
star