forked from sivajavatechie/JenkinsWar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request sivajavatechie#2 from chef-cft/add_refactor
Add refactor
- Loading branch information
Showing
19 changed files
with
307 additions
and
420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,88 +16,88 @@ | |
# # -*- 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 | ||
# # 4. sudo mv AAR to /var/www/ | ||
# # 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(""" | ||
# <VirtualHost *:80> | ||
# ServerName / | ||
# WSGIDaemonProcess /AAR user=www-data group=www-data threads=5 | ||
# WSGIProcessGroup /AAR | ||
# WSGIScriptAlias / /var/www/AAR/awesomeapp.wsgi | ||
# | ||
# | ||
# <Directory /var/www/AAR> | ||
# WSGIApplicationGroup %{GLOBAL} | ||
# WSGIScriptReloading On | ||
# Order deny,allow | ||
# Allow from all | ||
# </Directory> | ||
# | ||
# | ||
# CustomLog ${APACHE_LOG_DIR}/access.log combined | ||
# ServerAdmin [email protected] | ||
# </VirtualHost> | ||
# """) | ||
# 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()# | ||
# db.close()# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,4 +185,4 @@ case "$1" in | |
esac | ||
: | ||
``` | ||
``` |
Oops, something went wrong.