From 9208f1ac192044958b0f158338020449893f3bf5 Mon Sep 17 00:00:00 2001 From: Nicole Johnson Date: Mon, 23 Oct 2017 21:36:25 -0400 Subject: [PATCH 1/2] replace with workshop refactor --- 1_MongoDB/README.md | 45 ++++++++++++ {Install_MongoDB => 1_MongoDB}/install.rb | 0 {Tomcat => 2_Tomcat}/INSTRUCTIONS.md | 40 ++++++----- 2_Tomcat/README.md | 45 ++++++++++++ {Tomcat => 2_Tomcat}/tomcat.service | 7 +- .../AwesomeApplicanceRepair.pdf | Bin 3_Bonus/Awesome_Appliance_Repair/README.md | 48 +++++++++++++ .../Awesome_Appliance_Repair}/aar.rb | 44 ++++++------ .../Middleman}/INSTRUCTIONS.md | 2 +- 3_Bonus/Middleman/README.md | 47 ++++++++++++ Awesome_Appliance_Repair/README.md | 65 ----------------- Install_MongoDB/README.md | 67 ----------------- LICENSE | 4 +- Middleman/README.md | 68 ------------------ README.md | 65 ++++++++++++----- Tomcat/README.md | 66 ----------------- Tomcat/commands.sh | 61 ---------------- remediation_workshop/README.md | 33 --------- 18 files changed, 287 insertions(+), 420 deletions(-) create mode 100644 1_MongoDB/README.md rename {Install_MongoDB => 1_MongoDB}/install.rb (100%) rename {Tomcat => 2_Tomcat}/INSTRUCTIONS.md (65%) create mode 100644 2_Tomcat/README.md rename {Tomcat => 2_Tomcat}/tomcat.service (90%) rename {Awesome_Appliance_Repair => 3_Bonus/Awesome_Appliance_Repair}/AwesomeApplicanceRepair.pdf (100%) create mode 100644 3_Bonus/Awesome_Appliance_Repair/README.md rename {Awesome_Appliance_Repair => 3_Bonus/Awesome_Appliance_Repair}/aar.rb (96%) rename {Middleman => 3_Bonus/Middleman}/INSTRUCTIONS.md (99%) create mode 100644 3_Bonus/Middleman/README.md delete mode 100644 Awesome_Appliance_Repair/README.md delete mode 100644 Install_MongoDB/README.md delete mode 100644 Middleman/README.md delete mode 100644 Tomcat/README.md delete mode 100644 Tomcat/commands.sh delete mode 100644 remediation_workshop/README.md diff --git a/1_MongoDB/README.md b/1_MongoDB/README.md new file mode 100644 index 0000000..70b32d8 --- /dev/null +++ b/1_MongoDB/README.md @@ -0,0 +1,45 @@ +# Install MongoDB + +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/). + +## Goal + +Use Chef to successfully install MongoDB on a RHEL-based target system. + +## Success Criteria + +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 + +You should be able to explain the following: + +* Steps taken to achieve the end result +* Build and test process of Chef code +* Tools and resources used in the process + +>Note: You are NOT required to use Chef Server for this exercise, but you may if that is your preference. + +## 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/Install_MongoDB/install.rb b/1_MongoDB/install.rb similarity index 100% rename from Install_MongoDB/install.rb rename to 1_MongoDB/install.rb diff --git a/Tomcat/INSTRUCTIONS.md b/2_Tomcat/INSTRUCTIONS.md similarity index 65% rename from Tomcat/INSTRUCTIONS.md rename to 2_Tomcat/INSTRUCTIONS.md index d71cf9b..ce4843c 100644 --- a/Tomcat/INSTRUCTIONS.md +++ b/2_Tomcat/INSTRUCTIONS.md @@ -1,44 +1,44 @@ -# Installation Instructions +# Manual Installation Instructions for Tomcat -* To install OpenJDK 7 JDK using yum, run this command: +Install OpenJDK 7 JDK using yum, run this command: -``` +```shell $ sudo yum install java-1.7.0-openjdk-devel ``` -* Create the User +Create a user for tomcat ``` -$ sudo groupadd chef -$ sudo useradd -g chef chef +$ sudo groupadd tomcat +$ sudo useradd -M -s /bin/nologin -g tomcat -d /opt/tomcat tomcat ``` -* Download the Tomcat Binary +Download the Tomcat Binary > NOTE: A specific binary will be mentioned below but it will likely be out of date. You can find the binaries for Tomcat 8 here at https://archive.apache.org/dist/tomcat/tomcat-8/ ``` $ cd /tmp -$ wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.0.33/ +$ wget http://apache.cs.utah.edu/tomcat/tomcat-8/v8.5.20/bin/apache-tomcat-8.5.20.tar.gz ``` -* Extract the Tomcat Binary +Extract the Tomcat Binary ``` $ sudo mkdir /opt/tomcat $ sudo tar xvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1 ``` -* Update the Permissions +Update the Permissions ``` -$ sudo chgrp -R tomcat conf -$ sudo chmod g+rwx conf -$ sudo chmod g+r conf/* +$ sudo chgrp -R tomcat /opt/tomcat +$ sudo chmod -R g+r conf +$ sudo chmod g+x conf $ sudo chown -R tomcat webapps/ work/ temp/ logs/ ``` -* Install the Systemd Unit File +Install the Systemd Unit File ``` $ sudo vi /etc/systemd/system/tomcat.service @@ -67,20 +67,28 @@ ExecStop=/bin/kill -15 $MAINPID User=tomcat Group=tomcat +UMask=0007 +RestartSec=10 +Restart=always [Install] WantedBy=multi-user.target ``` -* Reload Systemd to load the Tomcat Unit file +Reload Systemd to load the Tomcat Unit file ``` $ sudo systemctl daemon-reload +``` + +Ensure `tomcat` is started and enabled + +``` $ sudo systemctl start tomcat $ sudo systemctl enable tomcat ``` -* Verify that Tomcat is running by visiting the site +Verify that Tomcat is running by visiting the site ``` $ curl http://localhost:8080 diff --git a/2_Tomcat/README.md b/2_Tomcat/README.md new file mode 100644 index 0000000..ad172c8 --- /dev/null +++ b/2_Tomcat/README.md @@ -0,0 +1,45 @@ +# Install and Configure Apache Tomcat + +The [Apache Tomcat®](http://tomcat.apache.org/) software is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies. The Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket specifications are developed under the Java Community Process. + +## Goal + +Use Chef to successfully install and configure tomcat on a RHEL7-based target system. + +## Success Criteria + +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 interact with the default tomcat site in a browser or successfully `curl localhost` 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 + +You should be able to explain the following: + +* Steps taken to achieve the end result +* Build and test process of Chef code +* Tools and resources used in the process + +>Note: You are NOT required to use Chef Server for this exercise, but you may if that is your preference. + +## Instructions + +* Translate the Tomcat installation instructions from `INSTRUCTIONS.rb` into Chef code that completes the installation and configuration +* 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 on your behalf +* 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. +* [Tomcat Installation Instructions](https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-centos-7) diff --git a/Tomcat/tomcat.service b/2_Tomcat/tomcat.service similarity index 90% rename from Tomcat/tomcat.service rename to 2_Tomcat/tomcat.service index e986a1f..0528c6a 100644 --- a/Tomcat/tomcat.service +++ b/2_Tomcat/tomcat.service @@ -16,8 +16,11 @@ Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./ ExecStart=/opt/tomcat/bin/startup.sh ExecStop=/bin/kill -15 $MAINPID -User=chef -Group=chef +User=tomcat +Group=tomcat +UMask=0007 +RestartSec=10 +Restart=always [Install] WantedBy=multi-user.target diff --git a/Awesome_Appliance_Repair/AwesomeApplicanceRepair.pdf b/3_Bonus/Awesome_Appliance_Repair/AwesomeApplicanceRepair.pdf similarity index 100% rename from Awesome_Appliance_Repair/AwesomeApplicanceRepair.pdf rename to 3_Bonus/Awesome_Appliance_Repair/AwesomeApplicanceRepair.pdf diff --git a/3_Bonus/Awesome_Appliance_Repair/README.md b/3_Bonus/Awesome_Appliance_Repair/README.md new file mode 100644 index 0000000..1df6907 --- /dev/null +++ b/3_Bonus/Awesome_Appliance_Repair/README.md @@ -0,0 +1,48 @@ +# Awesome Appliance Repair + +[Awesome Appliance Repair](https://github.com/learnchef/Awesome-Appliance-Repair) is a sample web application written in Python. The application includes [instructions for installing and initializing the application](https://github.com/learnchef/Awesome-Appliance-Repair/blob/master/AARinstall.py) on Ubuntu using MySQL as the database and Apache as the web server. + +## Goal + +Use Chef to successfully install and configure the Awesome Appliance Repair application and database on an Ubuntu-based target system. + +## Success Criteria + +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 interact with the Awesome Appliance Repair site in a browser (e.g., login, etc.) +* You can run chef-client multiple times without failures +* Your GitHub.com source code repository shows the history of your work + +You should be able to explain the following: + +* Steps taken to achieve the end result +* Build and test process of Chef code +* Tools and resources used in the process + +>NOTE: You are NOT required to use Chef Server for this exercise, but you may if that is your preference. + +## Instructions + +>NOTE: This workshop uses Ubuntu 12.04 or newer and NOT a RHEL-based distribution + +* Translate the Awesome Appliance Repair python installation script [AARinstall.py](https://github.com/chef-training/Awesome-Appliance-Repair/blob/master/AARinstall.py) into Chef code that completes the installation and configuration +* 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 on your behalf +* 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 Ubuntu-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. +* The contents of [AARinstall.py](https://github.com/chef-training/Awesome-Appliance-Repair/blob/master/AARinstall.py) are included within this workshop. See `aar.rb`. +* `AwesomeApplianceRepair.pdf` includes some hints and suggestions. diff --git a/Awesome_Appliance_Repair/aar.rb b/3_Bonus/Awesome_Appliance_Repair/aar.rb similarity index 96% rename from Awesome_Appliance_Repair/aar.rb rename to 3_Bonus/Awesome_Appliance_Repair/aar.rb index 5eed7af..306c261 100644 --- a/Awesome_Appliance_Repair/aar.rb +++ b/3_Bonus/Awesome_Appliance_Repair/aar.rb @@ -16,9 +16,9 @@ # # -*- coding: utf-8 -*- # from subprocess import Popen # import os, sys, getpass, binascii -# +# # # The following script assumes that apache2, mysql, and unzip have been installed. -# +# # # 1. wget https://github.com/colincam/Awesome-Appliance-Repair/archive/master.zip # # 2. unzip master.zip # # 3. cd into Awesome-Appliance-Repair @@ -26,30 +26,30 @@ # # 5. sudo su root # # 6. run script: python AARinstall.py # # 7. manually execute: apachectl graceful -# +# # if __name__ == '__main__': # root_dbpswd = getpass.getpass('enter the mysql root user password: ') -# +# # Popen(['chown', '-R', 'www-data:www-data', '/var/www/AAR'], shell=False).wait() -# -# # apt-get the stuff we need +# +# # apt-get the stuff we need # proc = Popen([ # 'apt-get', 'install', '-y', # 'libapache2-mod-wsgi', # 'python-pip', # 'python-mysqldb'], shell=False) # proc.wait() -# +# # # pip install flask # Popen(['pip', 'install', 'flask'], shell=False).wait() -# +# # # Generate the apache config file in sites-enabled # Popen(['apachectl', 'stop'], shell=False).wait() -# +# # pth = '/etc/apache2/sites-enabled/' # for f in os.listdir(pth): # os.remove(pth + f) -# +# # f = open('/etc/apache2/sites-enabled/AAR-apache.conf', 'w') # f.write(""" # @@ -57,47 +57,47 @@ # WSGIDaemonProcess /AAR user=www-data group=www-data threads=5 # WSGIProcessGroup /AAR # WSGIScriptAlias / /var/www/AAR/awesomeapp.wsgi -# +# # # WSGIApplicationGroup %{GLOBAL} # WSGIScriptReloading On # Order deny,allow # Allow from all # -# +# # CustomLog ${APACHE_LOG_DIR}/access.log combined # ServerAdmin ops@example.com # # """) # f.close() -# -# # Generate AAR_config.py with secrets +# +# # Generate AAR_config.py with secrets # f = open('/var/www/AAR/AAR_config.py', 'w') # appdbpw = binascii.b2a_base64(os.urandom(6)).strip('\n') # secretkey = binascii.b2a_base64(os.urandom(12)).strip('\n') -# +# # conn_args_string = """CONNECTION_ARGS = {"host":"localhost", "user":"aarapp", "passwd":"%s", "db":"AARdb"}\n\n""" % appdbpw -# +# # secret_key_string = """SECRET_KEY = "%s"\n\n""" % secretkey -# +# # database_values_string = """DB_VALUES = [(3,'Maytag','Washer', None, 'pending', "outflow hoses leak"),(4,'GE','Refrigerator', '2013-11-01', 'completed', "Ices up; won't defrost"), (5,'Alessi','Teapot', None, 'pending', "explodes"), (6,'Amana','Range', '2013-11-02', 'completed', "oven heats unevenly"), (7,'Whirlpool','Refrigerator', '2013-11-03', 'pending', "Makes a rattling noise"), (8,'GE','Microwave', '2013-11-04', 'pending', "Sparks and smokes when I put forks in it"), (9,'Maytag','Drier', None, 'pending', "Never heats up"), (10,'Amana','Refrigerator', '2013-11-05', 'pending', "Temperature too low, can't adjust."), (11,'Samsung','Washer', None, 'pending', "Doesn't get my bear suit white"), (12,'Frigidaire','Refrigerator', '2013-11-06', 'completed', "Has a bad smell I can't get rid of."), (13,'In-Sink-Erator','Dispose-all', None, 'pending', "blades broken"), (14,'KitchenAid','Mixer', '2013-11-07', 'completed', "Blows my fuses"), (15,'Moulinex','Juicer', None, 'pending', "Won't start"), (16,'Viking','Range', '2013-11-08', 'completed', "Gas leak"), (17,'Aga','Range', None, 'pending', "burner cover is cracked"), (18,'Jennaire','Cooktop', '2013-11-09', 'completed', "Glass cracked"), (19,'Wolfe','Stove', None, 'pending', "Burners are uneven"), (20,'LG','Dehumidifier', '2013-11-10', 'pending', "Ices up when external temp is around freezing"), (21,'DeLonghi','Oil Space Heater', None, 'pending', "Smells bad"), (22,'Kenmore','Refrigerator', '2013-11-11', 'pending', "excessive vibration"), (23,'Maytag','Washer/Drier', None, 'pending', "outflow hoses leak"), (24,'GE','Refrigerator', '2013-11-12', 'pending', "Refrigerator light is defective"), (25,'Kenmore','Washer', None, 'pending', "Unbalanced spin cycle"), (26,'Cookmore','Outdoor Grill', '2013-11-13', 'pending', "Smoker box is stuck"), (27,'Kenmore','Water heater', None, 'pending', "Can't adjust temperature"), (28,'Sanyo','Minifridge', '2013-11-14', 'pending', "Makes a lot of noise"), (29,'Bosch','Dishwasher', None, 'pending', "leaves spots on my glasses"), (30,'Whirlpool','Trash Compactor', '2013-11-15', 'pending', "leaking hydraulic fluid")] # """ -# +# # f.write(conn_args_string + secret_key_string + database_values_string) # f.close() -# +# # # Create DB, user, and permissions # import MySQLdb # db = MySQLdb.connect(host='localhost', user='root', passwd=root_dbpswd) # sql_script = open('make_AARdb.sql', 'r').read() -# +# # cur = db.cursor() # cur.execute(sql_script) # cur.close() -# +# # cur = db.cursor() # cur.execute('use AARdb') # cur.execute("CREATE USER 'aarapp'@'localhost' IDENTIFIED BY %s", (appdbpw,)) # cur.execute("GRANT CREATE,INSERT,DELETE,UPDATE,SELECT on AARdb.* to aarapp@localhost") # cur.close() -# db.close()# \ No newline at end of file +# db.close()# diff --git a/Middleman/INSTRUCTIONS.md b/3_Bonus/Middleman/INSTRUCTIONS.md similarity index 99% rename from Middleman/INSTRUCTIONS.md rename to 3_Bonus/Middleman/INSTRUCTIONS.md index 9bc9bc1..d7913e1 100644 --- a/Middleman/INSTRUCTIONS.md +++ b/3_Bonus/Middleman/INSTRUCTIONS.md @@ -185,4 +185,4 @@ case "$1" in esac : -``` \ No newline at end of file +``` diff --git a/3_Bonus/Middleman/README.md b/3_Bonus/Middleman/README.md new file mode 100644 index 0000000..ead01e6 --- /dev/null +++ b/3_Bonus/Middleman/README.md @@ -0,0 +1,47 @@ +# Middleman + +[Middleman](http://middlemanapp.com/) is a static site generator using all the shortcuts and tools in modern web development. It is a ruby (sinatra) application. + +## Goal + +Use Chef to successfully install and configure the middleman application + +## Success Criteria + +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 interact with the middleman site in a browser. +* You can run chef-client multiple times without failures +* Your GitHub.com source code repository shows the history of your work + +You should be able to explain the following: + +* Steps taken to achieve the end result +* Build and test process of Chef code +* Tools and resources used in the process + +>NOTE: You are NOT required to use Chef Server for this exercise, but you may if that is your preference. + +## Instructions + +>NOTE: This workshop uses Ubuntu 12.04 or newer and NOT a RHEL-based distribution + +* Translate the middleman installation `INSTRUCTIONS.rb` into Chef code that completes the installation and configuration +* 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 on your behalf +* 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 Ubuntu-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. +* Additional instructions are included in `INSTRUCTIONS.rb` within this repo diff --git a/Awesome_Appliance_Repair/README.md b/Awesome_Appliance_Repair/README.md deleted file mode 100644 index 8218f4a..0000000 --- a/Awesome_Appliance_Repair/README.md +++ /dev/null @@ -1,65 +0,0 @@ -# Awesome Appliance Repair - -[Awesome Appliance Repair](https://github.com/learnchef/Awesome-Appliance-Repair) is a sample web application written in Python. The application includes [instructions for installing and initializing the application](https://github.com/learnchef/Awesome-Appliance-Repair/blob/master/AARinstall.py) on Ubuntu using MySQL as the database and Apache as the web server. - -## Objectives - -Your goal with this project is to transform [AARinstall.py](https://github.com/learnchef/Awesome-Appliance-Repair/blob/master/AARinstall.py) into one or more Chef recipes that will install and initialize the application. - -After successfully completing this workshop, you will be able to: - -* Install and configure the Awesome Appliance Repair site using Chef. -* Use the [Chef Documentation](http://docs.chef.io) to identify and use resources that will help you model the desired state of your infrastructure. - - -## Pre-requisites - -Before beginning you will need: - -* Some experience using Chef such as: - * completing the exercises on [Learn Chef](http://learn.chef.io/tutorials) - * completing a Chef Essentials workshop - * real-world experience working with Chef -* Chef DK or chef-client installed on your local workstation to develop and test your Chef code. -* A text editor (i.e. Atom, SublimeTest, VisualStudio Code) -* A version control system (i.e. Github) -* A virtual machine running Ubuntu 12.04 or later - -## Instructions - -* Use the ChefDK and text editor to develop and test your Chef code on your local workstation. -* Use the instructions provided in the file `aar.rb` and `AwesomeApplianceRepair.pdf` to construct your Chef cookbook that mirrors the installation instructions. Use the Chef Resources reference to find the most appropriate Chef Resources to use for each task. [Chef resources reference][https://docs.chef.io/resources.html] - -* There are a couple of ways that you can write, test and run your cookbook. - * Using the steps outlined [here](https://learn.chef.io/tutorials/local-development/ubuntu/), write and test your cookbook locally using Vagrant + Virtualbox - * Use your Ubuntu 12.04 (or later) virtual machine. Write your cookbook in vim, nano or emacs, and run `chef-client` in `--local-mode`. - -## Completion Criteria - - Store your work in a Github repository. - - You should be able to explain the following: - - * Steps taken to achieve the end result. - * Build and test process of Chef code. - * Tools used in the process. - - You'll know this project is complete when: - - * Your Chef cookbook successfully compiles and executes on a target node. - * You can interact with the Awesome Appliance Repair site in a browser. - * You can run chef-client multiple times without failures. - * Your source code repository shows the history of your work. - -## Next steps - - You can expand on this project a number of ways including: - - * Testing - * Add [Inspec](http://inspec.io/) tests - * Add static code analysis using [Rubocop](https://github.com/bbatsov/rubocop) and [Food Critic](foodcritic.io) - * Add [ChefSpec](http://sethvargo.github.io/chefspec/) unit tests - - * Utilize community cookbooks inside of your cookbook [Community Cookbooks](http://supermarket.chef.io) - - The community has created cookbooks that accomplish similar goals. Select a group of resources, recipe, or cookbook and replace it with the equivalent community cookbook. diff --git a/Install_MongoDB/README.md b/Install_MongoDB/README.md deleted file mode 100644 index 4971b3e..0000000 --- a/Install_MongoDB/README.md +++ /dev/null @@ -1,67 +0,0 @@ -# Install MongoDB - -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 Red Hat Enterprise Linux, CentOS Linux, Fedora Linux, or a related system](http://docs.mongodb.org/manual/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux/). - -## Objectives - -The goal is to transform the installation instructions into one or more Chef recipes that will install and initialize the MongoDB application. - -After successfully completing this workshop, you will be able to: - -* Install and configure a basic Tomcat webpage using Chef. -* Use the [Chef Documentation](http://docs.chef.io) to identify and use resources that will help you model the desired state of your infrastructure. - -## Pre-requisites - -Before beginning you will need: - -* Some experience using Chef such as: - * completing the exercises on [Learn Chef](http://learn.chef.io/tutorials) - * completing a Chef Essentials workshop - * real-world experience working with Chef -* Chef DK or chef-client installed on your local workstation to develop and test your Chef code. -* A text editor (i.e. Atom, SublimeTest, VisualStudio Code) -* A version control system (i.e. Github) -* A virtual machine running Red Hat Enterprise Linux, CentOS Linux, Fedora Linux, or a related system. - -## Instructions - -* Use the ChefDK and text editor to develop and test your Chef code on your local workstation. -* Use the instructions provided in the file `install.rb` to construct your Chef cookbook that mirrors the installation instructions. Use the Chef Resources reference to find the most appropriate Chef Resources to use for each task. [Chef resources reference][https://docs.chef.io/resources.html] - -* There are a couple of ways that you can write, test and run your cookbook. - * Using the steps outlined [here](https://learn.chef.io/tutorials/local-development/), write and test your cookbook locally using Test Kitchen via Vagrant + Virtual Box, or the cloud platform of your choice. - * Use your Red Hat Enterprise Linux, CentOS Linux, Fedora Linux virtual machine. Write your cookbook in vim, nano or emacs, and run `chef-client` in `--local-mode`. - -## Completion Criteria - - Store your work in a Github repository. - - You should be able to explain the following: - - * Steps taken to achieve the end result. - * Build and test process of Chef code. - * Tools used in the process. - - You should be able to demonstrate the following: - - * Your Chef cookbook successfully compiles and executes on your target node - * You can login to MongoDB by typing `mongo` on the target system. - * You can run chef-client multiple times without failures - * Your source code repository shows the history of your work. - -## Next steps - - You can expand on this project a number of ways including: - - * Testing - * Add [Inspec](http://inspec.io/) tests - * Add static code analysis using [Rubocop](https://github.com/bbatsov/rubocop) and [Food Critic](foodcritic.io) - * Add [ChefSpec](http://sethvargo.github.io/chefspec/) unit tests - - * Utilize community cookbooks inside of your cookbook [Community Cookbooks](http://supermarket.chef.io) - - The community has created cookbooks that accomplish similar goals. Select a group of resources, recipe, or cookbook and replace it with the equivalent community cookbook. - - -* a working solution [Nathen Harvey](https://github.com/nathenharvey/install_mongo) diff --git a/LICENSE b/LICENSE index 3cc9f5e..590cc8d 100644 --- a/LICENSE +++ b/LICENSE @@ -49,7 +49,7 @@ exhaustive, and do not form part of our licenses. such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More_considerations - for the public: + for the public: wiki.creativecommons.org/Considerations_for_licensees ======================================================================= @@ -422,4 +422,4 @@ understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. -Creative Commons may be contacted at creativecommons.org. \ No newline at end of file +Creative Commons may be contacted at creativecommons.org. diff --git a/Middleman/README.md b/Middleman/README.md deleted file mode 100644 index f4865c8..0000000 --- a/Middleman/README.md +++ /dev/null @@ -1,68 +0,0 @@ -# Middleman - -[Middleman](http://middlemanapp.com/) is a static site generator using all the shortcuts and tools in modern web development. It is a ruby (sinatra) application. Setup instructions are included in INSTRUCTIONS.md. - -You goal is to transform the installation instructions into one or more Chef recipes that will install and initialize the application. - -## Objectives - -The goal is to transform the installation instructions into one or more Chef recipes that will install and initialize the Middleman application. - -After successfully completing this workshop, you will be able to: - -* Install and configure the Middleman site using Chef. -* Use the [Chef Documentation](http://docs.chef.io) to identify and use resources that will help you model the desired state of your infrastructure. -* Include [guards](https://docs.chef.io/resources.html#guards) in Chef resources. - -## Pre-requisites - -Before beginning you will need: - -* Some experience using Chef such as: - * completing the exercises on [Learn Chef](http://learn.chef.io/tutorials) - * completing a Chef Essentials workshop - * real-world experience working with Chef -* Chef DK or chef-client installed on your local workstation to develop and test your Chef code. -* A text editor (i.e. Atom, SublimeTest, VisualStudio Code) -* A version control system (i.e. Github) -* A virtual machine running Ubuntu 12.04 or later - -## Instructions - -* Use the ChefDK and text editor to develop and test your Chef code on your local workstation. -* Use the instructions provided in the file `INSTRUCTIONS.md` to construct your Chef cookbook that mirrors the installation instructions. Use the Chef Resources reference to find the most appropriate Chef Resources to use for each task. [Chef resources reference][https://docs.chef.io/resources.html] - -* There are a couple of ways that you can write, test and run your cookbook. - * Using the steps outlined [here](https://learn.chef.io/tutorials/local-development/ubuntu/), write and test your cookbook locally using Vagrant + Virtualbox - * Use your Ubuntu 12.04 (or later) virtual machine. Write your cookbook in vim, nano or emacs, and run `chef-client` in `--local-mode`. - - -## Completion Criteria - -Store your work in a Github repository. - -You should be able to explain the following: - -* Steps taken to achieve the end result. -* Build and test process of Chef code. -* Tools used in the process. - -You'll know this project is complete when: - -* Your Chef cookbook successfully compiles and executes on a target node -* You can interact with the middleman site in a browser. -* You can run chef-client multiple times without failures. -* Your source code repository shows the history of your work. - -## Next steps - -You can expand on this project a number of ways including: - -* Testing - * Add [Inspec](http://inspec.io/) tests - * Add static code analysis using [Rubocop](https://github.com/bbatsov/rubocop) and [Food Critic](foodcritic.io) - * Add [ChefSpec](http://sethvargo.github.io/chefspec/) unit tests - -* Utilize community cookbooks inside of your cookbook [Community Cookbooks](http://supermarket.chef.io) - -The community has created cookbooks that accomplish similar goals. Select a group of resources, recipe, or cookbook and replace it with the equivalent community cookbook. diff --git a/README.md b/README.md index 5f08816..76b9ccf 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,65 @@ -# Chef Workshops +# Chef SA Workshops -After completing some initial training on Chef, learners are often wondering where to go next to be successful with Chef. This repository is a collection of ideas suitable for answering that question. +## Instructions -Workshop ideas can be used as training exercises, hack day projects, starter projects, etc. +Complete the mandatory workshops below. These may be completed in any order, but it the recommendation is `1_MongoDB` then `2_Tomcat`. -Great projects: +* `1_MongoDB` +* `2_Tomcat` +* `3_Bonus` -* Have multiple correct answers -* Have a begin and end state defined with plenty of room for the learner to find his or her way to the end state. These are intentionally loosely defined. -* Can be facilitated or completed as self-study -* Can be extended in multiple directions based on learning objectives +Each workshop includes instructions stating the goal of the workshop, the success criteria, and, in some cases, basic instructions. Basic instructions are provided with the understanding that those executing the workshops may not have any practical experience with the specific technologies involved. + +If the first two workshops are completed successfully, additional bonus material from `3_Bonus` may be completed. This is extra credit material and additional consideration will be given if it is attempted and/or completed successfully. + +## Expectations + +There are no correct or incorrect working solutions to each of the workshops. If the participant's solution meets the defined success criteria, that is a correct solution. Each individual is expected to use their own experiences and approach to solving the task at hand. + +* Work will be shown on github + * Create a free account on [github.com](https://github.com) if you do not have one + * Fork this repository + * Commit your work locally and often to show progress + * Do not forget to push to your github repo! + * Provide instructions in your README.md for us to run your cookbook so that we can test your work. + * Be prepared to explain your approach and thought process for building the cookbooks + * Be prepared to present your working solutions by demonstrating successful `chef-client` runs ## Projects Included -* Awesome Appliance Repair - A simple, python-based web application that utilizes Apache for a web server and MySQL for a database. -* Install MongoDB - A starter project for MongoDB. This simply installs the software on the target system. -* Middleman - A static site generator using all the shortcuts and tools in modern web development. It is a ruby (sinatra) application. -* Remediation Workshop - Use [Chef Inspec](inspec.io) to test and remediate a system. -* Tomcat - A simple installation and configuration of an Apache web page. +* **1_MongoDB:** Install the software on the target system +* **2_Tomcat:** Install and configure the Apache Tomcat Java application server on the target system +* **3_Bonus:** Bonus Projects that can be completed in addition to `1_MongoDB` and `2_Tomcat` + * Expand the functionality of the previous two workshops + * Awesome Appliance Repair - A simple, python-based web application that utilizes Apache for a web server and MySQL for a database. + * Middleman - A static site generator using all the shortcuts and tools in modern web development. It is a ruby (sinatra) application. + +## Pre-requisites -## Contributing +You will need some experience using Chef such as: + +* Completing the exercises on [Learn Chef](http://learn.chef.io) +* Completing a Chef Essentials workshop or class +* Completing other online tutorials or training courses on Chef +* Real-world experience working with Chef + +You will also need to install a few pieces of software on your local workstation: + +* The [ChefDK](https://downloads.chef.io/chefdk) to develop and test your Chef code. +* A text editor to create and edit your Chef code (i.e. [Atom](https://atom.io), [VisualStudio Code](https://code.visualstudio.com), [SublimeText](https://www.sublimetext.com), or other) +* A free [GitHub.com](https://github.com) account to upload your work +* A virtual machine running a RHEL7 (or later) based linux distribution (RHEL, CentOS, Fedora, etc.) to serve as a test system + * This can be a local or cloud-hosted VM + >NOTE: Workshops in `3_Bonus` may require an Ubuntu-based operating system rather than RHEL7. If required, it will be called out specifically within that workshop's README file. -Pull requests are merged via Github, you can find the documentation about how to fork a repository and start contributing here [https://help.github.com/articles/fork-a-repo](https://help.github.com/articles/fork-a-repo). ## License & Authors Author:: Nathen Harvey () Author:: Nicole Johnson () +Author:: Jeff Mery () +Author:: Brian Chau () - -Copyright:: 2014 Chef Software, Inc. +Copyright:: 2017 Chef Software, Inc. This work is licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/). diff --git a/Tomcat/README.md b/Tomcat/README.md deleted file mode 100644 index 09cdd08..0000000 --- a/Tomcat/README.md +++ /dev/null @@ -1,66 +0,0 @@ -# Tomcat on CentOS - -The [Apache Tomcat®](http://tomcat.apache.org/) software is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies. The Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket specifications are developed under the Java Community Process. - -## Objectives - -The goal is to transform the installation instructions into one or more Chef recipes that will install and initialize the Tomcat application. - -After successfully completing this workshop, you will be able to: - -* Install and configure a basic Tomcat webpage using Chef. -* Use the [Chef Documentation](http://docs.chef.io) to identify and use resources that will help you model the desired state of your infrastructure. -* Include [guards](https://docs.chef.io/resources.html#guards) in Chef resources. - -## Pre-requisites - -Before beginning you will need: - -* Some experience using Chef such as: - * completing the exercises on [Learn Chef](http://learn.chef.io/tutorials) - * completing a Chef Essentials workshop - * real-world experience working with Chef -* Chef DK or chef-client installed on your local workstation to develop and test your Chef code. -* A text editor (i.e. Atom, SublimeTest, VisualStudio Code) -* A version control system (i.e. Github) -* A virtual machine running CentOS 7.0 or later - -## Instructions - -* Use the ChefDK and text editor to develop and test your Chef code on your local workstation. -* Use the instructions provided in the file `INSTRUCTIONS.md` and/or to construct your Chef cookbook that mirrors the installation instructions. Use the Chef Resources reference to find the most appropriate Chef Resources to use for each task. [Chef resources reference][https://docs.chef.io/resources.html] - -* There are a couple of ways that you can write, test and run your cookbook. - * Using the steps outlined [here](https://learn.chef.io/tutorials/local-development/rhel/), write and test your cookbook locally using Test Kitchen via Vagrant + Virtual Box, or the cloud platform of your choice. - * Use your CentOS 7.0 (or later) virtual machine. Write your cookbook in vim, nano or emacs, and run `chef-client` in `--local-mode`. - - -## Completion Criteria - -Store your work in a Github repository. - -You should be able to explain the following: - -* Steps taken to achieve the end result. -* Build and test process of Chef code. -* Tools used in the process. - -You should be able to demonstrate the following: - -* Your Chef cookbook successfully compiles and executes on your target node -* You can interact with the tomcat site in a browser or successfully `curl localhost` -* You can run chef-client multiple times without failures -* Your source code repository shows the history of your work - -## Next steps - -You can expand on this project a number of ways including: - -* Testing - * Add [Inspec](http://inspec.io/) tests - * Add static code analysis using [Rubocop](https://github.com/bbatsov/rubocop) and [Food Critic](foodcritic.io) - * Add [ChefSpec](http://sethvargo.github.io/chefspec/) unit tests - -* Utilize community cookbooks inside of your cookbook [Community Cookbooks](http://supermarket.chef.io) - -The community has created cookbooks that accomplish similar goals. Select a group of resources, recipe, or cookbook and replace it with the equivalent community cookbook. diff --git a/Tomcat/commands.sh b/Tomcat/commands.sh deleted file mode 100644 index 8a399b7..0000000 --- a/Tomcat/commands.sh +++ /dev/null @@ -1,61 +0,0 @@ -mkdir cookbooks -chef generate cookbook cookbooks/tomcat -tree cookbooks/tomcat -echo " - -package 'java-1.7.0-openjdk-devel' - -group 'chef' do - action :create -end - -user 'chef' do - group 'chef' -end - -# remote_file '/tmp/apache-tomcat-8.0.33.tar.gz' do -# source 'https://archive.apache.org/dist/tomcat/tomcat-8/v8.0.33/' -# end - -directory '/opt/tomcat' do - action :create - recursive true -end - -execute 'extract_tomcat' do - command 'tar xvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1' - cwd '/tmp' -end - -execute 'chgrp -R chef /opt/tomcat/conf' - -directory '/opt/tomcat/conf' do - group 'chef' - mode '0474' -end - -execute 'chmod g+r conf/*' do - cwd '/opt/tomcat' -end - -execute 'chown -R chef webapps/ work/ temp/ logs/ conf/' do - cwd '/opt/tomcat' -end - -template '/etc/systemd/system/tomcat.service' do - source 'tomcat.service.erb' -end - -execute 'systemctl daemon-reload' - -service 'tomcat' do - action [:start, :enable] -end - -" > cookbooks/tomcat/recipes/default.rb - -chef generate template cookbooks/tomcat tomcat.service - -cp ~/tomcat.service ~/cookbooks/tomcat/templates/default/tomcat.service.erb - -sudo chef-client --local-mode --runlist "recipe[tomcat::default]" diff --git a/remediation_workshop/README.md b/remediation_workshop/README.md deleted file mode 100644 index 7755be9..0000000 --- a/remediation_workshop/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# Remediation - -[Chef Inspec](inspec.io) provides a number of Compliance Profiles that can be used to check a number of controls across your infrastructure. -You can find a guide for this process [here](https://learn.chef.io/tutorials/compliance-assess/) - -Your goal with this project is to scan a node using one or more profiles and remediate any violations using Chef. - -## Objectives - -After successfully completing this workshop, you will be able to: - -* Add a node to the Chef Compliance server -* Execute scans from the Chef Compliance server -* Write cookbooks to remediate failing controls - -## Process - -* You will need: - * A Chef Compliance Server - * A workstation configured with the latest version of the Chef Development Kit (ChefDK) installed. - * A node to scan for compliance. - * The node and the workstation can be the same instance. - -* Please track and share your work in a git repository - - -* Login to the Chef Compliance server -* Add the node to be scanned -* Scan the node and note the failing controls -* Write cookbooks to remediate the failing controls -* Execute the cookbooks on the node -* Scan to verify remediation -* Fix one thing at a time From b6808ead88dcc7c828fe655b6587c9982a154d33 Mon Sep 17 00:00:00 2001 From: Nicole Johnson Date: Mon, 23 Oct 2017 21:48:44 -0400 Subject: [PATCH 2/2] proofread --- 3_Bonus/README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 3_Bonus/README.md diff --git a/3_Bonus/README.md b/3_Bonus/README.md new file mode 100644 index 0000000..c5d4040 --- /dev/null +++ b/3_Bonus/README.md @@ -0,0 +1,20 @@ +# Bonus Topics + +Provided workshops 1 and 2 have been completed successfully, one or more bonus items below may be attempted. Additional consideration will be given for any bonus topics attempted and/or completed. However, that consideration is predicated on successful completion of the base workshops. + +Bonus topics do NOT have to be attempted in any particular order. The participant may choose which items they would like to attempt. + +#### Expand on workshops 1 and/or 2 in one or more of the following ways + +* Testing + * Add [Inspec](http://inspec.io/) tests + * Add [ChefSpec](http://sethvargo.github.io/chefspec/) unit tests +* Refactor to make use of community cookbooks inside of your cookbook [Community Cookbooks](http://supermarket.chef.io) + >NOTE: If this item is selected, ensure that working versions of the base workshops are availble to show and discuss (e.g create a git feature branch for the refactor and leave `master` as the working version) +* Refactor to support multiple operating systems + * E.G. Ubuntu in addition to RHEL7 + +#### Complete one or more addtional workshops + +* Awesome Appliance Repair +* Middleman