Skip to content

Commit

Permalink
Added a new cookbook and configured kitchen
Browse files Browse the repository at this point in the history
  • Loading branch information
directdevops committed Jan 20, 2021
1 parent 00082c9 commit 3c17055
Show file tree
Hide file tree
Showing 16 changed files with 360 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Jan21/cookbooks/qtlampserver/.delivery/project.toml
@@ -0,0 +1,34 @@
# Delivery for Local Phases Execution
#
# This file allows you to execute test phases locally on a workstation or
# in a CI pipeline. The delivery-cli will read this file and execute the
# command(s) that are configured for each phase. You can customize them
# by just modifying the phase key on this file.
#
# By default these phases are configured for Cookbook Workflow only
#

[local_phases]
unit = "chef exec rspec spec/"
lint = "chef exec cookstyle"
# Foodcritic includes rules only appropriate for community cookbooks
# uploaded to Supermarket. We turn off any rules tagged "supermarket"
# by default. If you plan to share this cookbook you should remove
# '-t ~supermarket' below to enable supermarket rules.
syntax = "chef exec foodcritic . -t ~supermarket"
provision = "chef exec kitchen create"
deploy = "chef exec kitchen converge"
smoke = "chef exec kitchen verify"
# The functional phase is optional, you can define it by uncommenting
# the line below and running the command: `delivery local functional`
# functional = ""
cleanup = "chef exec kitchen destroy"

# Remote project.toml file
#
# Instead of the local phases above, you may specify a remote URI location for
# the `project.toml` file. This is useful for teams that wish to centrally
# manage the behavior of the `delivery local` command across many different
# projects.
#
# remote_file = "https://url/project.toml"
22 changes: 22 additions & 0 deletions Jan21/cookbooks/qtlampserver/.gitignore
@@ -0,0 +1,22 @@
.vagrant
*~
*#
.#*
\#*#
.*.sw[a-z]
*.un~

# Bundler
Gemfile.lock
gems.locked
bin/*
.bundle/*

# test kitchen
.kitchen/
kitchen.local.yml

# Chef
Berksfile.lock
.zero-knife.rb
Policyfile.lock.json
3 changes: 3 additions & 0 deletions Jan21/cookbooks/qtlampserver/Berksfile
@@ -0,0 +1,3 @@
source 'https://supermarket.chef.io'

metadata
11 changes: 11 additions & 0 deletions Jan21/cookbooks/qtlampserver/CHANGELOG.md
@@ -0,0 +1,11 @@
# qtlampserver CHANGELOG

This file is used to list changes made in each version of the qtlampserver cookbook.

# 0.1.0

Initial release.

- change 0
- change 1

3 changes: 3 additions & 0 deletions Jan21/cookbooks/qtlampserver/LICENSE
@@ -0,0 +1,3 @@
Copyright 2021 The Authors

All rights reserved, do not redistribute.
4 changes: 4 additions & 0 deletions Jan21/cookbooks/qtlampserver/README.md
@@ -0,0 +1,4 @@
# qtlampserver

TODO: Enter the cookbook description here.

110 changes: 110 additions & 0 deletions Jan21/cookbooks/qtlampserver/chefignore
@@ -0,0 +1,110 @@
# Put files/directories that should be ignored in this file when uploading
# to a Chef Infra Server or Supermarket.
# Lines that start with '# ' are comments.

# OS generated files #
######################
.DS_Store
ehthumbs.db
Icon?
nohup.out
Thumbs.db

# SASS #
########
.sass-cache

# EDITORS #
###########
.#*
.project
.settings
*_flymake
*_flymake.*
*.bak
*.sw[a-z]
*.tmproj
*~
\#*
mkmf.log
REVISION
TAGS*
tmtags

## COMPILED ##
##############
*.class
*.com
*.dll
*.exe
*.o
*.pyc
*.so
*/rdoc/
a.out

