From 7532bcaeed6f2f0349e66eebc2f137cc2487e5f9 Mon Sep 17 00:00:00 2001 From: stellarsquall Date: Thu, 20 Dec 2018 18:18:56 -0600 Subject: [PATCH] initial commit --- .../begin/workstation/.gitignore | 16 ++++ .../begin/workstation/.kitchen.yml | 21 ++++ .../begin/workstation/Berksfile | 3 + .../begin/workstation/README.md | 4 + .../begin/workstation/chefignore | 95 +++++++++++++++++++ .../begin/workstation/metadata.rb | 8 ++ .../begin/workstation/recipes/default.rb | 16 ++++ .../begin/workstation/recipes/setup.rb | 24 +++++ .../begin/workstation/spec/spec_helper.rb | 2 + .../spec/unit/recipes/default_spec.rb | 27 ++++++ .../begin/workstation/templates/motd.erb | 5 + .../workstation/test/recipes/default_test.rb | 19 ++++ .../end/workstation/.gitignore | 16 ++++ .../end/workstation/.kitchen.yml | 21 ++++ .../end/workstation/Berksfile | 3 + .../end/workstation/README.md | 4 + .../end/workstation/chefignore | 95 +++++++++++++++++++ .../end/workstation/metadata.rb | 8 ++ .../end/workstation/recipes/default.rb | 16 ++++ .../end/workstation/recipes/setup.rb | 24 +++++ .../end/workstation/spec/spec_helper.rb | 2 + .../spec/unit/recipes/default_spec.rb | 27 ++++++ .../end/workstation/templates/motd.erb | 5 + .../workstation/test/recipes/default_test.rb | 19 ++++ 24 files changed, 480 insertions(+) create mode 100755 07-4 Adding A Template/begin/workstation/.gitignore create mode 100755 07-4 Adding A Template/begin/workstation/.kitchen.yml create mode 100755 07-4 Adding A Template/begin/workstation/Berksfile create mode 100755 07-4 Adding A Template/begin/workstation/README.md create mode 100755 07-4 Adding A Template/begin/workstation/chefignore create mode 100755 07-4 Adding A Template/begin/workstation/metadata.rb create mode 100755 07-4 Adding A Template/begin/workstation/recipes/default.rb create mode 100755 07-4 Adding A Template/begin/workstation/recipes/setup.rb create mode 100755 07-4 Adding A Template/begin/workstation/spec/spec_helper.rb create mode 100755 07-4 Adding A Template/begin/workstation/spec/unit/recipes/default_spec.rb create mode 100755 07-4 Adding A Template/begin/workstation/templates/motd.erb create mode 100755 07-4 Adding A Template/begin/workstation/test/recipes/default_test.rb create mode 100755 07-4 Adding A Template/end/workstation/.gitignore create mode 100755 07-4 Adding A Template/end/workstation/.kitchen.yml create mode 100755 07-4 Adding A Template/end/workstation/Berksfile create mode 100755 07-4 Adding A Template/end/workstation/README.md create mode 100755 07-4 Adding A Template/end/workstation/chefignore create mode 100755 07-4 Adding A Template/end/workstation/metadata.rb create mode 100755 07-4 Adding A Template/end/workstation/recipes/default.rb create mode 100755 07-4 Adding A Template/end/workstation/recipes/setup.rb create mode 100755 07-4 Adding A Template/end/workstation/spec/spec_helper.rb create mode 100755 07-4 Adding A Template/end/workstation/spec/unit/recipes/default_spec.rb create mode 100755 07-4 Adding A Template/end/workstation/templates/motd.erb create mode 100755 07-4 Adding A Template/end/workstation/test/recipes/default_test.rb diff --git a/07-4 Adding A Template/begin/workstation/.gitignore b/07-4 Adding A Template/begin/workstation/.gitignore new file mode 100755 index 0000000..ec2a890 --- /dev/null +++ b/07-4 Adding A Template/begin/workstation/.gitignore @@ -0,0 +1,16 @@ +.vagrant +Berksfile.lock +*~ +*# +.#* +\#*# +.*.sw[a-z] +*.un~ + +# Bundler +Gemfile.lock +bin/* +.bundle/* + +.kitchen/ +.kitchen.local.yml diff --git a/07-4 Adding A Template/begin/workstation/.kitchen.yml b/07-4 Adding A Template/begin/workstation/.kitchen.yml new file mode 100755 index 0000000..78d2660 --- /dev/null +++ b/07-4 Adding A Template/begin/workstation/.kitchen.yml @@ -0,0 +1,21 @@ +--- +driver: + name: vagrant + +provisioner: + name: chef_zero + +verifier: + name: inspec + +platforms: + - name: centos-6.7 + +suites: + - name: default + run_list: + - recipe[workstation::default] + verifier: + inspec_tests: + - test/recipes + attributes: diff --git a/07-4 Adding A Template/begin/workstation/Berksfile b/07-4 Adding A Template/begin/workstation/Berksfile new file mode 100755 index 0000000..967b9a7 --- /dev/null +++ b/07-4 Adding A Template/begin/workstation/Berksfile @@ -0,0 +1,3 @@ +source "https://supermarket.chef.io" + +metadata diff --git a/07-4 Adding A Template/begin/workstation/README.md b/07-4 Adding A Template/begin/workstation/README.md new file mode 100755 index 0000000..c28ed2b --- /dev/null +++ b/07-4 Adding A Template/begin/workstation/README.md @@ -0,0 +1,4 @@ +# workstation + +TODO: Enter the cookbook description here. + diff --git a/07-4 Adding A Template/begin/workstation/chefignore b/07-4 Adding A Template/begin/workstation/chefignore new file mode 100755 index 0000000..80dc2d2 --- /dev/null +++ b/07-4 Adding A Template/begin/workstation/chefignore @@ -0,0 +1,95 @@ +# Put files/directories that should be ignored in this file when uploading +# or sharing to the community site. +# Lines that start with '# ' are comments. + +# OS generated files # +###################### +.DS_Store +Icon? +nohup.out +ehthumbs.db +Thumbs.db + +# SASS # +######## +.sass-cache + +# EDITORS # +########### +\#* +.#* +*~ +*.sw[a-z] +*.bak +REVISION +TAGS* +tmtags +*_flymake.* +*_flymake +*.tmproj +.project +.settings +mkmf.log + +## COMPILED ## +############## +a.out +*.o +*.pyc +*.so +*.com +*.class +*.dll +*.exe +*/rdoc/ + +# Testing # +########### +.watchr +.rspec +spec/* +spec/fixtures/* +test/* +features/* +Guardfile +Procfile + +# SCM # +####### +.git +*/.git +.gitignore +.gitmodules +.gitconfig +.gitattributes +.svn +*/.bzr/* +*/.hg/* +*/.svn/* + +# Berkshelf # +############# +Berksfile +Berksfile.lock +cookbooks/* +tmp + +# Cookbooks # +############# +CONTRIBUTING + +# Strainer # +############ +Colanderfile +Strainerfile +.colander +.strainer + +# Vagrant # +########### +.vagrant +Vagrantfile + +# Travis # +########## +.travis.yml diff --git a/07-4 Adding A Template/begin/workstation/metadata.rb b/07-4 Adding A Template/begin/workstation/metadata.rb new file mode 100755 index 0000000..27ff1c2 --- /dev/null +++ b/07-4 Adding A Template/begin/workstation/metadata.rb @@ -0,0 +1,8 @@ +name 'workstation' +maintainer 'The Authors' +maintainer_email 'you@example.com' +license 'all_rights' +description 'Installs/Configures workstation' +long_description 'Installs/Configures workstation' +version '0.2.1' + diff --git a/07-4 Adding A Template/begin/workstation/recipes/default.rb b/07-4 Adding A Template/begin/workstation/recipes/default.rb new file mode 100755 index 0000000..18ff117 --- /dev/null +++ b/07-4 Adding A Template/begin/workstation/recipes/default.rb @@ -0,0 +1,16 @@ +# +# Cookbook Name:: workstation +# Recipe:: default +# +# Copyright (c) 2015 The Authors, All Rights Reserved. + + +# +# The default recipe is the recipe that the cookbook is know most for +# accomplishing. It is often the practice to use this file to include specific +# recipes that perform a specific task. +# +# @see http://docs.chef.io/recipes.html#include-recipes +# + +include_recipe 'workstation::setup' diff --git a/07-4 Adding A Template/begin/workstation/recipes/setup.rb b/07-4 Adding A Template/begin/workstation/recipes/setup.rb new file mode 100755 index 0000000..6d24eeb --- /dev/null +++ b/07-4 Adding A Template/begin/workstation/recipes/setup.rb @@ -0,0 +1,24 @@ +# +# Cookbook Name:: workstation +# Recipe:: setup +# +# Copyright (c) 2015 The Authors, All Rights Reserved. + +package 'nano' +# or package 'vim-enhanced' + +package 'ntp' + +package 'git' do + action :install +end + +file '/etc/motd' do + content "This server is the property of Chef + HOSTNAME: #{node['hostname']} + IPADDRESS: #{node['ipaddress']} + CPU: #{node['cpu']['0']['mhz']} + MEMORY: #{node['memory']['total']} + " + action :create +end \ No newline at end of file diff --git a/07-4 Adding A Template/begin/workstation/spec/spec_helper.rb b/07-4 Adding A Template/begin/workstation/spec/spec_helper.rb new file mode 100755 index 0000000..1dd5126 --- /dev/null +++ b/07-4 Adding A Template/begin/workstation/spec/spec_helper.rb @@ -0,0 +1,2 @@ +require 'chefspec' +require 'chefspec/berkshelf' diff --git a/07-4 Adding A Template/begin/workstation/spec/unit/recipes/default_spec.rb b/07-4 Adding A Template/begin/workstation/spec/unit/recipes/default_spec.rb new file mode 100755 index 0000000..93ae243 --- /dev/null +++ b/07-4 Adding A Template/begin/workstation/spec/unit/recipes/default_spec.rb @@ -0,0 +1,27 @@ +# +# Cookbook Name:: workstation +# Spec:: default +# +# Copyright (c) 2015 The Authors, All Rights Reserved. + +require 'spec_helper' + +describe 'workstation::default' do + + context 'When all attributes are default, on an unspecified platform' do + + let(:chef_run) do + runner = ChefSpec::ServerRunner.new + runner.converge(described_recipe) + end + + it 'installs tree' do + expect(chef_run).to install_package('tree') + end + + it 'creates an /etc/motd' do + expect(chef_run).to create_template('/etc/motd') + end + + end +end diff --git a/07-4 Adding A Template/begin/workstation/templates/motd.erb b/07-4 Adding A Template/begin/workstation/templates/motd.erb new file mode 100755 index 0000000..84d5422 --- /dev/null +++ b/07-4 Adding A Template/begin/workstation/templates/motd.erb @@ -0,0 +1,5 @@ +This server is the property of Chef + HOSTNAME: <%= node['hostname'] %> + IPADDRESS: <%= node['ipaddress'] %> + CPU: <%= node['cpu']['0']['mhz'] %> + MEMORY: <%= node['memory']['total'] %> \ No newline at end of file diff --git a/07-4 Adding A Template/begin/workstation/test/recipes/default_test.rb b/07-4 Adding A Template/begin/workstation/test/recipes/default_test.rb new file mode 100755 index 0000000..72a80cc --- /dev/null +++ b/07-4 Adding A Template/begin/workstation/test/recipes/default_test.rb @@ -0,0 +1,19 @@ +# # encoding: utf-8 + +# Inspec test for recipe apache::default + +# The Inspec reference, with examples and extensive documentation, can be +# found at https://docs.chef.io/inspec_reference.html + +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 + \ No newline at end of file diff --git a/07-4 Adding A Template/end/workstation/.gitignore b/07-4 Adding A Template/end/workstation/.gitignore new file mode 100755 index 0000000..ec2a890 --- /dev/null +++ b/07-4 Adding A Template/end/workstation/.gitignore @@ -0,0 +1,16 @@ +.vagrant +Berksfile.lock +*~ +*# +.#* +\#*# +.*.sw[a-z] +*.un~ + +# Bundler +Gemfile.lock +bin/* +.bundle/* + +.kitchen/ +.kitchen.local.yml diff --git a/07-4 Adding A Template/end/workstation/.kitchen.yml b/07-4 Adding A Template/end/workstation/.kitchen.yml new file mode 100755 index 0000000..78d2660 --- /dev/null +++ b/07-4 Adding A Template/end/workstation/.kitchen.yml @@ -0,0 +1,21 @@ +--- +driver: + name: vagrant + +provisioner: + name: chef_zero + +verifier: + name: inspec + +platforms: + - name: centos-6.7 + +suites: + - name: default + run_list: + - recipe[workstation::default] + verifier: + inspec_tests: + - test/recipes + attributes: diff --git a/07-4 Adding A Template/end/workstation/Berksfile b/07-4 Adding A Template/end/workstation/Berksfile new file mode 100755 index 0000000..967b9a7 --- /dev/null +++ b/07-4 Adding A Template/end/workstation/Berksfile @@ -0,0 +1,3 @@ +source "https://supermarket.chef.io" + +metadata diff --git a/07-4 Adding A Template/end/workstation/README.md b/07-4 Adding A Template/end/workstation/README.md new file mode 100755 index 0000000..c28ed2b --- /dev/null +++ b/07-4 Adding A Template/end/workstation/README.md @@ -0,0 +1,4 @@ +# workstation + +TODO: Enter the cookbook description here. + diff --git a/07-4 Adding A Template/end/workstation/chefignore b/07-4 Adding A Template/end/workstation/chefignore new file mode 100755 index 0000000..80dc2d2 --- /dev/null +++ b/07-4 Adding A Template/end/workstation/chefignore @@ -0,0 +1,95 @@ +# Put files/directories that should be ignored in this file when uploading +# or sharing to the community site. +# Lines that start with '# ' are comments. + +# OS generated files # +###################### +.DS_Store +Icon? +nohup.out +ehthumbs.db +Thumbs.db + +# SASS # +######## +.sass-cache + +# EDITORS # +########### +\#* +.#* +*~ +*.sw[a-z] +*.bak +REVISION +TAGS* +tmtags +*_flymake.* +*_flymake +*.tmproj +.project +.settings +mkmf.log + +## COMPILED ## +############## +a.out +*.o +*.pyc +*.so +*.com +*.class +*.dll +*.exe +*/rdoc/ + +# Testing # +########### +.watchr +.rspec +spec/* +spec/fixtures/* +test/* +features/* +Guardfile +Procfile + +# SCM # +####### +.git +*/.git +.gitignore +.gitmodules +.gitconfig +.gitattributes +.svn +*/.bzr/* +*/.hg/* +*/.svn/* + +# Berkshelf # +############# +Berksfile +Berksfile.lock +cookbooks/* +tmp + +# Cookbooks # +############# +CONTRIBUTING + +# Strainer # +############ +Colanderfile +Strainerfile +.colander +.strainer + +# Vagrant # +########### +.vagrant +Vagrantfile + +# Travis # +########## +.travis.yml diff --git a/07-4 Adding A Template/end/workstation/metadata.rb b/07-4 Adding A Template/end/workstation/metadata.rb new file mode 100755 index 0000000..27ff1c2 --- /dev/null +++ b/07-4 Adding A Template/end/workstation/metadata.rb @@ -0,0 +1,8 @@ +name 'workstation' +maintainer 'The Authors' +maintainer_email 'you@example.com' +license 'all_rights' +description 'Installs/Configures workstation' +long_description 'Installs/Configures workstation' +version '0.2.1' + diff --git a/07-4 Adding A Template/end/workstation/recipes/default.rb b/07-4 Adding A Template/end/workstation/recipes/default.rb new file mode 100755 index 0000000..18ff117 --- /dev/null +++ b/07-4 Adding A Template/end/workstation/recipes/default.rb @@ -0,0 +1,16 @@ +# +# Cookbook Name:: workstation +# Recipe:: default +# +# Copyright (c) 2015 The Authors, All Rights Reserved. + + +# +# The default recipe is the recipe that the cookbook is know most for +# accomplishing. It is often the practice to use this file to include specific +# recipes that perform a specific task. +# +# @see http://docs.chef.io/recipes.html#include-recipes +# + +include_recipe 'workstation::setup' diff --git a/07-4 Adding A Template/end/workstation/recipes/setup.rb b/07-4 Adding A Template/end/workstation/recipes/setup.rb new file mode 100755 index 0000000..8e206d4 --- /dev/null +++ b/07-4 Adding A Template/end/workstation/recipes/setup.rb @@ -0,0 +1,24 @@ +# +# Cookbook Name:: workstation +# Recipe:: setup +# +# Copyright (c) 2015 The Authors, All Rights Reserved. + +# ~/cookbooks/workstation/recipes/setup.rb + +package 'nano' +# or package 'vim-enhanced' +package 'ntp' + +package 'tree' do + action :install +end + +package 'git' do + action :install +end + +template '/etc/motd' do + source 'motd.erb' + action :create +end \ No newline at end of file diff --git a/07-4 Adding A Template/end/workstation/spec/spec_helper.rb b/07-4 Adding A Template/end/workstation/spec/spec_helper.rb new file mode 100755 index 0000000..1dd5126 --- /dev/null +++ b/07-4 Adding A Template/end/workstation/spec/spec_helper.rb @@ -0,0 +1,2 @@ +require 'chefspec' +require 'chefspec/berkshelf' diff --git a/07-4 Adding A Template/end/workstation/spec/unit/recipes/default_spec.rb b/07-4 Adding A Template/end/workstation/spec/unit/recipes/default_spec.rb new file mode 100755 index 0000000..93ae243 --- /dev/null +++ b/07-4 Adding A Template/end/workstation/spec/unit/recipes/default_spec.rb @@ -0,0 +1,27 @@ +# +# Cookbook Name:: workstation +# Spec:: default +# +# Copyright (c) 2015 The Authors, All Rights Reserved. + +require 'spec_helper' + +describe 'workstation::default' do + + context 'When all attributes are default, on an unspecified platform' do + + let(:chef_run) do + runner = ChefSpec::ServerRunner.new + runner.converge(described_recipe) + end + + it 'installs tree' do + expect(chef_run).to install_package('tree') + end + + it 'creates an /etc/motd' do + expect(chef_run).to create_template('/etc/motd') + end + + end +end diff --git a/07-4 Adding A Template/end/workstation/templates/motd.erb b/07-4 Adding A Template/end/workstation/templates/motd.erb new file mode 100755 index 0000000..84d5422 --- /dev/null +++ b/07-4 Adding A Template/end/workstation/templates/motd.erb @@ -0,0 +1,5 @@ +This server is the property of Chef + HOSTNAME: <%= node['hostname'] %> + IPADDRESS: <%= node['ipaddress'] %> + CPU: <%= node['cpu']['0']['mhz'] %> + MEMORY: <%= node['memory']['total'] %> \ No newline at end of file diff --git a/07-4 Adding A Template/end/workstation/test/recipes/default_test.rb b/07-4 Adding A Template/end/workstation/test/recipes/default_test.rb new file mode 100755 index 0000000..72a80cc --- /dev/null +++ b/07-4 Adding A Template/end/workstation/test/recipes/default_test.rb @@ -0,0 +1,19 @@ +# # encoding: utf-8 + +# Inspec test for recipe apache::default + +# The Inspec reference, with examples and extensive documentation, can be +# found at https://docs.chef.io/inspec_reference.html + +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 + \ No newline at end of file