From de46c641f41f6d153f6563a6793288ee341bce2b Mon Sep 17 00:00:00 2001 From: krattan406 <30876207+krattan406@users.noreply.github.com> Date: Mon, 12 Feb 2018 00:35:35 -0500 Subject: [PATCH 01/12] Add files via upload --- 1_MongoDB/README.md | 172 +++++++++++++++--- 1_MongoDB/cookbooks/mongodb/Berksfile | 4 + 1_MongoDB/cookbooks/mongodb/LICENSE | 3 + 1_MongoDB/cookbooks/mongodb/README.md | 4 + 1_MongoDB/cookbooks/mongodb/chefignore | 107 +++++++++++ 1_MongoDB/cookbooks/mongodb/metadata.rb | 20 ++ .../cookbooks/mongodb/recipes/default.rb | 43 +++++ .../cookbooks/mongodb/spec/spec_helper.rb | 3 + .../mongodb/spec/unit/recipes/default_spec.rb | 35 ++++ .../test/smoke/default/default_test.rb | 18 ++ 10 files changed, 379 insertions(+), 30 deletions(-) create mode 100644 1_MongoDB/cookbooks/mongodb/Berksfile create mode 100644 1_MongoDB/cookbooks/mongodb/LICENSE create mode 100644 1_MongoDB/cookbooks/mongodb/README.md create mode 100644 1_MongoDB/cookbooks/mongodb/chefignore create mode 100644 1_MongoDB/cookbooks/mongodb/metadata.rb create mode 100644 1_MongoDB/cookbooks/mongodb/recipes/default.rb create mode 100644 1_MongoDB/cookbooks/mongodb/spec/spec_helper.rb create mode 100644 1_MongoDB/cookbooks/mongodb/spec/unit/recipes/default_spec.rb create mode 100644 1_MongoDB/cookbooks/mongodb/test/smoke/default/default_test.rb diff --git a/1_MongoDB/README.md b/1_MongoDB/README.md index 70b32d8..0dc6ca3 100644 --- a/1_MongoDB/README.md +++ b/1_MongoDB/README.md @@ -1,45 +1,157 @@ -# Install MongoDB +###1 - Setup & Environment #### -MongoDB is an open-source, document-oriented database designed for ease of development and scaling. The MongoDB documentation site includes a [tutorial on how to install MongoDB on RHEL-based system](http://docs.mongodb.org/manual/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux/). +1) Downloaded and install VirtualBox running CentOs 7 - Linux 64 bit +2) Install chef in the virtual machine using the command: +> $ sudo rpm -Uvh https://packages.chef.io/files/stable/chefdk/2.4.17/el/7/chefdk-2.4.17-1.el7.x86_64.rpm -## Goal +# 1 - RESULT : +Retrieving https://packages.chef.io/files/stable/chefdk/2.4.17/el/7/chefdk-2.4.17-1.el7.x86_64.rpm +warning: /var/tmp/rpm-tmp.b3AyNw: Header V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY +Preparing... ########################################### [100%] + 1:chefdk ########################################### [100%] +Thank you for installing Chef Development Kit! -Use Chef to successfully install MongoDB on a RHEL-based target system. +# 3) Checked the Ruby version & set path to chef sdk version +Ruby Version set to chef sdk ver: +echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> ~/.configuration_file && source ~/.configuration_file -## Success Criteria + echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> ~/.bash_profile && source ~/.bash_profile -You should be prepared and able to demonstrate the following: -* Your Chef cookbook successfully executes on your target node without errors -* Your Chef cookbook is portable and can be run by Chef to validate your work. Please include any instructions or assumptions needed to successfully execute your cookbook. -* You can login to MongoDB by typing `mongo` on the target system -* You can run `chef-client` multiple times without failures -* Your GitHub.com source code repository shows the history of your work +##### End of setup ##### -You should be able to explain the following: +## 2 - Create a directory called mongo-chef. +# We will use this directory to store the recipe to install mongo Db +# We have already downloaded chef Sdk in the previous step -* Steps taken to achieve the end result -* Build and test process of Chef code -* Tools and resources used in the process + - Rebooted my Virtual box and logged in as root ->Note: You are NOT required to use Chef Server for this exercise, but you may if that is your preference. + - create a dir for chef repository, here we will generate and store all our cookbooks. + +[root@osboxes /]# mkdir mongo-chef +ls +mkdir cookbooks +ls + +# RESULT: +[root@osboxes mongo-chef]# ls +cookbooks + +# 3 COOKBOOK : Next, generate a cookbook for all mongoldb installation instructions: +[root@osboxes mongo-chef]# chef generate cookbook cookbooks/mongodb + +# RESULT: + +Generating cookbook mongodb +- Ensuring correct cookbook file content +- Ensuring delivery configuration +- Ensuring correct delivery build cookbook content +Your cookbook is ready. Type `cd cookbooks/mongodb` to enter it. + +# Check the directory structure. I have already installed the tree package to view directories as tree + +[root@osboxes mongodb]# tree +. +├── Berksfile +├── chefignore +├── LICENSE +├── metadata.rb +├── README.md +├── recipes +│   └── default.rb +├── spec +│   ├── spec_helper.rb +│   └── unit +│   └── recipes +│   └── default_spec.rb +└── test + └── smoke + └── default + └── default_test.rb + +7 directories, 9 files + +# 4 Create a recipe file where I will enter the resources and actions to perform on each resource to install mongoldb. + +# Now run the Cookbook: +[root@osboxes recipes]# chef-client --local-mode install.rb + +# RESULT - 5X unsuccessful runs with errors - please see unsucessful runs.txt, with possible issues and solutions. + +## +# Cookbook:: mongodb +# Recipe:: default +# +# Copyright:: 2018, The Authors, All Rights Reserved. + +# add yum clean all. +# yum update + + +yum_repository 'mongodb' do + description "MongoDB Repository" + baseurl "http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/" + gpgcheck false + enabled true + action :create +end + +package 'mongodb-org' do + :install +end + + +#service mongod start + +service 'mongod' do + #supports : restart => true + action [:enable, :start] +end + + +execute 'chkconfig' do + #command 'mongo --host 127.0.0.1:27017' + command 'sudo mongo' + action :run + live_stream true +ignore_failure true +end + +# RESULT: + +Starting Chef Client, version 13.6.4 +resolving cookbooks for run list: [] +Synchronizing Cookbooks: +Installing Cookbook Gems: +Compiling Cookbooks... +[2018-02-11T18:28:59-05:00] WARN: Node osboxes has an empty run list. +[2018-02-11T18:28:59-05:00] WARN: Node osboxes has an empty run list. +Converging 4 resources +Recipe: @recipe_files::/mongo-chef/cookbooks/mongodb/recipes/default.rb + * yum_repository[mongodb] action create + * template[/etc/yum.repos.d/mongodb.repo] action create (up to date) + * execute[yum clean metadata mongodb] action nothing (skipped due to action :nothing) + * execute[yum-makecache-mongodb] action nothing (skipped due to action :nothing) + * ruby_block[yum-cache-reload-mongodb] action nothing (skipped due to action :nothing) + (up to date) + * yum_package[mongodb-org] action install (up to date) + * service[mongod] action enable (up to date) + * service[mongod] action start (up to date) + * execute[chkconfig] action run + [execute] MongoDB shell version v3.6.2 + connecting to: mongodb://127.0.0.1:27017 + MongoDB server version: 3.6.2 + bye + - execute sudo mongo + +Running handlers: +Running handlers complete +Chef Client finished, 1/9 resources updated in 10 seconds +[2018-02-11T18:29:05-05:00] WARN: No config file found or specified on command line, using command line options. +[2018-02-11T18:29:05-05:00] WARN: No config file found or specified on command line, using command line options. -## Instructions -* Translate the MongoDB installation instructions from `install.rb` into Chef code that completes the installation -* Use the Chef [Resources Reference](https://docs.chef.io/resources.html) to find the most appropriate Chef resources to use for each task -* Once you feel you have met the success criteria outlined above, send a link to your GitHub.com repo to the person coordinating these workshops -* Provide instructions for us to run your cookbook so that we can test your work. -There are a couple of ways that you can write, test and run your cookbook. -* Write and test your cookbook locally using Test Kitchen via Vagrant + Virtual Box, or the cloud platform of your choice. - * Steps for this option are outlined [here](https://learn.chef.io/tutorials/local-development/) -* Develop directly on your RHEL-based virtual machine - * Write your cookbook in vim, nano or emacs, and run `chef-client` in `--local-mode` - * The ChefDK or Chef Client must be installed on the VM first -## Suggested Resources -* Use the [Chef Documentation](http://docs.chef.io) to identify and use resources that will help you model the desired state of your infrastructure. -* [MongoDB Installation Instructions](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/) diff --git a/1_MongoDB/cookbooks/mongodb/Berksfile b/1_MongoDB/cookbooks/mongodb/Berksfile new file mode 100644 index 0000000..0656a99 --- /dev/null +++ b/1_MongoDB/cookbooks/mongodb/Berksfile @@ -0,0 +1,4 @@ +# frozen_string_literal: true +source 'https://supermarket.chef.io' + +metadata diff --git a/1_MongoDB/cookbooks/mongodb/LICENSE b/1_MongoDB/cookbooks/mongodb/LICENSE new file mode 100644 index 0000000..a27e740 --- /dev/null +++ b/1_MongoDB/cookbooks/mongodb/LICENSE @@ -0,0 +1,3 @@ +Copyright 2018 The Authors + +All rights reserved, do not redistribute. diff --git a/1_MongoDB/cookbooks/mongodb/README.md b/1_MongoDB/cookbooks/mongodb/README.md new file mode 100644 index 0000000..32dc913 --- /dev/null +++ b/1_MongoDB/cookbooks/mongodb/README.md @@ -0,0 +1,4 @@ +# mongodb + +TODO: Enter the cookbook description here. + diff --git a/1_MongoDB/cookbooks/mongodb/chefignore b/1_MongoDB/cookbooks/mongodb/chefignore new file mode 100644 index 0000000..38e7379 --- /dev/null +++ b/1_MongoDB/cookbooks/mongodb/chefignore @@ -0,0 +1,107 @@ +# Put files/directories that should be ignored in this file when uploading +# to a chef-server or supermarket. +# 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/* +examples/* +Guardfile +Procfile +.kitchen* +.rubocop.yml +spec/* +Rakefile +.travis.yml +.foodcritic +.codeclimate.yml + +# SCM # +####### +.git +*/.git +.gitignore +.gitmodules +.gitconfig +.gitattributes +.svn +*/.bzr/* +*/.hg/* +*/.svn/* + +# Berkshelf # +############# +Berksfile +Berksfile.lock +cookbooks/* +tmp + +# Policyfile # +############## +Policyfile.rb +Policyfile.lock.json + +# Cookbooks # +############# +CONTRIBUTING* +CHANGELOG* +TESTING* +MAINTAINERS.toml + +# Strainer # +############ +Colanderfile +Strainerfile +.colander +.strainer + +# Vagrant # +########### +.vagrant +Vagrantfile diff --git a/1_MongoDB/cookbooks/mongodb/metadata.rb b/1_MongoDB/cookbooks/mongodb/metadata.rb new file mode 100644 index 0000000..588abb2 --- /dev/null +++ b/1_MongoDB/cookbooks/mongodb/metadata.rb @@ -0,0 +1,20 @@ +name 'mongodb' +maintainer 'The Authors' +maintainer_email 'you@example.com' +license 'All Rights Reserved' +description 'Installs/Configures mongodb' +long_description 'Installs/Configures mongodb' +version '0.1.0' +chef_version '>= 12.1' if respond_to?(:chef_version) + +# 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//mongodb/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//mongodb' diff --git a/1_MongoDB/cookbooks/mongodb/recipes/default.rb b/1_MongoDB/cookbooks/mongodb/recipes/default.rb new file mode 100644 index 0000000..e81e6a8 --- /dev/null +++ b/1_MongoDB/cookbooks/mongodb/recipes/default.rb @@ -0,0 +1,43 @@ +# +# Cookbook:: mongodb +# Recipe:: default +# +# Copyright:: 2018, The Authors, All Rights Reserved. + +# add yum clean all. +# yum update + + +yum_repository 'mongodb' do + description "MongoDB Repository" + baseurl "http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/" + gpgcheck false + enabled true + action :create +end + +package 'mongodb-org' do + :install +end + + +#service mongod start + +service 'mongod' do + #supports : restart => true + action [:enable, :start] +end + + +execute 'chkconfig' do + #command 'mongo --host 127.0.0.1:27017' + command 'sudo mongo' + action :run + live_stream true +ignore_failure true +end + + + + + diff --git a/1_MongoDB/cookbooks/mongodb/spec/spec_helper.rb b/1_MongoDB/cookbooks/mongodb/spec/spec_helper.rb new file mode 100644 index 0000000..052d78a --- /dev/null +++ b/1_MongoDB/cookbooks/mongodb/spec/spec_helper.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true +require 'chefspec' +require 'chefspec/berkshelf' diff --git a/1_MongoDB/cookbooks/mongodb/spec/unit/recipes/default_spec.rb b/1_MongoDB/cookbooks/mongodb/spec/unit/recipes/default_spec.rb new file mode 100644 index 0000000..76eab9b --- /dev/null +++ b/1_MongoDB/cookbooks/mongodb/spec/unit/recipes/default_spec.rb @@ -0,0 +1,35 @@ +# +# Cookbook:: mongodb +# Spec:: default +# +# Copyright:: 2018, The Authors, All Rights Reserved. + +require 'spec_helper' + +describe 'mongodb::default' do + context 'When all attributes are default, on Ubuntu 16.04' do + let(:chef_run) do + # for a complete list of available platforms and versions see: + # https://github.com/customink/fauxhai/blob/master/PLATFORMS.md + runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04') + runner.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end + + context 'When all attributes are default, on CentOS 7.4.1708' do + let(:chef_run) do + # for a complete list of available platforms and versions see: + # https://github.com/customink/fauxhai/blob/master/PLATFORMS.md + runner = ChefSpec::ServerRunner.new(platform: 'centos', version: '7.4.1708') + runner.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/1_MongoDB/cookbooks/mongodb/test/smoke/default/default_test.rb b/1_MongoDB/cookbooks/mongodb/test/smoke/default/default_test.rb new file mode 100644 index 0000000..a70e26b --- /dev/null +++ b/1_MongoDB/cookbooks/mongodb/test/smoke/default/default_test.rb @@ -0,0 +1,18 @@ +# # encoding: utf-8 + +# Inspec test for recipe mongodb::default + +# The Inspec reference, with examples and extensive documentation, can be +# found at http://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 From c8f3c03841bee387873be8a6f57c55af800857f6 Mon Sep 17 00:00:00 2001 From: krattan406 <30876207+krattan406@users.noreply.github.com> Date: Mon, 12 Feb 2018 00:46:33 -0500 Subject: [PATCH 02/12] Update README.md --- 1_MongoDB/README.md | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/1_MongoDB/README.md b/1_MongoDB/README.md index 0dc6ca3..ec3538a 100644 --- a/1_MongoDB/README.md +++ b/1_MongoDB/README.md @@ -1,30 +1,33 @@ -###1 - Setup & Environment #### +##################################### - Setup & Environment ########################################################### 1) Downloaded and install VirtualBox running CentOs 7 - Linux 64 bit 2) Install chef in the virtual machine using the command: > $ sudo rpm -Uvh https://packages.chef.io/files/stable/chefdk/2.4.17/el/7/chefdk-2.4.17-1.el7.x86_64.rpm -# 1 - RESULT : +# RESULT : Retrieving https://packages.chef.io/files/stable/chefdk/2.4.17/el/7/chefdk-2.4.17-1.el7.x86_64.rpm warning: /var/tmp/rpm-tmp.b3AyNw: Header V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY Preparing... ########################################### [100%] 1:chefdk ########################################### [100%] Thank you for installing Chef Development Kit! -# 3) Checked the Ruby version & set path to chef sdk version + +# #################################### Checked the Ruby version & set path to chef sdk version ############ Ruby Version set to chef sdk ver: echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> ~/.configuration_file && source ~/.configuration_file echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> ~/.bash_profile && source ~/.bash_profile -##### End of setup ##### +######################################## End of setup ############################################################ + +############################MongoDB install instructions ######################################################### -## 2 - Create a directory called mongo-chef. -# We will use this directory to store the recipe to install mongo Db -# We have already downloaded chef Sdk in the previous step +Create a directory called mongo-chef. +We will use this directory to store the recipe to install mongo Db +We have already downloaded chef Sdk in the previous step - - Rebooted my Virtual box and logged in as root +- Rebooted my Virtual box and logged in as root - create a dir for chef repository, here we will generate and store all our cookbooks. @@ -33,14 +36,16 @@ ls mkdir cookbooks ls -# RESULT: + #### RESULT: [root@osboxes mongo-chef]# ls cookbooks -# 3 COOKBOOK : Next, generate a cookbook for all mongoldb installation instructions: +################# COOKBOOK :###################################################################### +###Next, generate a cookbook for all mongoldb installation instructions: + [root@osboxes mongo-chef]# chef generate cookbook cookbooks/mongodb -# RESULT: +##### RESULT: Generating cookbook mongodb - Ensuring correct cookbook file content @@ -74,10 +79,11 @@ Your cookbook is ready. Type `cd cookbooks/mongodb` to enter it. # 4 Create a recipe file where I will enter the resources and actions to perform on each resource to install mongoldb. # Now run the Cookbook: -[root@osboxes recipes]# chef-client --local-mode install.rb +[root@osboxes recipes]# chef-client --local-mode default.rb -# RESULT - 5X unsuccessful runs with errors - please see unsucessful runs.txt, with possible issues and solutions. +# RESULT - 5X unsuccessful runs with errors - please see unsucessful_runs.txt, with possible issues and solutions. +default.rb ## # Cookbook:: mongodb # Recipe:: default From a6b2522f726790120bccffc9c62bc1db99589421 Mon Sep 17 00:00:00 2001 From: krattan406 <30876207+krattan406@users.noreply.github.com> Date: Mon, 12 Feb 2018 00:49:08 -0500 Subject: [PATCH 03/12] Update README.md --- 1_MongoDB/README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/1_MongoDB/README.md b/1_MongoDB/README.md index ec3538a..bc11aff 100644 --- a/1_MongoDB/README.md +++ b/1_MongoDB/README.md @@ -1,10 +1,11 @@ -##################################### - Setup & Environment ########################################################### +# Setup & Environment +########################################################### 1) Downloaded and install VirtualBox running CentOs 7 - Linux 64 bit 2) Install chef in the virtual machine using the command: > $ sudo rpm -Uvh https://packages.chef.io/files/stable/chefdk/2.4.17/el/7/chefdk-2.4.17-1.el7.x86_64.rpm -# RESULT : +#### RESULT : Retrieving https://packages.chef.io/files/stable/chefdk/2.4.17/el/7/chefdk-2.4.17-1.el7.x86_64.rpm warning: /var/tmp/rpm-tmp.b3AyNw: Header V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY Preparing... ########################################### [100%] @@ -12,19 +13,18 @@ Preparing... ########################################### [100%] Thank you for installing Chef Development Kit! -# #################################### Checked the Ruby version & set path to chef sdk version ############ +# Checked the Ruby version & set path to chef sdk version ############ Ruby Version set to chef sdk ver: echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> ~/.configuration_file && source ~/.configuration_file echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> ~/.bash_profile && source ~/.bash_profile -######################################## End of setup ############################################################ +###### End of setup ############################################################ -############################MongoDB install instructions ######################################################### +# MongoDB install Chef Recipe creation instructions ########################### -Create a directory called mongo-chef. -We will use this directory to store the recipe to install mongo Db +Create a directory called mongo-chef. We will use this directory to store the recipe to install mongo Db We have already downloaded chef Sdk in the previous step - Rebooted my Virtual box and logged in as root @@ -76,7 +76,7 @@ Your cookbook is ready. Type `cd cookbooks/mongodb` to enter it. 7 directories, 9 files -# 4 Create a recipe file where I will enter the resources and actions to perform on each resource to install mongoldb. +# Create a recipe file where I will enter the resources and actions to perform on each resource to install mongoldb. # Now run the Cookbook: [root@osboxes recipes]# chef-client --local-mode default.rb From cc05ee1db6627d89d4ad36019d1c270a7cff2f55 Mon Sep 17 00:00:00 2001 From: krattan406 <30876207+krattan406@users.noreply.github.com> Date: Mon, 12 Feb 2018 00:52:28 -0500 Subject: [PATCH 04/12] Update README.md --- 1_MongoDB/README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/1_MongoDB/README.md b/1_MongoDB/README.md index bc11aff..d3880b7 100644 --- a/1_MongoDB/README.md +++ b/1_MongoDB/README.md @@ -1,5 +1,5 @@ # Setup & Environment -########################################################### + 1) Downloaded and install VirtualBox running CentOs 7 - Linux 64 bit 2) Install chef in the virtual machine using the command: @@ -20,9 +20,9 @@ echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> ~/.configuration_file && echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> ~/.bash_profile && source ~/.bash_profile -###### End of setup ############################################################ +## End of setup -# MongoDB install Chef Recipe creation instructions ########################### +# MongoDB install Chef Recipe creation instructions Create a directory called mongo-chef. We will use this directory to store the recipe to install mongo Db We have already downloaded chef Sdk in the previous step @@ -36,16 +36,16 @@ ls mkdir cookbooks ls - #### RESULT: + ## RESULT: [root@osboxes mongo-chef]# ls cookbooks -################# COOKBOOK :###################################################################### +# COOKBOOK : ###Next, generate a cookbook for all mongoldb installation instructions: [root@osboxes mongo-chef]# chef generate cookbook cookbooks/mongodb -##### RESULT: +#### RESULT: Generating cookbook mongodb - Ensuring correct cookbook file content @@ -53,7 +53,7 @@ Generating cookbook mongodb - Ensuring correct delivery build cookbook content Your cookbook is ready. Type `cd cookbooks/mongodb` to enter it. -# Check the directory structure. I have already installed the tree package to view directories as tree +### Check the directory structure. I have already installed the tree package to view directories as tree [root@osboxes mongodb]# tree . @@ -76,12 +76,12 @@ Your cookbook is ready. Type `cd cookbooks/mongodb` to enter it. 7 directories, 9 files -# Create a recipe file where I will enter the resources and actions to perform on each resource to install mongoldb. +### Create a recipe file where I will enter the resources and actions to perform on each resource to install mongoldb. -# Now run the Cookbook: +### Now run the Cookbook: [root@osboxes recipes]# chef-client --local-mode default.rb -# RESULT - 5X unsuccessful runs with errors - please see unsucessful_runs.txt, with possible issues and solutions. +### RESULT - 5X unsuccessful runs with errors - please see unsucessful_runs.txt, with possible issues and solutions. default.rb ## From 7c95ddab315623cd23db5266dd4d0fd73bcdc258 Mon Sep 17 00:00:00 2001 From: krattan406 <30876207+krattan406@users.noreply.github.com> Date: Mon, 12 Feb 2018 00:54:16 -0500 Subject: [PATCH 05/12] Update README.md --- 1_MongoDB/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/1_MongoDB/README.md b/1_MongoDB/README.md index d3880b7..2c1eda5 100644 --- a/1_MongoDB/README.md +++ b/1_MongoDB/README.md @@ -85,13 +85,13 @@ Your cookbook is ready. Type `cd cookbooks/mongodb` to enter it. default.rb ## -# Cookbook:: mongodb -# Recipe:: default +#Cookbook:: mongodb +#Recipe:: default # -# Copyright:: 2018, The Authors, All Rights Reserved. +#Copyright:: 2018, The Authors, All Rights Reserved. -# add yum clean all. -# yum update +#add yum clean all. +#yum update yum_repository 'mongodb' do @@ -123,7 +123,7 @@ execute 'chkconfig' do ignore_failure true end -# RESULT: +#### RESULT: Starting Chef Client, version 13.6.4 resolving cookbooks for run list: [] From ada736f64cb9c3b55d5fac5ca56babc5bbb5a5f1 Mon Sep 17 00:00:00 2001 From: krattan406 <30876207+krattan406@users.noreply.github.com> Date: Mon, 12 Feb 2018 01:41:33 -0500 Subject: [PATCH 06/12] Update README.md --- 1_MongoDB/README.md | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/1_MongoDB/README.md b/1_MongoDB/README.md index 2c1eda5..2675dd4 100644 --- a/1_MongoDB/README.md +++ b/1_MongoDB/README.md @@ -13,15 +13,13 @@ Preparing... ########################################### [100%] Thank you for installing Chef Development Kit! -# Checked the Ruby version & set path to chef sdk version ############ +#### Checked the Ruby version & set path to chef sdk version ############ Ruby Version set to chef sdk ver: echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> ~/.configuration_file && source ~/.configuration_file echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> ~/.bash_profile && source ~/.bash_profile -## End of setup - # MongoDB install Chef Recipe creation instructions Create a directory called mongo-chef. We will use this directory to store the recipe to install mongo Db @@ -36,7 +34,7 @@ ls mkdir cookbooks ls - ## RESULT: + #### RESULT: [root@osboxes mongo-chef]# ls cookbooks @@ -76,23 +74,21 @@ Your cookbook is ready. Type `cd cookbooks/mongodb` to enter it. 7 directories, 9 files -### Create a recipe file where I will enter the resources and actions to perform on each resource to install mongoldb. +#### Create a recipe file where I will enter the resources and actions to perform on each resource to install mongoldb. -### Now run the Cookbook: +#### Now run the Cookbook: [root@osboxes recipes]# chef-client --local-mode default.rb -### RESULT - 5X unsuccessful runs with errors - please see unsucessful_runs.txt, with possible issues and solutions. +#### RESULT - 5X unsuccessful runs with errors - please see unsucessful_runs.txt, with possible issues and solutions. + +# MongoDb install Chef Recipe default.rb -## -#Cookbook:: mongodb -#Recipe:: default -# -#Copyright:: 2018, The Authors, All Rights Reserved. -#add yum clean all. -#yum update +Cookbook:: mongodb +Recipe:: default +Copyright:: 2018, The Authors, All Rights Reserved. yum_repository 'mongodb' do description "MongoDB Repository" @@ -106,9 +102,6 @@ package 'mongodb-org' do :install end - -#service mongod start - service 'mongod' do #supports : restart => true action [:enable, :start] From 7caccdc09b3627312c359aee26b0b92e09f72147 Mon Sep 17 00:00:00 2001 From: krattan406 <30876207+krattan406@users.noreply.github.com> Date: Wed, 14 Feb 2018 13:47:47 -0800 Subject: [PATCH 07/12] Update README.md --- 1_MongoDB/README.md | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/1_MongoDB/README.md b/1_MongoDB/README.md index 2675dd4..e95d67c 100644 --- a/1_MongoDB/README.md +++ b/1_MongoDB/README.md @@ -1,5 +1,26 @@ + +# Usage + +1) Copy the cookook to your virtualBox running CentOs 7 and +2) login as root +3) Change working directory to /cookbooks/mongodb +4) Run mongo install cookbook : + sudo chef-client --local-mode recipes/default.rb +5) login mongo shell: + > mongo +6) You are now logged in: + root@osboxes mongodb]# mongo + MongoDB shell version v3.6.2 + connecting to: mongodb://127.0.0.1:27017 + MongoDB server version: 3.6.2 + -etc.(truncated)---- + + + # Setup & Environment +Note : This setup was done one time to set the environment of my virtualBox centOS7 +and ChefDk kit ver 2.4.17 1) Downloaded and install VirtualBox running CentOs 7 - Linux 64 bit 2) Install chef in the virtual machine using the command: @@ -16,9 +37,7 @@ Thank you for installing Chef Development Kit! #### Checked the Ruby version & set path to chef sdk version ############ Ruby Version set to chef sdk ver: echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> ~/.configuration_file && source ~/.configuration_file - - echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> ~/.bash_profile && source ~/.bash_profile - +echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> ~/.bash_profile && source ~/.bash_profile # MongoDB install Chef Recipe creation instructions From 943bab9b2ba83c64cdaccd4ea9f270238d0cbe2d Mon Sep 17 00:00:00 2001 From: krattan406 <30876207+krattan406@users.noreply.github.com> Date: Wed, 14 Feb 2018 13:48:46 -0800 Subject: [PATCH 08/12] Update README.md --- 1_MongoDB/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/1_MongoDB/README.md b/1_MongoDB/README.md index e95d67c..d2f195e 100644 --- a/1_MongoDB/README.md +++ b/1_MongoDB/README.md @@ -15,6 +15,7 @@ MongoDB server version: 3.6.2 -etc.(truncated)---- +7) You are now able to use MongoDb ! # Setup & Environment From a10f55a7e519ede803c46810b342983fe6112f3f Mon Sep 17 00:00:00 2001 From: krattan406 <30876207+krattan406@users.noreply.github.com> Date: Wed, 14 Feb 2018 13:51:05 -0800 Subject: [PATCH 09/12] Add files via upload --- .../MongoDb-install-unsucessfullRuns.txt | 331 ++++++++++++++++++ 1 file changed, 331 insertions(+) create mode 100644 1_MongoDB/MongoDb-install-unsucessfullRuns.txt diff --git a/1_MongoDB/MongoDb-install-unsucessfullRuns.txt b/1_MongoDB/MongoDb-install-unsucessfullRuns.txt new file mode 100644 index 0000000..9a7fe38 --- /dev/null +++ b/1_MongoDB/MongoDb-install-unsucessfullRuns.txt @@ -0,0 +1,331 @@ +root@osboxes recipes]# chef-client --local-mode install.rb +[2018-02-10T20:04:43-05:00] WARN: No config file found or specified on command line, using command line options. +Starting Chef Client, version 13.6.4 +resolving cookbooks for run list: ["learn_chef_httpd"] +Synchronizing Cookbooks: + - learn_chef_httpd (0.1.0) +Installing Cookbook Gems: +Compiling Cookbooks... + +Running handlers: +[2018-02-10T20:04:48-05:00] ERROR: Running exception handlers +[2018-02-10T20:04:48-05:00] ERROR: Running exception handlers +Running handlers complete +[2018-02-10T20:04:48-05:00] ERROR: Exception handlers complete +[2018-02-10T20:04:48-05:00] ERROR: Exception handlers complete +Chef Client failed. 0 resources updated in 04 seconds +[2018-02-10T20:04:48-05:00] FATAL: Stacktrace dumped to /root/.chef/local-mode-cache/cache/chef-stacktrace.out +[2018-02-10T20:04:48-05:00] FATAL: Stacktrace dumped to /root/.chef/local-mode-cache/cache/chef-stacktrace.out +[2018-02-10T20:04:48-05:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report +[2018-02-10T20:04:48-05:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report +[2018-02-10T20:04:48-05:00] ERROR: Option action must be equal to one of: nothing, install, upgrade, remove, purge, reconfig, lock, unlock! You passed :start. +[2018-02-10T20:04:48-05:00] ERROR: Option action must be equal to one of: nothing, install, upgrade, remove, purge, reconfig, lock, unlock! You passed :start. +[2018-02-10T20:04:48-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1) +[2018-02-10T20:04:48-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1) +[root@osboxes recipes]# chef-client --local-mode install.rb +[2018-02-10T20:07:03-05:00] WARN: No config file found or specified on command line, using command line options. +Starting Chef Client, version 13.6.4 +resolving cookbooks for run list: ["learn_chef_httpd"] +Synchronizing Cookbooks: + - learn_chef_httpd (0.1.0) +Installing Cookbook Gems: +Compiling Cookbooks... +Converging 5 resources +Recipe: learn_chef_httpd::default + * yum_package[httpd] action install^[[A^[[A (up to date) + * service[httpd] action enable (up to date) + * service[httpd] action start (up to date) + * template[/var/www/html/index.html] action create (up to date) +Recipe: @recipe_files::/chef-repo/cookbooks/mongodb/recipes/install.rb + * yum_repository[mongodb] action create + * template[/etc/yum.repos.d/mongodb.repo] action create + - update content in file /etc/yum.repos.d/mongodb.repo from e3b0c4 to acded2 + --- /etc/yum.repos.d/mongodb.repo 2018-02-10 01:03:23.942774971 -0500 + +++ /etc/yum.repos.d/.chef-mongodb20180210-16941-w8avo5.repo 2018-02-10 20:07:22.730208840 -0500 + @@ -1 +1,9 @@ + +# This file was generated by Chef + +# Do NOT modify this file by hand. + + + +[mongodb] + +name=MongoDB Repository + +enabled=1 + +fastestmirror_enabled=0 + +gpgcheck=0^[[B + - restore selinux security context + * execute[yum clean metadata mongodb] action run + - execute yum clean metadata --disablerepo=* --enablerepo=mongodb + * execute[yum-makecache-mongodb] action run + + ================================================================================ + Error executing action `run` on resource 'execute[yum-makecache-mongodb]' + ================================================================================ + + Mixlib::ShellOut::ShellCommandFailed + ------------------------------------ + Expected process to exit with [0], but received '1' + ---- Begin output of yum -q -y makecache --disablerepo=* --enablerepo=mongodb ---- + STDOUT: + STDERR: One of the configured repositories failed (Unknown), + and yum doesn't have enough cached data to continue. At this point the only + safe thing yum can do is fail. There are a few ways to work "fix" this: + + 1. Contact the upstream for the repository and get them to fix the problem. + + 2. Reconfigure the baseurl/etc. for the repository, to point to a working + upstream. This is most often useful if you are using a newer + distribution release than is supported by the repository (and the + packages for the previous distribution release still work). + + 3. Run the command with the repository temporarily disabled + yum --disablerepo= ... + + 4. Disable the repository permanently, so yum won't use it by default. Yum + will then just ignore the repository until you permanently enable it + again or use --enablerepo for temporary usage: + + yum-config-manager --disable + or + subscription-manager repos --disable= + + 5. Configure the failing repository to be skipped, if it is unavailable. + Note that yum will try to contact the repo. when it runs most commands, + so will have to try and fail each time (and thus. yum will be be much + slower). If it is a very temporary problem though, this is often a nice + compromise: + + yum-config-manager --save --setopt=.skip_if_unavailable=true + + Cannot find a valid baseurl for repo: mongodb + ---- End output of yum -q -y makecache --disablerepo=* --enablerepo=mongodb ---- + Ran yum -q -y makecache --disablerepo=* --enablerepo=mongodb returned 1 + + Resource Declaration: + --------------------- + # In /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4/lib/chef/provider/yum_repository.rb + + 60: declare_resource(:execute, "yum-makecache-#{new_resource.repositoryid}") do + 61: command "yum -q -y makecache --disablerepo=* --enablerepo=#{new_resource.repositoryid}" + 62: action :nothing + 63: only_if { new_resource.enabled } + 64: end + 65: + + Compiled Resource: + ------------------ + # Declared in /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4/lib/chef/provider/yum_repository.rb:60:in `block in ' + + execute("yum-makecache-mongodb") do + action [:nothing] + default_guard_interpreter :execute + command "yum -q -y makecache --disablerepo=* --enablerepo=mongodb" + backup 5 + returns 0 + user nil + declared_type :execute + cookbook_name "@recipe_files" + domain nil + only_if { #code block } + end + + System Info: + ------------ + chef_version=13.6.4 + platform=centos + platform_version=7.4.1708 + ruby=ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux] + program_name=chef-client worker: ppid=16936;start=20:07:03; + executable=/opt/chefdk/bin/chef-client + + + ================================================================================ + Error executing action `create` on resource 'yum_repository[mongodb]' + ================================================================================ + + Mixlib::ShellOut::ShellCommandFailed + ------------------------------------ + execute[yum-makecache-mongodb] (/opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4/lib/chef/provider/yum_repository.rb line 60) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1' + ---- Begin output of yum -q -y makecache --disablerepo=* --enablerepo=mongodb ---- + STDOUT: + STDERR: One of the configured repositories failed (Unknown), + and yum doesn't have enough cached data to continue. At this point the only + safe thing yum can do is fail. There are a few ways to work "fix" this: + + 1. Contact the upstream for the repository and get them to fix the problem. + + 2. Reconfigure the baseurl/etc. for the repository, to point to a working + upstream. This is most often useful if you are using a newer + distribution release than is supported by the repository (and the + packages for the previous distribution release still work). + + 3. Run the command with the repository temporarily disabled + yum --disablerepo= ... + + 4. Disable the repository permanently, so yum won't use it by default. Yum + will then just ignore the repository until you permanently enable it + again or use --enablerepo for temporary usage: + + yum-config-manager --disable + or + subscription-manager repos --disable= + + 5. Configure the failing repository to be skipped, if it is unavailable. + Note that yum will try to contact the repo. when it runs most commands, + so will have to try and fail each time (and thus. yum will be be much + slower). If it is a very temporary problem though, this is often a nice + compromise: + + yum-config-manager --save --setopt=.skip_if_unavailable=true + + Cannot find a valid baseurl for repo: mongodb + ---- End output of yum -q -y makecache --disablerepo=* --enablerepo=mongodb ---- + Ran yum -q -y makecache --disablerepo=* --enablerepo=mongodb returned 1 + + Resource Declaration: + --------------------- + # In /chef-repo/cookbooks/mongodb/recipes/install.rb + + 1: yum_repository 'mongodb' do + 2: description 'MongoDB Repository' + 3: baseurl= "http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/" + 4: gpgcheck false + 5: enabled true + 6: action :create + 7: end + 8: + + Compiled Resource: + ------------------ + # Declared in /chef-repo/cookbooks/mongodb/recipes/install.rb:1:in `from_file' + + yum_repository("mongodb") do + action [:create] + updated true + updated_by_last_action true + default_guard_interpreter :default + declared_type :yum_repository + cookbook_name "@recipe_files" + recipe_name "/chef-repo/cookbooks/mongodb/recipes/install.rb" + description "MongoDB Repository" + gpgcheck false + enabled true + repositoryid "mongodb" + end + + System Info: + ------------ + chef_version=13.6.4 + platform=centos + platform_version=7.4.1708 + ruby=ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux] + program_name=chef-client worker: ppid=16936;start=20:07:03; + executable=/opt/chefdk/bin/chef-client + + +Running handlers: +[2018-02-10T20:07:23-05:00] ERROR: Running exception handlers +[2018-02-10T20:07:23-05:00] ERROR: Running exception handlers +Running handlers complete +[2018-02-10T20:07:23-05:00] ERROR: Exception handlers complete +[2018-02-10T20:07:23-05:00] ERROR: Exception handlers complete +Chef Client failed. 2 resources updated in 20 seconds +[2018-02-10T20:07:23-05:00] FATAL: Stacktrace dumped to /root/.chef/local-mode-cache/cache/chef-stacktrace.out +[2018-02-10T20:07:23-05:00] FATAL: Stacktrace dumped to /root/.chef/local-mode-cache/cache/chef-stacktrace.out +[2018-02-10T20:07:23-05:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report +[2018-02-10T20:07:23-05:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report +[2018-02-10T20:07:23-05:00] ERROR: yum_repository[mongodb] (@recipe_files::/chef-repo/cookbooks/mongodb/recipes/install.rb line 1) had an error: Mixlib::ShellOut::ShellCommandFailed: execute[yum-makecache-mongodb] (/opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4/lib/chef/provider/yum_repository.rb line 60) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1' +---- Begin output of yum -q -y makecache --disablerepo=* --enablerepo=mongodb ---- +STDOUT: +STDERR: One of the configured repositories failed (Unknown), + and yum doesn't have enough cached data to continue. At this point the only + safe thing yum can do is fail. There are a few ways to work "fix" this: + + 1. Contact the upstream for the repository and get them to fix the problem. + + 2. Reconfigure the baseurl/etc. for the repository, to point to a working + upstream. This is most often useful if you are using a newer + distribution release than is supported by the repository (and the + packages for the previous distribution release still work). + + 3. Run the command with the repository temporarily disabled + yum --disablerepo= ... + + 4. Disable the repository permanently, so yum won't use it by default. Yum + will then just ignore the repository until you permanently enable it + again or use --enablerepo for temporary usage: + + yum-config-manager --disable + or + subscription-manager repos --disable= + + 5. Configure the failing repository to be skipped, if it is unavailable. + Note that yum will try to contact the repo. when it runs most commands, + so will have to try and fail each time (and thus. yum will be be much + slower). If it is a very temporary problem though, this is often a nice + compromise: + + yum-config-manager --save --setopt=.skip_if_unavailable=true + +Cannot find a valid baseurl for repo: mongodb +---- End output of yum -q -y makecache --disablerepo=* --enablerepo=mongodb ---- +Ran yum -q -y makecache --disablerepo=* --enablerepo=mongodb returned 1 +[2018-02-10T20:07:23-05:00] ERROR: yum_repository[mongodb] (@recipe_files::/chef-repo/cookbooks/mongodb/recipes/install.rb line 1) had an error: Mixlib::ShellOut::ShellCommandFailed: execute[yum-makecache-mongodb] (/opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4/lib/chef/provider/yum_repository.rb line 60) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1' +---- Begin output of yum -q -y makecache --disablerepo=* --enablerepo=mongodb ---- +STDOUT: +STDERR: One of the configured repositories failed (Unknown), + and yum doesn't have enough cached data to continue. At this point the only + safe thing yum can do is fail. There are a few ways to work "fix" this: + + 1. Contact the upstream for the repository and get them to fix the problem. + + 2. Reconfigure the baseurl/etc. for the repository, to point to a working + upstream. This is most often useful if you are using a newer + distribution release than is supported by the repository (and the + packages for the previous distribution release still work). + + 3. Run the command with the repository temporarily disabled + yum --disablerepo= ... + + 4. Disable the repository permanently, so yum won't use it by default. Yum + will then just ignore the repository until you permanently enable it + again or use --enablerepo for temporary usage: + + yum-config-manager --disable + or + subscription-manager repos --disable= + + 5. Configure the failing repository to be skipped, if it is unavailable. + Note that yum will try to contact the repo. when it runs most commands, + so will have to try and fail each time (and thus. yum will be be much + slower). If it is a very temporary problem though, this is often a nice + compromise: + + yum-config-manager --save --setopt=.skip_if_unavailable=true + +Cannot find a valid baseurl for repo: mongodb +---- End output of yum -q -y makecache --disablerepo=* --enablerepo=mongodb ---- +Ran yum -q -y makecache --disablerepo=* --enablerepo=mongodb returned 1 +[2018-02-10T20:07:24-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1) +[2018-02-10T20:07:24-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1) + +---------------- +SOLUTION: + +2018-02-11T17:54:34-05:00] WARN: No config file found or specified on command line, using command line options. +[2018-02-11T17:54:35-05:00] WARN: Chef client 10321 is running, will wait for it to finish and then run. +[2018-02-11T17:54:35-05:00] WARN: Chef client 10321 is running, will wait for it to finish and then run. + +[root@osboxes cookbooks]# ps aux | grep chef + +RESULT: +bin/chef-client --local-mode default.rb +root 10658 0.0 1.6 263932 48496 pts/0 Tl 17:32 0:00 chef-client worker: ppid=10653;start=17:32:32; +root 10842 0.0 1.6 263336 47904 ? Sl 17:36 0:00 chef-client worker: ppid=10837;start=17:36:55; +root 11093 0.2 1.7 264508 52840 pts/0 Tl 17:38 0:03 /opt/chefdk/embedded/bin/ruby --disable-gems /usr/bin/chef-client --local-mode default.rb +root 11098 0.0 1.6 264648 49096 pts/0 Tl 17:38 0:00 chef-client worker: ppid=11093;start=17:38:45; +root 11382 0.2 1.7 263312 51624 pts/0 + + +[root@osboxes cookbooks]# sudo kill -9 10321 + + + From 84622da415d85399c56ab3a16640d0eb111f1cc6 Mon Sep 17 00:00:00 2001 From: krattan406 <30876207+krattan406@users.noreply.github.com> Date: Wed, 14 Feb 2018 13:54:25 -0800 Subject: [PATCH 10/12] Update README.md --- 1_MongoDB/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/1_MongoDB/README.md b/1_MongoDB/README.md index d2f195e..ca81d5c 100644 --- a/1_MongoDB/README.md +++ b/1_MongoDB/README.md @@ -1,9 +1,9 @@ # Usage -1) Copy the cookook to your virtualBox running CentOs 7 and -2) login as root -3) Change working directory to /cookbooks/mongodb +1) Copy the cookook to your virtualBox running CentOs 7 and ChefDk kit ver 2.4.17. +2) login as root. +3) Change working directory to /cookbooks/mongodb. 4) Run mongo install cookbook : sudo chef-client --local-mode recipes/default.rb 5) login mongo shell: From 2dfdeb42779cc2c92bdc76b2b731b490a08688ec Mon Sep 17 00:00:00 2001 From: krattan406 <30876207+krattan406@users.noreply.github.com> Date: Wed, 14 Feb 2018 14:53:16 -0800 Subject: [PATCH 11/12] Update README.md --- 1_MongoDB/README.md | 191 ++++++++++++-------------------------------- 1 file changed, 52 insertions(+), 139 deletions(-) diff --git a/1_MongoDB/README.md b/1_MongoDB/README.md index ca81d5c..8796add 100644 --- a/1_MongoDB/README.md +++ b/1_MongoDB/README.md @@ -1,176 +1,89 @@ # Usage - +Assumption: You have a virtualbox with centOs7 and ChefDk 2.4.17 1) Copy the cookook to your virtualBox running CentOs 7 and ChefDk kit ver 2.4.17. -2) login as root. +2) Login as super user on terminal. 3) Change working directory to /cookbooks/mongodb. 4) Run mongo install cookbook : sudo chef-client --local-mode recipes/default.rb -5) login mongo shell: - > mongo -6) You are now logged in: + +# Test + From terminal, login mongo shell: + > mongo + Result: + You are now logged in: root@osboxes mongodb]# mongo MongoDB shell version v3.6.2 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 3.6.2 -etc.(truncated)---- -7) You are now able to use MongoDb ! - # Setup & Environment - -Note : This setup was done one time to set the environment of my virtualBox centOS7 +Note : This setup was done one time to set the environment of my virtualBox using centOS7 and ChefDk kit ver 2.4.17 1) Downloaded and install VirtualBox running CentOs 7 - Linux 64 bit 2) Install chef in the virtual machine using the command: > $ sudo rpm -Uvh https://packages.chef.io/files/stable/chefdk/2.4.17/el/7/chefdk-2.4.17-1.el7.x86_64.rpm -#### RESULT : +Result: Retrieving https://packages.chef.io/files/stable/chefdk/2.4.17/el/7/chefdk-2.4.17-1.el7.x86_64.rpm -warning: /var/tmp/rpm-tmp.b3AyNw: Header V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY -Preparing... ########################################### [100%] - 1:chefdk ########################################### [100%] +----etc [Truncated] Thank you for installing Chef Development Kit! +3) Now set the Ruby version to be used as the Chefdk version: + Ruby Version set to chef sdk ver: + echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> ~/.configuration_file && source ~/.configuration_file + echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> ~/.bash_profile && source ~/.bash_profile -#### Checked the Ruby version & set path to chef sdk version ############ -Ruby Version set to chef sdk ver: -echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> ~/.configuration_file && source ~/.configuration_file -echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> ~/.bash_profile && source ~/.bash_profile - -# MongoDB install Chef Recipe creation instructions +# MongoDB-install Chef Recipe creation instructions: -Create a directory called mongo-chef. We will use this directory to store the recipe to install mongo Db +1) Create a directory called mongo-chef. We will use this directory to store the recipe to install mongo Db We have already downloaded chef Sdk in the previous step - -- Rebooted my Virtual box and logged in as root - - - create a dir for chef repository, here we will generate and store all our cookbooks. - -[root@osboxes /]# mkdir mongo-chef -ls -mkdir cookbooks -ls - - #### RESULT: -[root@osboxes mongo-chef]# ls -cookbooks - -# COOKBOOK : -###Next, generate a cookbook for all mongoldb installation instructions: - -[root@osboxes mongo-chef]# chef generate cookbook cookbooks/mongodb - -#### RESULT: - -Generating cookbook mongodb -- Ensuring correct cookbook file content -- Ensuring delivery configuration -- Ensuring correct delivery build cookbook content -Your cookbook is ready. Type `cd cookbooks/mongodb` to enter it. - -### Check the directory structure. I have already installed the tree package to view directories as tree - +2) Rebooted my Virtual box and logged in as root +3) create a dir for chef repository, here we will generate and store all our cookbooks. +4) [root@osboxes /]# mkdir mongo-chef +5) mkdir cookbook + RESULT: + [root@osboxes mongo-chef]# ls + cookbooks + +6) Next, generate a cookbook for all mongoldb installation instructions: + [root@osboxes mongo-chef]# chef generate cookbook cookbooks/mongodb + RESULT: + Generating cookbook mongodb + - [Truncated] .. + Your cookbook is ready. Type `cd cookbooks/mongodb` to enter it. + +7) Check the directory structure. I have already installed the tree package to view directories as tree [root@osboxes mongodb]# tree . -├── Berksfile -├── chefignore -├── LICENSE -├── metadata.rb -├── README.md -├── recipes -│   └── default.rb -├── spec -│   ├── spec_helper.rb -│   └── unit -│   └── recipes -│   └── default_spec.rb -└── test - └── smoke - └── default + ├── Berksfile + ├── chefignore + ├── LICENSE + ├── metadata.rb + ├── README.md + ├── recipes + │   └── default.rb + ├── spec + │   ├── spec_helper.rb + │   └── unit + │ └── recipes + │   └── default_spec.rb + └── test + └── smoke + └── default └── default_test.rb - 7 directories, 9 files -#### Create a recipe file where I will enter the resources and actions to perform on each resource to install mongoldb. +8) Create a recipe file where I will enter the resources and actions to perform on each resource to install mongoldb. -#### Now run the Cookbook: +9) Now run the Cookbook: [root@osboxes recipes]# chef-client --local-mode default.rb + RESULT - 5X unsuccessful runs with errors - please see unsucessful_runs.txt, with possible issues and solutions. -#### RESULT - 5X unsuccessful runs with errors - please see unsucessful_runs.txt, with possible issues and solutions. - -# MongoDb install Chef Recipe - -default.rb - -Cookbook:: mongodb -Recipe:: default - -Copyright:: 2018, The Authors, All Rights Reserved. - -yum_repository 'mongodb' do - description "MongoDB Repository" - baseurl "http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/" - gpgcheck false - enabled true - action :create -end - -package 'mongodb-org' do - :install -end - -service 'mongod' do - #supports : restart => true - action [:enable, :start] -end - - -execute 'chkconfig' do - #command 'mongo --host 127.0.0.1:27017' - command 'sudo mongo' - action :run - live_stream true -ignore_failure true -end - -#### RESULT: - -Starting Chef Client, version 13.6.4 -resolving cookbooks for run list: [] -Synchronizing Cookbooks: -Installing Cookbook Gems: -Compiling Cookbooks... -[2018-02-11T18:28:59-05:00] WARN: Node osboxes has an empty run list. -[2018-02-11T18:28:59-05:00] WARN: Node osboxes has an empty run list. -Converging 4 resources -Recipe: @recipe_files::/mongo-chef/cookbooks/mongodb/recipes/default.rb - * yum_repository[mongodb] action create - * template[/etc/yum.repos.d/mongodb.repo] action create (up to date) - * execute[yum clean metadata mongodb] action nothing (skipped due to action :nothing) - * execute[yum-makecache-mongodb] action nothing (skipped due to action :nothing) - * ruby_block[yum-cache-reload-mongodb] action nothing (skipped due to action :nothing) - (up to date) - * yum_package[mongodb-org] action install (up to date) - * service[mongod] action enable (up to date) - * service[mongod] action start (up to date) - * execute[chkconfig] action run - [execute] MongoDB shell version v3.6.2 - connecting to: mongodb://127.0.0.1:27017 - MongoDB server version: 3.6.2 - bye - - execute sudo mongo - -Running handlers: -Running handlers complete -Chef Client finished, 1/9 resources updated in 10 seconds -[2018-02-11T18:29:05-05:00] WARN: No config file found or specified on command line, using command line options. -[2018-02-11T18:29:05-05:00] WARN: No config file found or specified on command line, using command line options. - - - + 6 th time sucess! From 9bb139ffe13a9b225d240c12460822eb94c79a2d Mon Sep 17 00:00:00 2001 From: krattan406 <30876207+krattan406@users.noreply.github.com> Date: Wed, 14 Feb 2018 14:54:19 -0800 Subject: [PATCH 12/12] Update README.md --- 1_MongoDB/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/1_MongoDB/README.md b/1_MongoDB/README.md index 8796add..7f5309a 100644 --- a/1_MongoDB/README.md +++ b/1_MongoDB/README.md @@ -9,7 +9,9 @@ Assumption: You have a virtualbox with centOs7 and ChefDk 2.4.17 # Test From terminal, login mongo shell: + > mongo + Result: You are now logged in: root@osboxes mongodb]# mongo