# Testing #
###########
.circleci/*
.codeclimate.yml
.foodcritic
.kitchen*
.rspec
.rubocop.yml
.travis.yml
.watchr
azure-pipelines.yml
examples/*
features/*
Guardfile
kitchen.yml*
Procfile
Rakefile
spec/*
spec/*
spec/fixtures/*
test/*

# SCM #
#######
.git
.gitattributes
.gitconfig
.github/*
.gitignore
.gitmodules
.svn
*/.bzr/*
*/.git
*/.hg/*
*/.svn/*

# Berkshelf #
#############
Berksfile
Berksfile.lock
cookbooks/*
tmp

# Bundler #
###########
vendor/*
Gemfile
Gemfile.lock

# Policyfile #
##############
Policyfile.rb
Policyfile.lock.json

# Cookbooks #
#############
CHANGELOG*
CONTRIBUTING*
TESTING*
CODE_OF_CONDUCT*

# Vagrant #
###########
.vagrant
Vagrantfile
51 changes: 51 additions & 0 deletions Jan21/cookbooks/qtlampserver/kitchen.yml
@@ -0,0 +1,51 @@
---
driver:
name: ec2
aws_ssh_key_id: cheflearning
region: us-west-2
availability_zone: us-west-2b
subnet_id: subnet-80ed0eca
instance_type: t2.micro
image_id: ami-0ac73f33a1888c64a
security_group_ids: ["sg-0926fc031b2a6b92c"]

## The forwarded_port port feature lets you connect to ports on the VM guest via
## localhost on the host.
## see also: https://www.vagrantup.com/docs/networking/forwarded_ports.html

# network:
# - ["forwarded_port", {guest: 80, host: 8080}]

provisioner:
name: chef_zero
# You may wish to disable always updating cookbooks in CI or other testing environments.
# For example:
# always_update_cookbooks: <%= !ENV['CI'] %>
always_update_cookbooks: true

## product_name and product_version specifies a specific Chef product and version to install.
## see the Chef documentation for more details: https://docs.chef.io/config_yml_kitchen.html
# product_name: chef
# product_version: 15

verifier:
name: inspec

transport:
ssh_key: ./cheflearning.pem
connection_timeout: 10
connection_retries: 5
username: ubuntu

platforms:
- name: ubuntu-18.04
#- name: centos-7

suites:
- name: default
run_list:
- recipe[qtlampserver::default]
verifier:
inspec_tests:
- test/integration/default
attributes:
20 changes: 20 additions & 0 deletions Jan21/cookbooks/qtlampserver/metadata.rb
@@ -0,0 +1,20 @@
name 'qtlampserver'
maintainer 'The Authors'
maintainer_email 'you@example.com'
license 'All Rights Reserved'
description 'Installs/Configures qtlampserver'
long_description 'Installs/Configures qtlampserver'
version '0.1.0'
chef_version '>= 14.0'

# The `issues_url` points to the location where issues for this cookbook are
# tracked. A `View Issues` link will be displayed on this cookbook's page when
# uploaded to a Supermarket.
#
# issues_url 'https://github.com/<insert_org_here>/qtlampserver/issues'

# The `source_url` points to the development repository for this cookbook. A
# `View Source` link will be displayed on this cookbook's page when uploaded to
# a Supermarket.
#
# source_url 'https://github.com/<insert_org_here>/qtlampserver'
5 changes: 5 additions & 0 deletions Jan21/cookbooks/qtlampserver/recipes/default.rb
@@ -0,0 +1,5 @@
#
# Cookbook:: qtlampserver
# Recipe:: default
#
# Copyright:: 2021, The Authors, All Rights Reserved.
5 changes: 5 additions & 0 deletions Jan21/cookbooks/qtlampserver/recipes/lamp_ubuntu.rb
@@ -0,0 +1,5 @@
#
# Cookbook:: .
# Recipe:: lamp_ubuntu
#
# Copyright:: 2021, The Authors, All Rights Reserved.
2 changes: 2 additions & 0 deletions Jan21/cookbooks/qtlampserver/spec/spec_helper.rb
@@ -0,0 +1,2 @@
require 'chefspec'
require 'chefspec/berkshelf'
29 changes: 29 additions & 0 deletions Jan21/cookbooks/qtlampserver/spec/unit/recipes/default_spec.rb
@@ -0,0 +1,29 @@
#
# Cookbook:: qtlampserver
# Spec:: default
#
# Copyright:: 2021, The Authors, All Rights Reserved.

require 'spec_helper'

describe 'qtlampserver::default' do
context 'When all attributes are default, on Ubuntu 18.04' do
# for a complete list of available platforms and versions see:
# https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md
platform 'ubuntu', '18.04'

it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
end

context 'When all attributes are default, on CentOS 7' do
# for a complete list of available platforms and versions see:
# https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md
platform 'centos', '7'

it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
end
end
29 changes: 29 additions & 0 deletions Jan21/cookbooks/qtlampserver/spec/unit/recipes/lamp_ubuntu_spec.rb
@@ -0,0 +1,29 @@
#
# Cookbook:: .
# Spec:: lamp_ubuntu
#
# Copyright:: 2021, The Authors, All Rights Reserved.

require 'spec_helper'

describe '.::lamp_ubuntu' do
context 'When all attributes are default, on Ubuntu 18.04' do
# for a complete list of available platforms and versions see:
# https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md
platform 'ubuntu', '18.04'

it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
end

context 'When all attributes are default, on CentOS 7' do
# for a complete list of available platforms and versions see:
# https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md
platform 'centos', '7'

it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
end
end
@@ -0,0 +1,16 @@
# InSpec test for recipe qtlampserver::default

# The InSpec reference, with examples and extensive documentation, can be
# found at https://www.inspec.io/docs/reference/resources/

unless os.windows?
# This is an example test, replace with your own test.
describe user('root'), :skip do
it { should exist }
end
end

# This is an example test, replace it with your own test.
describe port(80), :skip do
it { should_not be_listening }
end
@@ -0,0 +1,16 @@
# InSpec test for recipe .::lamp_ubuntu

# The InSpec reference, with examples and extensive documentation, can be
# found at https://www.inspec.io/docs/reference/resources/

unless os.windows?
# This is an example test, replace with your own test.
describe user('root'), :skip do
it { should exist }
end
end

# This is an example test, replace it with your own test.
describe port(80), :skip do
it { should_not be_listening }
end

0 comments on commit 3c17055

Please sign in to comment.