Skip to content

Commit

Permalink
Added cookbook for utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
directdevops committed Jan 30, 2021
1 parent df6f3cc commit 15b8e8c
Show file tree
Hide file tree
Showing 18 changed files with 357 additions and 7 deletions.
7 changes: 0 additions & 7 deletions Jan21/chef-repo/cookbooks/hellochef/Berksfile.lock

This file was deleted.

34 changes: 34 additions & 0 deletions Jan21/chef-repo/cookbooks/ltutils/.delivery/project.toml
Original file line number Original file line Diff line number Diff line change
@@ -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/chef-repo/cookbooks/ltutils/.gitignore
Original file line number Original file line Diff line number Diff line change
@@ -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/chef-repo/cookbooks/ltutils/Berksfile
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://supermarket.chef.io'

metadata
11 changes: 11 additions & 0 deletions Jan21/chef-repo/cookbooks/ltutils/CHANGELOG.md
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,11 @@
# ltutils CHANGELOG

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

# 0.1.0

Initial release.

- change 0
- change 1

3 changes: 3 additions & 0 deletions Jan21/chef-repo/cookbooks/ltutils/LICENSE
Original file line number Original file line 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 Jan21/chef-repo/cookbooks/ltutils/README.md
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,4 @@
# ltutils

TODO: Enter the cookbook description here.

1 change: 1 addition & 0 deletions Jan21/chef-repo/cookbooks/ltutils/attributes/default.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1 @@
default['ltutils']['utilpackages'] = [ 'git', 'tree']
110 changes: 110 additions & 0 deletions Jan21/chef-repo/cookbooks/ltutils/chefignore
Original file line number Original file line Diff line number Diff line change
@@ -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
38 changes: 38 additions & 0 deletions Jan21/chef-repo/cookbooks/ltutils/kitchen.yml
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,38 @@
---
driver:
name: vagrant

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

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

suites:
- name: default
run_list:
- recipe[ltutils::default]
verifier:
inspec_tests:
- test/integration/default
attributes:
20 changes: 20 additions & 0 deletions Jan21/chef-repo/cookbooks/ltutils/metadata.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,20 @@
name 'ltutils'
maintainer 'The Authors'
maintainer_email 'qtdevops@gmail.com'
license 'All Rights Reserved'
description 'Installs/Configures ltutils'
long_description 'Installs/Configures ltutils'
version '1.0.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>/ltutils/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>/ltutils'
5 changes: 5 additions & 0 deletions Jan21/chef-repo/cookbooks/ltutils/recipes/default.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# Cookbook:: ltutils
# Recipe:: default
#
# Copyright:: 2021, The Authors, All Rights Reserved.
14 changes: 14 additions & 0 deletions Jan21/chef-repo/cookbooks/ltutils/recipes/utils.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Cookbook:: .
# Recipe:: utils
#
# Copyright:: 2021, The Authors, All Rights Reserved.

utilpackages = node['ltutils']['utilpackages']

utilpackages.each do |utilpackage|
package utilpackage do
action :install
end

end
2 changes: 2 additions & 0 deletions Jan21/chef-repo/cookbooks/ltutils/spec/spec_helper.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,2 @@
require 'chefspec'
require 'chefspec/berkshelf'
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# Cookbook:: ltutils
# Spec:: default
#
# Copyright:: 2021, The Authors, All Rights Reserved.

require 'spec_helper'

describe 'ltutils::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/chef-repo/cookbooks/ltutils/spec/unit/recipes/utils_spec.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# Cookbook:: .
# Spec:: utils
#
# Copyright:: 2021, The Authors, All Rights Reserved.

require 'spec_helper'

describe '.::utils' 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
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,16 @@
# InSpec test for recipe ltutils::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
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,16 @@
# InSpec test for recipe .::utils

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

Please sign in to comment.