diff --git a/1-4 ChefDK/install_chefdk.pdf b/1-4 ChefDK/install_chefdk.pdf new file mode 100644 index 0000000..8aa29e2 Binary files /dev/null and b/1-4 ChefDK/install_chefdk.pdf differ diff --git a/1-5 Vagrant/1-5 Vagrant.txt b/1-5 Vagrant/1-5 Vagrant.txt new file mode 100644 index 0000000..12459a6 --- /dev/null +++ b/1-5 Vagrant/1-5 Vagrant.txt @@ -0,0 +1,42 @@ +# 1-5 Configuring Your Development Environment - Vagrant and VirtualBox +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course + +# run these commands to ensure you're setup properly. +# Commands are demonstrated on a MacOS terminal. If on a Windows machine, commands +# for navigation and file manipulation may vary. +# If unable to locate any of the tools, please ensure that your system path is +# properly configured as documented in the setup pdf. + +# all commands assume working out of the home directory, ~/ + +# Run these commands on your local machine +cd ~ +chef --version +chef -v +vboxmanage --version +vagrant --version +mkdir chef +cd chef/ +pwd +vagrant box add bento/centos-7.2 --provider=virtualbox +vagrant init bento/centos-7.2 +ls +cat Vagrantfile +vagrant up +vagrant status +vagrant ssh-config +vagrant ssh + +# Run these commands on the vagrant instance after running 'vagrant ssh' +vagrant@localhost$ curl https://omnitruck.chef.io/install.sh | sudo bash -s -- -P chefdk -c stable -v 0.18.30 +vagrant@localhost$ chef --version +vagrant@localhost$ sudo yum install nano -y +vagrant@localhost$ sudo yum install vim -y +vagrant@localhost$ exit + + +# when you're done with the exercises for the moment, suspend the machine state +vagrant suspend + +# or destroy the virtual machine +vagrant destroy --force \ No newline at end of file diff --git a/1-5 Vagrant/Vagrantfile_sample b/1-5 Vagrant/Vagrantfile_sample new file mode 100644 index 0000000..7398c0e --- /dev/null +++ b/1-5 Vagrant/Vagrantfile_sample @@ -0,0 +1,71 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# All Vagrant configuration is done below. The "2" in Vagrant.configure +# configures the configuration version (we support older styles for +# backwards compatibility). Please don't change it unless you know what +# you're doing. +Vagrant.configure("2") do |config| + # The most common configuration options are documented and commented below. + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://atlas.hashicorp.com/search. + config.vm.box = "bento/centos-7.2" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not runsecommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + +config.vm.network "forwarded_port", guest: 80, host: 8090 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider "virtualbox" do |vb| + # # Display the VirtualBox GUI when booting the machine + # vb.gui = true + # + # # Customize the amount of memory on the VM: + # vb.memory = "1024" + # end + # + # View the documentation for the provider you are using for more + # information on available options. + + # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies + # such as FTP and Heroku are also available. See the documentation at + # https://docs.vagrantup.com/v2/push/atlas.html for more information. + # config.push.define "atlas" do |push| + # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" + # end + + # Enable provisioning with a shell script. Additional provisioners such as + # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the + # documentation for more information about their specific syntax and use. + # config.vm.provision "shell", inline: <<-SHELL + # apt-get update + # apt-get install -y apache2 + # SHELL \ No newline at end of file diff --git a/1-5 Vagrant/Vagrantfile_sample.zip b/1-5 Vagrant/Vagrantfile_sample.zip new file mode 100644 index 0000000..bac9cb0 Binary files /dev/null and b/1-5 Vagrant/Vagrantfile_sample.zip differ diff --git a/1-6 AWS/1-6 AWS.txt b/1-6 AWS/1-6 AWS.txt new file mode 100644 index 0000000..b27a8b9 --- /dev/null +++ b/1-6 AWS/1-6 AWS.txt @@ -0,0 +1,30 @@ +# 1-6 Configuring Your Development Environment - Amazon EC2 +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course + +# run these commands to ensure you're setup properly. +# Commands are demonstrated on a MacOS terminal. If on a Windows machine, commands +# for navigation and file manipulation may vary. +# If unable to locate any of the tools, please ensure that your system path is +# properly configured as documented in the setup pdf. + +# all commands assume working out of the home directory, ~/ + +# Run these commands on your local machine to connect to your cloud instance +cd ~ +ssh -i /PATH/TO/AWS_KEY centos@PUBLIC_HOSTNAME +sudo chmod 400 /PATH/TO/AWS_KEY +ssh -i /PATH/TO/AWS_KEY centos@PUBLIC_HOSTNAME + + +# Run these commands on the cloud instance after connecting with ssh +centos@ip$ curl https://omnitruck.chef.io/install.sh | sudo bash -s -- -P chefdk -c stable -v 0.18.30 +centos@ip$ chef --version +centos@ip$ sudo yum install nano -y +centos@ip$ sudo yum install vim -y +centos@ip$ exit + + +# when you're done with the exercises for the moment, exit the machine +centos@ip$ exit + +# or consider destroying the cloud instance. Remember, these cost money over time! \ No newline at end of file diff --git a/1-7 GCP/1-7 GCP.txt b/1-7 GCP/1-7 GCP.txt new file mode 100644 index 0000000..ca485f6 --- /dev/null +++ b/1-7 GCP/1-7 GCP.txt @@ -0,0 +1,33 @@ +# 1-7 Configuring Your Development Environment - Google Compute Engine +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course + +# run these commands to ensure you're setup properly. +# Commands are demonstrated on a MacOS terminal. If on a Windows machine, commands +# for navigation and file manipulation may vary. +# If unable to locate any of the tools, please ensure that your system path is +# properly configured as documented in the setup pdf. + +# all commands assume working out of the home directory, ~/ + +# Connect to the cloud instance using the Cloud Console, or follow the +# commands below to connect with an ssh client +cd ~ +ssh-keygen -t rsa -b 2048 -f ~/.ssh/gce +cat ~/.ssh/gce.pub + +# After locating username and public ipaddress in the cloud console +ssh -i ~/.ssh/gce username@PUBLIC_IP + + +# Run these commands on the cloud instance after connecting with ssh +username@centos7$ curl https://omnitruck.chef.io/install.sh | sudo bash -s -- -P chefdk -c stable -v 0.18.30 +username@centos7$ chef --version +username@centos7$ sudo yum install nano -y +username@centos7$ sudo yum install vim -y +username@centos7$ exit + + +# when you're done with the exercises for the moment, exit the machine +username@centos7$ exit + +# or consider destroying the cloud instance. Remember, these cost money over time! \ No newline at end of file diff --git a/1-8 Azure/1-8 Azure.txt b/1-8 Azure/1-8 Azure.txt new file mode 100644 index 0000000..dfcd62e --- /dev/null +++ b/1-8 Azure/1-8 Azure.txt @@ -0,0 +1,32 @@ +# 1-8 Configuring Your Development Environment - Microsoft Azure +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course + +# run these commands to ensure you're setup properly. +# Commands are demonstrated on a MacOS terminal. If on a Windows machine, commands +# for navigation and file manipulation may vary. +# If unable to locate any of the tools, please ensure that your system path is +# properly configured as documented in the setup pdf. + +# all commands assume working out of the home directory, ~/ + +# follow the commands below to connect with the Azure instance with an ssh client +cd ~ +ssh-keygen -t rsa -b 2048 -f ~/.ssh/azure +cat ~/.ssh/azure.pub + +# After locating username and public ipaddress in the cloud console +ssh -i ~/.ssh/azure username@PUBLIC_IP + + +# Run these commands on the cloud instance after connecting with ssh +username@centos7$ curl https://omnitruck.chef.io/install.sh | sudo bash -s -- -P chefdk -c stable -v 0.18.30 +username@centos7$ chef --version +username@centos7$ sudo yum install nano -y +username@centos7$ sudo yum install vim -y +username@centos7$ exit + + +# when you're done with the exercises for the moment, exit the machine +username@centos7$ exit + +# or consider destroying the cloud instance. Remember, these cost money over time! \ No newline at end of file diff --git a/10-4 Uploading Cookbooks/10-4 Uploading Cookbooks b/10-4 Uploading Cookbooks/10-4 Uploading Cookbooks new file mode 100644 index 0000000..952a832 --- /dev/null +++ b/10-4 Uploading Cookbooks/10-4 Uploading Cookbooks @@ -0,0 +1,21 @@ +# 10-4 Uploading Cookbooks +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after configuring the ~/chef-repo directory +# and downloading the /cookbooks to your local machine + +cd ~/chef-repo +ls +ls cookbooks/ +ls -a +ls .chef/ +cat .chef/knife.rb +knife --help +knife client list +knife ssl check +knife cookbook --help +knife cookbook list +knife cookbook upload workstation +knife cookbook upload apache +knife cookbook list \ No newline at end of file diff --git a/10-4 Uploading Cookbooks/10-4 Uploading Cookbooks.txt b/10-4 Uploading Cookbooks/10-4 Uploading Cookbooks.txt new file mode 100644 index 0000000..952a832 --- /dev/null +++ b/10-4 Uploading Cookbooks/10-4 Uploading Cookbooks.txt @@ -0,0 +1,21 @@ +# 10-4 Uploading Cookbooks +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after configuring the ~/chef-repo directory +# and downloading the /cookbooks to your local machine + +cd ~/chef-repo +ls +ls cookbooks/ +ls -a +ls .chef/ +cat .chef/knife.rb +knife --help +knife client list +knife ssl check +knife cookbook --help +knife cookbook list +knife cookbook upload workstation +knife cookbook upload apache +knife cookbook list \ No newline at end of file diff --git a/10-5 Reconfigure Vagrant/10-5 Reconfigure Vagrant.txt b/10-5 Reconfigure Vagrant/10-5 Reconfigure Vagrant.txt new file mode 100644 index 0000000..8567c3e --- /dev/null +++ b/10-5 Reconfigure Vagrant/10-5 Reconfigure Vagrant.txt @@ -0,0 +1,10 @@ +# 10-5 Reconfigure Vagrant +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo + +cd ~/chef-repo +cat Vagrantfile +vagrant plugin install vagrant-ohai +vagrant up \ No newline at end of file diff --git a/10-6 Lab Bootstrap Webserver/10-6 Lab Bootstrap a Webserver.txt b/10-6 Lab Bootstrap Webserver/10-6 Lab Bootstrap a Webserver.txt new file mode 100644 index 0000000..dc93552 --- /dev/null +++ b/10-6 Lab Bootstrap Webserver/10-6 Lab Bootstrap a Webserver.txt @@ -0,0 +1,20 @@ +# 10-6 Lab: Bootstrap a Webserver +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo and running 'vagrant up' + +cd ~/chef-repo +vagrant status +vagrant ssh-config +knife bootstrap localhost --ssh-port PORT --ssh-user vagrant --sudo --identity-file /PATH/TO/KEY -N web1 +knife node list +knife node show web1 +knife node run_list add web1 "recipe[workstation],recipe[apache]" +knife node show web1 +vagrant ssh web1 + +# run these commands on the web1 vagrant instance + +vagrant@web1$ sudo chef-client +vagrant@web1$ curl localhost \ No newline at end of file diff --git a/11-3 Lab Wrapper Cookbooks/11-3 Wrapper Cookbooks.txt b/11-3 Lab Wrapper Cookbooks/11-3 Wrapper Cookbooks.txt new file mode 100644 index 0000000..bc664e5 --- /dev/null +++ b/11-3 Lab Wrapper Cookbooks/11-3 Wrapper Cookbooks.txt @@ -0,0 +1,15 @@ +# 11-3 Wrapper Cookbooks +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo and running 'vagrant up' + +cd ~/chef-repo +pwd +ls cookbooks/ +chef generate cookbook cookbooks/myhaproxy +ls cookbooks/ +tree cookbooks/myhaproxy +nano cookbooks/myhaproxy/metadata.rb +cat Vagrantfile +nano cookbooks/myhaproxy/recipes/default.rb \ No newline at end of file diff --git a/11-3 Lab Wrapper Cookbooks/default.rb b/11-3 Lab Wrapper Cookbooks/default.rb new file mode 100644 index 0000000..2c25a60 --- /dev/null +++ b/11-3 Lab Wrapper Cookbooks/default.rb @@ -0,0 +1,16 @@ +# chef-repo/cookbooks/myhaproxy/recipes/default.rb +# +# Cookbook Name:: myhaproxy +# Recipe:: default +# +# Copyright (c) 2016 The Authors, All Rights Reserved. + +node.default['haproxy']['members'] = [{ + 'hostname' => 'WEB1_HOSTNAME', # these values come from the Vagrantfile + 'ipaddress' => 'WEB1_IPADDRESS', # or the public IP and hostname is using a cloud provider + 'port' => 80, + 'ssl_port' => 80 + } +] + +include_recipe 'haproxy::manual' \ No newline at end of file diff --git a/11-3 Lab Wrapper Cookbooks/metadata.rb b/11-3 Lab Wrapper Cookbooks/metadata.rb new file mode 100644 index 0000000..8a9a0c9 --- /dev/null +++ b/11-3 Lab Wrapper Cookbooks/metadata.rb @@ -0,0 +1,11 @@ +# chef-repo/cookbooks/myhaproxy/metadata.rb + +name 'myhaproxy' +maintainer 'The Authors' +maintainer_email 'you@example.com' +license 'all_rights' +description 'Installs/Configures myhaproxy' +long_description 'Installs/Configures myhaproxy' +version '0.1.0' + +depends 'haproxy', '= 2.0.0' \ No newline at end of file diff --git a/11-4 Berkshelf/11-4 Berkshelf.txt b/11-4 Berkshelf/11-4 Berkshelf.txt new file mode 100644 index 0000000..d78b07e --- /dev/null +++ b/11-4 Berkshelf/11-4 Berkshelf.txt @@ -0,0 +1,20 @@ +# 11-4 Berkshelf +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo and running 'vagrant up' + +cd ~/chef-repo +cd cookbooks/myhaproxy +tree +cat Berksfile +berks install +cd ~/.berkshelf/cookbooks +ls +cd ~/chef-repo/cookbooks/myhaproxy +cat Berksfile.lock +berks upload +nano recipes/default.rb +berks upload +knife cookbook list +berks upload --force \ No newline at end of file diff --git a/11-5 Lab Deploy LB/11-5 Lab Deploy a Webserver.txt b/11-5 Lab Deploy LB/11-5 Lab Deploy a Webserver.txt new file mode 100644 index 0000000..7dce3a6 --- /dev/null +++ b/11-5 Lab Deploy LB/11-5 Lab Deploy a Webserver.txt @@ -0,0 +1,15 @@ +# 11-5 Lab: Deploy the Load balancer +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo and running 'vagrant up' + +cd ~/chef-repo +vagrant ssh-config +knife bootstrap localhost --ssh-port LOAD-BALANCER_PORT --ssh-user vagrant --sudo --identity-file /PATH/TO/LB_KEY -N load-balancer --run-list "recipe[myhaproxy]" +vagrant ssh load-balancer + +# run these commands on the load-balancer vagrant instance + +vagrant@web1$ curl localhost +vagrant@web1$ exit \ No newline at end of file diff --git a/12-3 Lab Add Web2/12-3 Bootstrap Web2.txt b/12-3 Lab Add Web2/12-3 Bootstrap Web2.txt new file mode 100644 index 0000000..8760c4b --- /dev/null +++ b/12-3 Lab Add Web2/12-3 Bootstrap Web2.txt @@ -0,0 +1,35 @@ +# 12-3 Bootstrap Web2 and Update Load Balancer +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo and running 'vagrant up' + +cd ~/chef-repo +vagrant ssh-config +knife bootstrap localhost --ssh-port WEB2_PORT --ssh-user vagrant --sudo --identity-file /PATH/TO/WEB2_KEY -N web2 --run-list "recipe[workstation],recipe[apache]" +vagrant ssh web2 +cat Vagrantfile +nano cookbooks/myhaproxy/recipes/default.rb +nano cookbooks/myhaproxy/metadata.rb +cd cookbooks/myhaproxy +berks install +berks upload +cd ~/chef-repo +knife cookbook list +knife cookbook show myhaproxy +vagrant ssh load-balancer + + +# run these commands on the web2 vagrant instance + +vagrant@web2$ curl localhost +vagrant@web2$ sudo chef-client +vagrant@web2$ curl localhost +vagrant@web2$ exit + +# run these commands on the load-balancer vagrant instance + +vagrant@load-balancer$ curl localhost +vagrant@load-balancer$ curl localhost +vagrant@load-balancer$ exit + diff --git a/12-3 Lab Add Web2/default.rb b/12-3 Lab Add Web2/default.rb new file mode 100644 index 0000000..345aa45 --- /dev/null +++ b/12-3 Lab Add Web2/default.rb @@ -0,0 +1,21 @@ +# chef-repo/cookbooks/myhaproxy/recipes/default.rb +# +# Cookbook Name:: myhaproxy +# Recipe:: default +# +# Copyright (c) 2016 The Authors, All Rights Reserved. + +node.default['haproxy']['members'] = [{ + 'hostname' => 'WEB1_HOSTNAME', # these values come from the Vagrantfile + 'ipaddress' => 'WEB1_IPADDRESS', # or the public IP and hostname is using a cloud provider + 'port' => 80, + 'ssl_port' => 80 + },{ + 'hostname' => 'WEB2_HOSTNAME', # these values come from the Vagrantfile + 'ipaddress' => 'WEB2_IPADDRESS', # or the public IP and hostname is using a cloud provider + 'port' => 80, + 'ssl_port' => 80 + } +] + +include_recipe 'haproxy::manual' \ No newline at end of file diff --git a/12-4 Verify with Knife/12-4 Verify Node Data with Knife.txt b/12-4 Verify with Knife/12-4 Verify Node Data with Knife.txt new file mode 100644 index 0000000..659b270 --- /dev/null +++ b/12-4 Verify with Knife/12-4 Verify Node Data with Knife.txt @@ -0,0 +1,22 @@ +# 12-4 Verify Node Data with Knife +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo and running 'vagrant up' + +cd ~/chef-repo +knife node --help +knife node list +knife cookbook list +knife cookbook show myhaproxy +knife cookbook show myhaproxy 0.2.0 +knife node show --help +knife node show web1 +knife node show web1 -a ipaddress +knife node show web1 -a hostname +knife node show load-balancer -a haproxy +nano cookbooks/myhaproxy/recipes/default.rb +knife node show load-balancer -a haproxy.members +knife node show load-balancer -a cpu.0.mhz +knife node show load-balancer -a memory.total +knife node show load-balancer -a cookbooks \ No newline at end of file diff --git a/12-5 Bonus Chef-Client/12-5 Bonus Run the chef-client on a Schedule.txt b/12-5 Bonus Chef-Client/12-5 Bonus Run the chef-client on a Schedule.txt new file mode 100644 index 0000000..3b280c8 --- /dev/null +++ b/12-5 Bonus Chef-Client/12-5 Bonus Run the chef-client on a Schedule.txt @@ -0,0 +1,25 @@ +# 12-5 Bonus: Run the chef-client on a Schedule +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo and running 'vagrant up' + +cd ~/chef-repo +chef generate cookbook cookbooks/mychef-client +ls cookbooks/ +cd cookbooks/mychef-client +nano metadata.rb +nano recipes/default.rb +berks install +berks upload +cd ~/chef-repo +knife node show load-balancer +knife node run_list set load-balancer "recipe[mychef-client],recipe[myhaproxy]" +knife node show load-balancer +vagrant ssh load-balancer + +# run these commands on the load-balancer vagrant instance + +vagrant@load-balancer$ sudo chef-client +vagrant@load-balancer$ ps awux | grep chef-client +vagrant@load-balancer$ exit diff --git a/12-5 Bonus Chef-Client/default.rb b/12-5 Bonus Chef-Client/default.rb new file mode 100644 index 0000000..6d83eb9 --- /dev/null +++ b/12-5 Bonus Chef-Client/default.rb @@ -0,0 +1,11 @@ +# ~/chef-repo/cookbooks/mychef-client/recipes/default.rb +# +# Cookbook Name:: mychef-client +# Recipe:: default +# +# Copyright (c) 2016 The Authors, All Rights Reserved. + +node.default['chef_client']['interval'] = '300' +node.default['chef_client']['splay'] = '60' + +include_recipe 'chef-client::default' \ No newline at end of file diff --git a/12-5 Bonus Chef-Client/metadata.rb b/12-5 Bonus Chef-Client/metadata.rb new file mode 100644 index 0000000..13489a1 --- /dev/null +++ b/12-5 Bonus Chef-Client/metadata.rb @@ -0,0 +1,11 @@ +# ~/chef-repo/cookbooks/mychef-client/recipes/metadata.rb + +name 'mychef-client' +maintainer 'The Authors' +maintainer_email 'you@example.com' +license 'all_rights' +description 'Installs/Configures mychef-client' +long_description 'Installs/Configures mychef-client' +version '0.1.0' + +depends 'chef-client', '= 7.0.2' \ No newline at end of file diff --git a/13-3 Creating Roles/13-3 Methods for Creating Roles.txt b/13-3 Creating Roles/13-3 Methods for Creating Roles.txt new file mode 100644 index 0000000..4ef2e47 --- /dev/null +++ b/13-3 Creating Roles/13-3 Methods for Creating Roles.txt @@ -0,0 +1,35 @@ +# 13-3 Methods for Creating Roles +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo and running 'vagrant up' + +cd ~/chef-repo +knife role --help +knife role list +ls roles/ +cat roles/starter.rb +nano roles/web.rb +knife role from file roles/web.rb +knife role list +knife role show web +knife node show web1 +knife node run_list set web1 "role[web]" +knife node show web1 +knife node run_list set web2 "role[web]" +knife node show web2 +vagrant ssh web1 +knife node show web1 +vagrant ssh web2 +knife node show web2 + + +# run these commands on the web1 vagrant instance + +vagrant@web1$ sudo chef-client +vagrant@web1$ exit + +# run these commands on the web2 vagrant instance + +vagrant@web2$ sudo chef-client +vagrant@web2$ exit \ No newline at end of file diff --git a/13-3 Creating Roles/web.rb b/13-3 Creating Roles/web.rb new file mode 100644 index 0000000..94d165a --- /dev/null +++ b/13-3 Creating Roles/web.rb @@ -0,0 +1,3 @@ +name 'web' +description 'Web Server Role' +run_list 'recipe[workstation]','recipe[apache]' \ No newline at end of file diff --git a/13-3 Creating Roles/web_old.rb b/13-3 Creating Roles/web_old.rb new file mode 100644 index 0000000..94d165a --- /dev/null +++ b/13-3 Creating Roles/web_old.rb @@ -0,0 +1,3 @@ +name 'web' +description 'Web Server Role' +run_list 'recipe[workstation]','recipe[apache]' \ No newline at end of file diff --git a/13-4 Lab Load Balancer Role/13-4 Lab Create the Load Balancer Role.txt b/13-4 Lab Load Balancer Role/13-4 Lab Create the Load Balancer Role.txt new file mode 100644 index 0000000..36e5b3a --- /dev/null +++ b/13-4 Lab Load Balancer Role/13-4 Lab Create the Load Balancer Role.txt @@ -0,0 +1,20 @@ +# 13-4 Lab: Create the Load Balancer Role +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo and running 'vagrant up' + +cd ~/chef-repo +ls roles/ + + + +# run these commands on the web1 vagrant instance + +vagrant@web1$ sudo chef-client +vagrant@web1$ exit + +# run these commands on the web2 vagrant instance + +vagrant@web2$ sudo chef-client +vagrant@web2$ exit \ No newline at end of file diff --git a/13-4 Lab Load Balancer Role/load-balancer.rb b/13-4 Lab Load Balancer Role/load-balancer.rb new file mode 100644 index 0000000..b59fdb3 --- /dev/null +++ b/13-4 Lab Load Balancer Role/load-balancer.rb @@ -0,0 +1,3 @@ +name 'load-balancer' +description 'load balancer role' +run_list 'recipe[myhaproxy]' \ No newline at end of file diff --git a/13-4 Lab Load Balancer Role/load-balancer_old.rb b/13-4 Lab Load Balancer Role/load-balancer_old.rb new file mode 100644 index 0000000..b59fdb3 --- /dev/null +++ b/13-4 Lab Load Balancer Role/load-balancer_old.rb @@ -0,0 +1,3 @@ +name 'load-balancer' +description 'load balancer role' +run_list 'recipe[myhaproxy]' \ No newline at end of file diff --git a/13-5 Knife SSH/13-5 Converge Using knife ssh.txt b/13-5 Knife SSH/13-5 Converge Using knife ssh.txt new file mode 100644 index 0000000..c6ea0e5 --- /dev/null +++ b/13-5 Knife SSH/13-5 Converge Using knife ssh.txt @@ -0,0 +1,15 @@ +# 13-5 Converge Using knife ssh +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo and running 'vagrant up' + +cd ~/chef-repo +knife winrm --help +knife ssh --help +vagrant ssh-config +knife ssh localhost 'sudo chef-client' --manual-list --ssh-port WEB1_PORT --ssh-user vagrant --identity-file /PATH/TO/WEB1_KEY/ +knife ssh localhost 'sudo chef-client' -m -p WEB1_PORT -x vagrant -i /PATH/TO/WEB1_KEY/ +knife ssh "*:*" -x chef -P chef "sudo chef-client" +knife ssh "*:*" -x chef -i /PATH/TO/AWS_KEY "sudo chef-client" +knife ssh "role:web" -x chef -P chef "sudo chef-client" \ No newline at end of file diff --git a/14-3 Knife Search/14-3 Running Searches with knife.txt b/14-3 Knife Search/14-3 Running Searches with knife.txt new file mode 100644 index 0000000..51be467 --- /dev/null +++ b/14-3 Knife Search/14-3 Running Searches with knife.txt @@ -0,0 +1,22 @@ +# 14-3 Running Searches with knife +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo and running 'vagrant up' + +cd ~/chef-repo +knife node show web1 +knife node show web1 -a node +knife node show web1 -a ipaddress +knife node show web1 -a memory.total +knife search --help +knife search node "*:*" +knife search node "*:*" -a ipaddress +knife search node "name:web1" +knife search node "name:*" +knife search node "name:web" +knife search node "name:web" -a ipaddress +knife search role "*:*" +knife search role "*:*" -a name +knife search node "role:web AND recipes:apache" +knife search node "role:web" -a ipaddress \ No newline at end of file diff --git a/14-4 Dynamic LB/cloud_default.rb b/14-4 Dynamic LB/cloud_default.rb new file mode 100644 index 0000000..f7b0df6 --- /dev/null +++ b/14-4 Dynamic LB/cloud_default.rb @@ -0,0 +1,30 @@ +# ~/chef-repo/cookbooks/myhaproxy/recipes/default.rb +# +# Cookbook Name:: myhaproxy +# Recipe:: default +# +# Copyright (c) 2016 The Authors, All Rights Reserved. +# +# This recipe is for using the public hostname and public ipaddress +# on any cloud instance, such as AWS, Azure or GCP + +all_web_nodes = search('node',"role:web") + +members = [] + +all_web_nodes.each do |web_node| + + member = { + 'hostname' => web_node['cloud']['public_hostname'], + 'ipaddress' => web_node['cloud']['public_ipv4'], + 'port' => 80, + 'ssl_port' => 80 + } + + members.push(member) + +end + +node.default['haproxy']['members'] = members + +include_recipe "haproxy::manual" \ No newline at end of file diff --git a/14-4 Dynamic LB/default.rb b/14-4 Dynamic LB/default.rb new file mode 100644 index 0000000..cf7d9a6 --- /dev/null +++ b/14-4 Dynamic LB/default.rb @@ -0,0 +1,27 @@ +# ~/chef-repo/cookbooks/myhaproxy/recipes/default.rb +# +# Cookbook Name:: myhaproxy +# Recipe:: default +# +# Copyright (c) 2016 The Authors, All Rights Reserved. + +all_web_nodes = search('node',"role:web") + +members = [] + +all_web_nodes.each do |web_node| + + member = { + 'hostname' => web_node['hostname'], + 'ipaddress' => web_node['ipaddress'], + 'port' => 80, + 'ssl_port' => 80 + } + + members.push(member) + +end + +node.default['haproxy']['members'] = members + +include_recipe "haproxy::manual" \ No newline at end of file diff --git a/14-5 Lab Test LB/14-5 Lab Testing the Dynamic Load Balancer.txt b/14-5 Lab Test LB/14-5 Lab Testing the Dynamic Load Balancer.txt new file mode 100644 index 0000000..88d07ee --- /dev/null +++ b/14-5 Lab Test LB/14-5 Lab Testing the Dynamic Load Balancer.txt @@ -0,0 +1,24 @@ +# 14-5 Lab: Testing the Dynamic Load Balancer +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo and running 'vagrant up' + +cd ~/chef-repo +pwd +cd cookbooks/myhaproxy/ +berks upload +berks install +berks upload +vagrant ssh-config +knife ssh localhost 'sudo chef-client' -m -x vagrant -i /PATH/TO/LB_KEY/ -p LB_PORT +knife node show load-balancer -a haproxy.members + +# or you can run these commands on the load-balancer +# vagrant instance to converge and test + +vagrant ssh load-balancer +vagrant@load-balancer$ sudo chef-client +vagrant@load-balancer$ curl localhost +vagrant@load-balancer$ curl localhost +vagrant@load-balancer$ exit diff --git a/14-5 Lab Test LB/metadata.rb b/14-5 Lab Test LB/metadata.rb new file mode 100644 index 0000000..9373ff7 --- /dev/null +++ b/14-5 Lab Test LB/metadata.rb @@ -0,0 +1,11 @@ +# chef-repo/cookbooks/myhaproxy/metadata.rb + +name 'myhaproxy' +maintainer 'The Authors' +maintainer_email 'you@example.com' +license 'all_rights' +description 'Installs/Configures myhaproxy' +long_description 'Installs/Configures myhaproxy' +version '1.0.0' + +depends 'haproxy', '= 2.0.0' \ No newline at end of file diff --git a/15-3 Creating Environments/15-3 Creating and Managing Environments.txt b/15-3 Creating Environments/15-3 Creating and Managing Environments.txt new file mode 100644 index 0000000..0499702 --- /dev/null +++ b/15-3 Creating Environments/15-3 Creating and Managing Environments.txt @@ -0,0 +1,36 @@ +# 15-3 Creating and Managing Environments +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo and running 'vagrant up' + +cd ~/chef-repo +knife search node "*:*" +knife environment list +knife environment show _default +knife environment --help +ls +mkdir environments +cat cookbooks/apache/metadata.rb +cat cookbooks/myhaproxy/metadata.rb +nano environments/production.rb +knife environment from file environments/production.rb +knife environment list +knife environment show +knife environment show production +knife node environment set web1 production +knife node show web1 +knife nod environment set load-balancer production +knife node show load-balancer +vagrant ssh web1 +vagrant ssh load-balancer + +# run these commands on the web1 vagrant instance + +vagrant@web1$ sudo chef-client +vagrant@web1$ exit + +# run these commands on the load-balancer vagrant instance + +vagrant@load-balancer$ sudo chef-client +vagrant@load-balancer$ exit diff --git a/15-3 Creating Environments/production.rb b/15-3 Creating Environments/production.rb new file mode 100644 index 0000000..1e85507 --- /dev/null +++ b/15-3 Creating Environments/production.rb @@ -0,0 +1,5 @@ +name 'production' +description 'where production code is run' + +cookbook 'apache', '= 0.2.1' +cookbook 'myhaproxy', '= 1.0.0' \ No newline at end of file diff --git a/15-4 Lab Acceptance Env/15-4 Lab Acceptance Environment.txt b/15-4 Lab Acceptance Env/15-4 Lab Acceptance Environment.txt new file mode 100644 index 0000000..fac26ea --- /dev/null +++ b/15-4 Lab Acceptance Env/15-4 Lab Acceptance Environment.txt @@ -0,0 +1,23 @@ +# 15-4 Lab: Assign web2 to an Acceptance Environment +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo and running 'vagrant up' + +cd ~/chef-repo +ls environments/ +nano environments/acceptance.rb +ls environments/ +knife environment list +knife environment from file environments/acceptance.rb +knife environment list +knife environment show acceptance +knife node environment set web2 acceptance +knife node show web2 +vagrant ssh web2 + + +# run these commands on the web2 vagrant instance + +vagrant@web2$ sudo chef-client +vagrant@web2$ exit \ No newline at end of file diff --git a/15-4 Lab Acceptance Env/acceptance.rb b/15-4 Lab Acceptance Env/acceptance.rb new file mode 100644 index 0000000..576c187 --- /dev/null +++ b/15-4 Lab Acceptance Env/acceptance.rb @@ -0,0 +1,4 @@ +name 'acceptance' +description 'where application code is tested' + +# no cookbook restrictions \ No newline at end of file diff --git a/15-5 Refine LB/15-5 Refine the Load Balancer.txt b/15-5 Refine LB/15-5 Refine the Load Balancer.txt new file mode 100644 index 0000000..a251412 --- /dev/null +++ b/15-5 Refine LB/15-5 Refine the Load Balancer.txt @@ -0,0 +1,30 @@ +# 15-5 Refine the Load Balancer +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo and running 'vagrant up' + +cd ~/chef-repo +knife cookbook list +cd cookbooks/myhaproxy/ +berks upload +berks install +berks upload +knife cookbook list +vagrant ssh load-balancer +knife environment show production +knife search node "*:*" +knife search node "chef_environment:production" +cd ~/chef-repo +nano environments/production.rb +knife environment from file environments/production.rb +knife environment show production + + + +# run these commands on the load-balancer vagrant instance to test the 1.0.1 version of myhaproxy + +vagrant@load-balancer$ sudo chef-client +vagrant@load-balancer$ curl localhost +vagrant@load-balancer$ curl localhost +vagrant@load-balancer$ exit \ No newline at end of file diff --git a/15-5 Refine LB/cloud_default.rb b/15-5 Refine LB/cloud_default.rb new file mode 100644 index 0000000..a546409 --- /dev/null +++ b/15-5 Refine LB/cloud_default.rb @@ -0,0 +1,30 @@ +# ~/chef-repo/cookbooks/myhaproxy/recipes/default.rb +# +# Cookbook Name:: myhaproxy +# Recipe:: default +# +# Copyright (c) 2016 The Authors, All Rights Reserved. +# +# This recipe is for using the public hostname and public ipaddress +# on any cloud instance, such as AWS, Azure or GCP + +all_web_nodes = search('node',"role:web AND chef_environment:#{node.chef_environment}") + +members = [] + +all_web_nodes.each do |web_node| + + member = { + 'hostname' => web_node['cloud']['public_hostname'], + 'ipaddress' => web_node['cloud']['public_ipv4'], + 'port' => 80, + 'ssl_port' => 80 + } + + members.push(member) + +end + +node.default['haproxy']['members'] = members + +include_recipe "haproxy::manual" \ No newline at end of file diff --git a/15-5 Refine LB/default.rb b/15-5 Refine LB/default.rb new file mode 100644 index 0000000..fb13a91 --- /dev/null +++ b/15-5 Refine LB/default.rb @@ -0,0 +1,27 @@ +# ~/chef-repo/cookbooks/myhaproxy/recipes/default.rb +# +# Cookbook Name:: myhaproxy +# Recipe:: default +# +# Copyright (c) 2016 The Authors, All Rights Reserved. + +all_web_nodes = search('node',"role:web AND chef_environment:#{node.chef_environment}") + +members = [] + +all_web_nodes.each do |web_node| + + member = { + 'hostname' => web_node['hostname'], + 'ipaddress' => web_node['ipaddress'], + 'port' => 80, + 'ssl_port' => 80 + } + + members.push(member) + +end + +node.default['haproxy']['members'] = members + +include_recipe "haproxy::manual" \ No newline at end of file diff --git a/15-5 Refine LB/metadata.rb b/15-5 Refine LB/metadata.rb new file mode 100644 index 0000000..971ba25 --- /dev/null +++ b/15-5 Refine LB/metadata.rb @@ -0,0 +1,11 @@ +# chef-repo/cookbooks/myhaproxy/metadata.rb + +name 'myhaproxy' +maintainer 'The Authors' +maintainer_email 'you@example.com' +license 'all_rights' +description 'Installs/Configures myhaproxy' +long_description 'Installs/Configures myhaproxy' +version '1.0.1' + +depends 'haproxy', '= 2.0.0' \ No newline at end of file diff --git a/16-3 Using Data Bags/16-3 Using Data Bags.txt b/16-3 Using Data Bags/16-3 Using Data Bags.txt new file mode 100644 index 0000000..85d27a5 --- /dev/null +++ b/16-3 Using Data Bags/16-3 Using Data Bags.txt @@ -0,0 +1,25 @@ +# 16-3 Using Data Bags +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo and running 'vagrant up' + +cd ~/chef-repo +ls +mkdir data_bags +mkdir data_bags/users +knife data bag --help +knife data bag list +knife data bag create users +knife data bag from file users data_bags/users/user1.json data_bags/users/user2.json +knife data bag list +knife data bag show users +knife data bag show users/user1 +knife search users "*:*" +knife search users "platform:centos" +knife search users "platform:centos" -a comment +mkdir data_bags/groups +knife data bag create groups +knife data bag from file groups data_bags/groups/group1.json +knife data bag show groups +knife data bag show groups group1 \ No newline at end of file diff --git a/16-3 Using Data Bags/data_bags.zip b/16-3 Using Data Bags/data_bags.zip new file mode 100644 index 0000000..d9debbc Binary files /dev/null and b/16-3 Using Data Bags/data_bags.zip differ diff --git a/16-3 Using Data Bags/data_bags/groups/group1.json b/16-3 Using Data Bags/data_bags/groups/group1.json new file mode 100644 index 0000000..b0e2024 --- /dev/null +++ b/16-3 Using Data Bags/data_bags/groups/group1.json @@ -0,0 +1,6 @@ +{ + "id": "group1", + "gid": 2000, + "members": ["user1","user2"], + "platform": "centos" +} \ No newline at end of file diff --git a/16-3 Using Data Bags/data_bags/users/user1.json b/16-3 Using Data Bags/data_bags/users/user1.json new file mode 100644 index 0000000..7fd725a --- /dev/null +++ b/16-3 Using Data Bags/data_bags/users/user1.json @@ -0,0 +1,9 @@ +{ + "id": "user1", + "comment": "I am user1", + "uid": 100, + "gid": 1, + "home": "/home/user1", + "shell": "/bin/bash", + "platform": "centos" +} \ No newline at end of file diff --git a/16-3 Using Data Bags/data_bags/users/user2.json b/16-3 Using Data Bags/data_bags/users/user2.json new file mode 100644 index 0000000..cf88edb --- /dev/null +++ b/16-3 Using Data Bags/data_bags/users/user2.json @@ -0,0 +1,9 @@ +{ + "id": "user2", + "comment": "I am user2", + "uid": 101, + "gid": 1, + "home": "/home/user2", + "shell": "/bin/bash", + "platform": "centos" +} \ No newline at end of file diff --git a/16-4 Users and Groups/16-4 Users and Groups from Data Bags.txt b/16-4 Users and Groups/16-4 Users and Groups from Data Bags.txt new file mode 100644 index 0000000..b6d2ea2 --- /dev/null +++ b/16-4 Users and Groups/16-4 Users and Groups from Data Bags.txt @@ -0,0 +1,10 @@ +# 16-4 Users and Groups from Data Bags +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo and running 'vagrant up' + +cd ~/chef-repo +chef generate cookbook cookbooks/myusers +tree cookbooks/myusers/ +nano cookbooks/myusers/recipes/default.rb diff --git a/16-4 Users and Groups/data_bags.zip b/16-4 Users and Groups/data_bags.zip new file mode 100644 index 0000000..bd0fdd7 Binary files /dev/null and b/16-4 Users and Groups/data_bags.zip differ diff --git a/16-4 Users and Groups/data_bags/users/user1.json b/16-4 Users and Groups/data_bags/users/user1.json new file mode 100644 index 0000000..7fd725a --- /dev/null +++ b/16-4 Users and Groups/data_bags/users/user1.json @@ -0,0 +1,9 @@ +{ + "id": "user1", + "comment": "I am user1", + "uid": 100, + "gid": 1, + "home": "/home/user1", + "shell": "/bin/bash", + "platform": "centos" +} \ No newline at end of file diff --git a/16-4 Users and Groups/data_bags/users/user2.json b/16-4 Users and Groups/data_bags/users/user2.json new file mode 100644 index 0000000..cf88edb --- /dev/null +++ b/16-4 Users and Groups/data_bags/users/user2.json @@ -0,0 +1,9 @@ +{ + "id": "user2", + "comment": "I am user2", + "uid": 101, + "gid": 1, + "home": "/home/user2", + "shell": "/bin/bash", + "platform": "centos" +} \ No newline at end of file diff --git a/16-4 Users and Groups/default.rb b/16-4 Users and Groups/default.rb new file mode 100644 index 0000000..b29a437 --- /dev/null +++ b/16-4 Users and Groups/default.rb @@ -0,0 +1,16 @@ +# ~/chef-repo/cookbooks/myusers/recipes/default.rb +# +# Cookbook Name:: myusers +# Recipe:: default +# +# Copyright (c) 2016 The Authors, All Rights Reserved. + +search("users", "platform:centos").each do |user_data| + user user_data['id'] do + comment user_data['comment'] + uid user_data['uid'] + gid user_data['gid'] + home user_data['home'] + shell user_data['shell'] + end +end \ No newline at end of file diff --git a/16-4 Users and Groups/web.rb b/16-4 Users and Groups/web.rb new file mode 100644 index 0000000..c487825 --- /dev/null +++ b/16-4 Users and Groups/web.rb @@ -0,0 +1,3 @@ +name 'web' +description 'Web Server Role' +run_list 'recipe[myusers]','recipe[workstation]','recipe[apache]' \ No newline at end of file diff --git a/16-5 Lab Data Bags/16-5 Lab Managing Data Bags.txt b/16-5 Lab Data Bags/16-5 Lab Managing Data Bags.txt new file mode 100644 index 0000000..8a2562e --- /dev/null +++ b/16-5 Lab Data Bags/16-5 Lab Managing Data Bags.txt @@ -0,0 +1,30 @@ +# 16-5 Lab: Managing Data Bags +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo and running 'vagrant up' + +cd ~/chef-repo +knife data bag show users +knife data bag show groups +knife data bag from file users data_bags/users/anthony.json data_bags/users/gordon.json data_bags/users/julia.json +knife data bag show users +knife data bag from file groups data_bags/groups/chefs.json +knife data bag show groups +knife search users "*:*" +knife search users "*:*" -a home +knife search groups "platform:centos" +knife search groups "platform:centos" -a members +cd cookbooks/myusers/ +berks upload +berks upload --force +cd ~/chef-repo +knife role from file roles/web.rb roles/base.rb roles/load-balancer.rb +vagrant ssh web1 + +# run these commands on the web1 vagrant instance + +vagrant@web1$ sudo chef-client +vagrant@web1$ cat /etc/passwd +vagrant@web1$ cat /etc/group +vagrant@web1$ exit \ No newline at end of file diff --git a/16-5 Lab Data Bags/base.rb b/16-5 Lab Data Bags/base.rb new file mode 100644 index 0000000..45741b3 --- /dev/null +++ b/16-5 Lab Data Bags/base.rb @@ -0,0 +1,3 @@ +name 'base' +description 'Base Role for all Servers' +run_list 'recipe[myusers]' \ No newline at end of file diff --git a/16-5 Lab Data Bags/data_bags.zip b/16-5 Lab Data Bags/data_bags.zip new file mode 100644 index 0000000..1d9c0d1 Binary files /dev/null and b/16-5 Lab Data Bags/data_bags.zip differ diff --git a/16-5 Lab Data Bags/data_bags/groups/chefs.json b/16-5 Lab Data Bags/data_bags/groups/chefs.json new file mode 100644 index 0000000..9bc296b --- /dev/null +++ b/16-5 Lab Data Bags/data_bags/groups/chefs.json @@ -0,0 +1,6 @@ +{ + "id": "chefs", + "gid": 42, + "platform": "centos", + "members": ["julia","anthony","gordon"] +} \ No newline at end of file diff --git a/16-5 Lab Data Bags/data_bags/users/anthony.json b/16-5 Lab Data Bags/data_bags/users/anthony.json new file mode 100644 index 0000000..aed824d --- /dev/null +++ b/16-5 Lab Data Bags/data_bags/users/anthony.json @@ -0,0 +1,10 @@ +{ + "id": "anthony", + "comment": "anthony bourdain", + "uid": 200, + "gid": 0, + "home": "/home/anthony", + "shell": "/bin/bash", + "platform": "centos", + "tvshow": "food network" +} \ No newline at end of file diff --git a/16-5 Lab Data Bags/data_bags/users/gordon.json b/16-5 Lab Data Bags/data_bags/users/gordon.json new file mode 100644 index 0000000..7da6eb8 --- /dev/null +++ b/16-5 Lab Data Bags/data_bags/users/gordon.json @@ -0,0 +1,10 @@ +{ + "id": "gordon", + "comment": "gordon ramsay", + "uid": 201, + "gid": 0, + "home": "/home/gordon", + "shell": "/bin/bash", + "platform": "centos", + "tvshow": "MasterChef" +} \ No newline at end of file diff --git a/16-5 Lab Data Bags/data_bags/users/julia.json b/16-5 Lab Data Bags/data_bags/users/julia.json new file mode 100644 index 0000000..1435512 --- /dev/null +++ b/16-5 Lab Data Bags/data_bags/users/julia.json @@ -0,0 +1,10 @@ +{ + "id": "julia", + "comment": "julia child", + "uid": 202, + "gid": 0, + "home": "/home/julia", + "shell": "/bin/bash", + "platform": "centos", + "tvshow": "baking with julia" +} \ No newline at end of file diff --git a/16-5 Lab Data Bags/default.rb b/16-5 Lab Data Bags/default.rb new file mode 100644 index 0000000..6bf27c0 --- /dev/null +++ b/16-5 Lab Data Bags/default.rb @@ -0,0 +1,18 @@ +# ~/chef-repo/cookbooks/myusers/recipes/default.rb +# +# Cookbook Name:: myusers +# Recipe:: default +# +# Copyright (c) 2016 The Authors, All Rights Reserved. + +search("users", "platform:centos").each do |user_data| + user user_data['id'] do + comment user_data['comment'] + uid user_data['uid'] + gid user_data['gid'] + home user_data['home'] + shell user_data['shell'] + end +end + +include_recipe 'myusers::groups' \ No newline at end of file diff --git a/16-5 Lab Data Bags/groups.rb b/16-5 Lab Data Bags/groups.rb new file mode 100644 index 0000000..0f2be01 --- /dev/null +++ b/16-5 Lab Data Bags/groups.rb @@ -0,0 +1,8 @@ +# ~/chef-repo/cookbooks/myusers/recipes/groups.rb + +search("groups", "platform:centos").each do |group_data| + group group_data['id'] do + gid group_data['gid'] + members group_data['members'] + end +end \ No newline at end of file diff --git a/16-5 Lab Data Bags/load-balancer.rb b/16-5 Lab Data Bags/load-balancer.rb new file mode 100644 index 0000000..5e6f600 --- /dev/null +++ b/16-5 Lab Data Bags/load-balancer.rb @@ -0,0 +1,3 @@ +name 'load-balancer' +description 'Load Balancer Role' +run_list 'role[base]','recipe[myhaproxy]' \ No newline at end of file diff --git a/16-5 Lab Data Bags/metadata.rb b/16-5 Lab Data Bags/metadata.rb new file mode 100644 index 0000000..eaac1c6 --- /dev/null +++ b/16-5 Lab Data Bags/metadata.rb @@ -0,0 +1,9 @@ +# chef-repo/cookbooks/myusers/metadata.rb + +name 'myusers' +maintainer 'The Authors' +maintainer_email 'you@example.com' +license 'all_rights' +description 'Installs/Configures myusers' +long_description 'Installs/Configures myusers' +version '0.2.0' \ No newline at end of file diff --git a/16-5 Lab Data Bags/web.rb b/16-5 Lab Data Bags/web.rb new file mode 100644 index 0000000..798ce00 --- /dev/null +++ b/16-5 Lab Data Bags/web.rb @@ -0,0 +1,3 @@ +name 'web' +description 'Web Server Role' +run_list 'role[base]','recipe[workstation]','recipe[apache]' \ No newline at end of file diff --git a/16-6 Encrypting Secrets/16-6 Encrypting Secrets.txt b/16-6 Encrypting Secrets/16-6 Encrypting Secrets.txt new file mode 100644 index 0000000..2ac3fe8 --- /dev/null +++ b/16-6 Encrypting Secrets/16-6 Encrypting Secrets.txt @@ -0,0 +1,26 @@ +# 16-6 Encrypting Secrets +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor + +# run these commands on your local machine after copying new Vagrantfile to ~/chef-repo and running 'vagrant up' + +cd ~/chef-repo +knife data bag list +openssl rand -base64 512 | tr -d '\r\n' > secret-key +ls +cat secret-key +knife data bag create secret-users --secret-file secret-file +knife data bag list +knife data bag from file secret-users data_bags/users/julia.json --secret-file secret-key +knife data bag show secret-users +knife data bag show secret-users julia +knife data bag show secret-users/julia +knife data bag show secret-users julia --secret-file secret-key +vagrant ssh web1 +knife vault --help + +# run these commands on the web1 vagrant instance + +vagrant@web1$ ls /etc/chef/ +vagrant@web1$ cat /etc/passwd +vagrant@web1$ exit \ No newline at end of file diff --git a/2-3 your first recipe/2-1 Lab Your First Recipe.txt b/2-3 your first recipe/2-1 Lab Your First Recipe.txt new file mode 100644 index 0000000..3f52e56 --- /dev/null +++ b/2-3 your first recipe/2-1 Lab Your First Recipe.txt @@ -0,0 +1,12 @@ +# 2-3 Lab: Your First Recipe! +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor +# run these commands from your vagrant or cloud CentOS 7 instance + +cd ~ +which chef +which nano +nano hello.rb +cat hello.rb +sudo chef-client --local-mode hello.rb +cat /hello.txt \ No newline at end of file diff --git a/2-3 your first recipe/2-3 Lab Your First Recipe.txt b/2-3 your first recipe/2-3 Lab Your First Recipe.txt new file mode 100644 index 0000000..3f52e56 --- /dev/null +++ b/2-3 your first recipe/2-3 Lab Your First Recipe.txt @@ -0,0 +1,12 @@ +# 2-3 Lab: Your First Recipe! +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor +# run these commands from your vagrant or cloud CentOS 7 instance + +cd ~ +which chef +which nano +nano hello.rb +cat hello.rb +sudo chef-client --local-mode hello.rb +cat /hello.txt \ No newline at end of file diff --git a/2-3 your first recipe/hello.rb b/2-3 your first recipe/hello.rb new file mode 100644 index 0000000..131b58c --- /dev/null +++ b/2-3 your first recipe/hello.rb @@ -0,0 +1,16 @@ +# This is an example of the file you should have written on your vagrant or cloud instance +# The path of the recipe is '/hello.rb' +# This ruby file will be run with the command 'sudo chef-client --local-mode hello.rb' +# The result is that a file, hello.txt, will be created in the root directory +# with the content "Hello, world!" + +# +# The file, named '/hello.txt' is created +# with the content 'Hello, world!' +# +# @see https://docs.chef.io/resource_file.html +# + +file '/hello.txt' do + content 'Hello, world!' +end \ No newline at end of file diff --git a/3-2 exploring system resources/3-2 Exploring System Resources.txt b/3-2 exploring system resources/3-2 Exploring System Resources.txt new file mode 100644 index 0000000..bf3c66e --- /dev/null +++ b/3-2 exploring system resources/3-2 Exploring System Resources.txt @@ -0,0 +1,8 @@ +# 3-2 Exploring System Resources +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor +# run these commands from your vagrant or cloud CentOS 7 instance + +cd ~ +sudo chef-client --local-mode hello.rb +cat /hello.txt \ No newline at end of file diff --git a/3-2 exploring system resources/hello.rb b/3-2 exploring system resources/hello.rb new file mode 100644 index 0000000..8b1e073 --- /dev/null +++ b/3-2 exploring system resources/hello.rb @@ -0,0 +1,16 @@ +# This is an example of the file you should have written on your vagrant or cloud instance +# The title of the recipe is 'hello.rb' +# This ruby file will be run with the command 'sudo chef-client --local-mode hello.rb' +# The result is that a file, hello.txt, will be created in the root directory +# with the content "Hello, world!" + +# +# The file, named '/hello.txt' is created +# with the content 'Hello, world!' +# +# @see https://docs.chef.io/resource_file.html +# + +file '/hello.txt' do + content 'Hello, world!' +end \ No newline at end of file diff --git a/3-3 convergence and desired state/# 3-3 Convergence and Desired State.txt b/3-3 convergence and desired state/# 3-3 Convergence and Desired State.txt new file mode 100644 index 0000000..d51aabf --- /dev/null +++ b/3-3 convergence and desired state/# 3-3 Convergence and Desired State.txt @@ -0,0 +1,14 @@ +# 3-3 Convergence and Desired State +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# run these commands from your vagrant or cloud CentOS 7 instance + +cd ~ +sudo chef-client --local-mode hello.rb +cat /hello.txt +vim /hello.txt +sudo vim /hello.txt +cat /hello.txt +ls -l /hello.txt +sudo chown vagrant /hello.txt +ls -l /hello.txt +sudo chef-client --local-mode hello.rb \ No newline at end of file diff --git a/3-3 convergence and desired state/3-3 Convergence and Desired State commands.txt b/3-3 convergence and desired state/3-3 Convergence and Desired State commands.txt new file mode 100644 index 0000000..d51aabf --- /dev/null +++ b/3-3 convergence and desired state/3-3 Convergence and Desired State commands.txt @@ -0,0 +1,14 @@ +# 3-3 Convergence and Desired State +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# run these commands from your vagrant or cloud CentOS 7 instance + +cd ~ +sudo chef-client --local-mode hello.rb +cat /hello.txt +vim /hello.txt +sudo vim /hello.txt +cat /hello.txt +ls -l /hello.txt +sudo chown vagrant /hello.txt +ls -l /hello.txt +sudo chef-client --local-mode hello.rb \ No newline at end of file diff --git a/3-3 convergence and desired state/3-3 Convergence and Desired State.txt b/3-3 convergence and desired state/3-3 Convergence and Desired State.txt new file mode 100644 index 0000000..0c404ac --- /dev/null +++ b/3-3 convergence and desired state/3-3 Convergence and Desired State.txt @@ -0,0 +1,15 @@ +# 3-3 Convergence and Desired State commands +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor +# run these commands from your vagrant or cloud CentOS 7 instance + +cd ~ +sudo chef-client --local-mode hello.rb +cat /hello.txt +vim /hello.txt +sudo vim /hello.txt +cat /hello.txt +ls -l /hello.txt +sudo chown vagrant /hello.txt +ls -l /hello.txt +sudo chef-client --local-mode hello.rb \ No newline at end of file diff --git a/3-3 convergence and desired state/hello.txt b/3-3 convergence and desired state/hello.txt new file mode 100644 index 0000000..4f0891e --- /dev/null +++ b/3-3 convergence and desired state/hello.txt @@ -0,0 +1,2 @@ +Hello, world! +random content!!! \ No newline at end of file diff --git a/3-4 organizing resources/3-4 Organizing Resources.txt b/3-4 organizing resources/3-4 Organizing Resources.txt new file mode 100644 index 0000000..37bdead --- /dev/null +++ b/3-4 organizing resources/3-4 Organizing Resources.txt @@ -0,0 +1,6 @@ +# 3-4 Organizing Resources +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# run these commands from your vagrant or cloud CentOS 7 instance + +cd ~ +nano setup.rb \ No newline at end of file diff --git a/3-4 organizing resources/setup.rb b/3-4 organizing resources/setup.rb new file mode 100644 index 0000000..84fda3e --- /dev/null +++ b/3-4 organizing resources/setup.rb @@ -0,0 +1,15 @@ +# ~/setup.rb + +package 'tree' do + action :install +end + +package 'ntp' + +file '/etc/motd' do + content 'This server is the property of ...' +end + +service 'ntpd' do + action [:enable, :start] +end \ No newline at end of file diff --git a/3-4 organizing resources/setup_old.rb b/3-4 organizing resources/setup_old.rb new file mode 100644 index 0000000..3838483 --- /dev/null +++ b/3-4 organizing resources/setup_old.rb @@ -0,0 +1,15 @@ + + +package 'tree' do + action :install +end + +package 'ntp' + +file '/etc/motd' do + content 'This server is the property of ...' +end + +service 'ntpd' do + action [:enable, :start] +end \ No newline at end of file diff --git a/3-5 lab workstation/3-5 Lab: Workstation Setup Recipe.txt b/3-5 lab workstation/3-5 Lab: Workstation Setup Recipe.txt new file mode 100644 index 0000000..385592a --- /dev/null +++ b/3-5 lab workstation/3-5 Lab: Workstation Setup Recipe.txt @@ -0,0 +1,12 @@ +# 3-5 Lab: Workstation Setup Recipe +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor +# run these commands from your vagrant or cloud CentOS 7 instance + +cd ~ +touch setup.rb +nano setup.rb +cat setup.rb +sudo chef-client --local-mode setup.rb +which tree +sudo chef-client --local-mode setup.rb \ No newline at end of file diff --git a/3-5 lab workstation/setup.rb b/3-5 lab workstation/setup.rb new file mode 100644 index 0000000..0e5cd99 --- /dev/null +++ b/3-5 lab workstation/setup.rb @@ -0,0 +1,14 @@ +# ~/setup.rb + +package 'tree' do + action :install +end + +package 'ntp' + +file '/etc/motd' do + content 'This server is the property of ...' + action :create + owner 'root' + group 'root' +end \ No newline at end of file diff --git a/3-5 lab workstation/setup_old.rb b/3-5 lab workstation/setup_old.rb new file mode 100644 index 0000000..0e5cd99 --- /dev/null +++ b/3-5 lab workstation/setup_old.rb @@ -0,0 +1,14 @@ +# ~/setup.rb + +package 'tree' do + action :install +end + +package 'ntp' + +file '/etc/motd' do + content 'This server is the property of ...' + action :create + owner 'root' + group 'root' +end \ No newline at end of file diff --git a/4-3 cookbook components/4-3 Cookbook Components.txt b/4-3 cookbook components/4-3 Cookbook Components.txt new file mode 100644 index 0000000..e938d88 --- /dev/null +++ b/4-3 cookbook components/4-3 Cookbook Components.txt @@ -0,0 +1,16 @@ +# 4-3 Cookbook Components +# commands that involve editing files assume nano as the text editor +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# run these commands from your vagrant or cloud CentOS 7 instance + +cd ~ +chef --help +chef generate --help +chef generate cookbook --help +mkdir cookbooks +chef generate cookbook coobooks/workstation +tree +cat cookbooks/workstation/metadata.rb +cat cookbooks/workstation/README.md +cat cookbooks/workstation/recipes/default.rb +mv setup.rb cookbooks/workstation/recipes/ \ No newline at end of file diff --git a/4-4 revision with git/4-4 Revision with Git.txt b/4-4 revision with git/4-4 Revision with Git.txt new file mode 100644 index 0000000..37d8dfe --- /dev/null +++ b/4-4 revision with git/4-4 Revision with Git.txt @@ -0,0 +1,25 @@ +# 4-4 Revision with Git +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor +# run these commands from your vagrant or cloud CentOS 7 instance + +cd ~ +tree +which git +nano cookbooks/workstation/recipes/setup.rb +sudo chef-client -z cookbooks/workstation/recipes/setup.rb +cd cookbooks/workstation/ +pwd +tree +git init +ls -a +git status +git add . +git status +git commit -m "initial workstation cookbook commit" +git status +nano recipes/setup.rb +git status +git add recipes/setup.rb +git commit -m "added ntp to setup.rb" +git status \ No newline at end of file diff --git a/4-5 lab apache/4-5 Lab Deploy Apache Webserver.txt b/4-5 lab apache/4-5 Lab Deploy Apache Webserver.txt new file mode 100644 index 0000000..fd1bbc7 --- /dev/null +++ b/4-5 lab apache/4-5 Lab Deploy Apache Webserver.txt @@ -0,0 +1,15 @@ +# 4-5 Lab: Deploy Apache Webserver +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor +# run these commands from your vagrant or cloud CentOS 7 instance + +cd ~ +chef generate cookbook cookbooks/apache +tree +chef generate --help +chef generate recipe cookbooks/apache/server +tree +nano cookbooks/apache/recipes/server.rb +chef exec ruby -c cookbooks/apache/recipes/server.rb +sudo chef-client -z cookbooks/apache/recipes/server.rb +curl localhost \ No newline at end of file diff --git a/4-5 lab apache/4-5 Lab: Deploy Apache Webserver.txt b/4-5 lab apache/4-5 Lab: Deploy Apache Webserver.txt new file mode 100644 index 0000000..fd1bbc7 --- /dev/null +++ b/4-5 lab apache/4-5 Lab: Deploy Apache Webserver.txt @@ -0,0 +1,15 @@ +# 4-5 Lab: Deploy Apache Webserver +# this command list is provided to accompany the demos in the Chef Fundamentals Udemy course +# commands that involve editing files assume nano as the text editor +# run these commands from your vagrant or cloud CentOS 7 instance + +cd ~ +chef generate cookbook cookbooks/apache +tree +chef generate --help +chef generate recipe cookbooks/apache/server +tree +nano cookbooks/apache/recipes/server.rb +chef exec ruby -c cookbooks/apache/recipes/server.rb +sudo chef-client -z cookbooks/apache/recipes/server.rb +curl localhost \ No newline at end of file diff --git a/4-5 lab apache/server.rb b/4-5 lab apache/server.rb new file mode 100644 index 0000000..a8d4b5f --- /dev/null +++ b/4-5 lab apache/server.rb @@ -0,0 +1,13 @@ +# ~/cookbooks/apache/recipes/server.rb + +package 'httpd' do + action :install +end + +file '/var/www/html/index.html' do + content '