Skip to content

Commit

Permalink
Added a test kitchen example with azure rm driver
Browse files Browse the repository at this point in the history
  • Loading branch information
qtsathish committed Jun 10, 2021
1 parent d4fce1a commit eb4f626
Show file tree
Hide file tree
Showing 12 changed files with 293 additions and 0 deletions.
32 changes: 32 additions & 0 deletions May21/cookbooks/qt_apache/.delivery/project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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 = "echo skipping unit phase."
lint = "chef exec cookstyle"
# foodcritic has been deprecated in favor of cookstyle so we skip the syntax
# phase now.
syntax = "echo skipping syntax phase. Use lint phase instead."
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"
25 changes: 25 additions & 0 deletions May21/cookbooks/qt_apache/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.vagrant
*~
*#
.#*
\#*#
.*.sw[a-z]
*.un~

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

# test kitchen
.kitchen/
kitchen.local.yml

# Chef Infra
Berksfile.lock
.zero-knife.rb
Policyfile.lock.json

.idea/

5 changes: 5 additions & 0 deletions May21/cookbooks/qt_apache/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"chef-software.chef"
]
}
3 changes: 3 additions & 0 deletions May21/cookbooks/qt_apache/Berksfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://supermarket.chef.io'

metadata
10 changes: 10 additions & 0 deletions May21/cookbooks/qt_apache/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# qt_apache CHANGELOG

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

## 0.1.0

Initial release.

- change 0
- change 1
3 changes: 3 additions & 0 deletions May21/cookbooks/qt_apache/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Copyright 2021 The Authors

All rights reserved, do not redistribute.
4 changes: 4 additions & 0 deletions May21/cookbooks/qt_apache/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# qt_apache

TODO: Enter the cookbook description here.

115 changes: 115 additions & 0 deletions May21/cookbooks/qt_apache/chefignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# 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
.envrc

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

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

# Testing #
###########
.circleci/*
.codeclimate.yml
.delivery/*
.foodcritic
.kitchen*
.mdlrc
.overcommit.yml
.rspec
.rubocop.yml
.travis.yml
.watchr
.yamllint
azure-pipelines.yml
Dangerfile
examples/*
features/*
Guardfile
kitchen.yml*
mlc_config.json
Procfile
Rakefile
spec/*
test/*

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

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

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

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

# Documentation #
#############
CODE_OF_CONDUCT*
CONTRIBUTING*
documentation/*
TESTING*
UPGRADING*

# Vagrant #
###########
.vagrant
Vagrantfile
46 changes: 46 additions & 0 deletions May21/cookbooks/qt_apache/kitchen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
driver:
name: azurerm
subscription_id: "your subscription id here"
location: "eastus"
machine_size: Standard_B1s
username: qtdevops
password: motherindia@123
#destroy_resource_group_contents: true

## 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

# 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/workstation/config_yml_kitchen/
# product_name: chef
# product_version: 16

verifier:
name: inspec

platforms:
- name: ubuntu-18.04
driver:
image_urn: Canonical:UbuntuServer:18.04-LTS:latest
#- name: centos-8

suites:
- name: default
run_list:
- recipe[qt_apache::default]
verifier:
inspec_tests:
- test/integration/default
attributes:
19 changes: 19 additions & 0 deletions May21/cookbooks/qt_apache/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name 'qt_apache'
maintainer 'The Authors'
maintainer_email 'you@example.com'
license 'All Rights Reserved'
description 'Installs/Configures qt_apache'
version '0.1.0'
chef_version '>= 15.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>/qt_apache/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>/qt_apache'
15 changes: 15 additions & 0 deletions May21/cookbooks/qt_apache/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Cookbook:: qt_apache
# Recipe:: default
#
# Copyright:: 2021, The Authors, All Rights Reserved.

apt_update 'update packages' do
ignore_failure true
action :update
end

package 'apache2' do
action :install
end

16 changes: 16 additions & 0 deletions May21/cookbooks/qt_apache/test/integration/default/default_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# InSpec test for recipe qt_apache::default

# The Chef InSpec reference, with examples and extensive documentation, can be
# found at https://docs.chef.io/inspec/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 eb4f626

Please sign in to comment.