├── .DS_Store ├── .gitignore ├── .gitmodules ├── Berksfile ├── Berksfile.lock ├── LICENSE ├── README.md ├── Vagrantfile ├── chefignore ├── metadata.rb ├── opsworks-roles └── example-layer.json └── recipes └── default.rb /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erupenkman/opsworks-example/ceda66a6905fa356d45eb8a0ced7acb6e9be98de/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "opsworks/cookbooks"] 2 | path = opsworks/cookbooks 3 | url = https://github.com/aws/opsworks-cookbooks.git 4 | branch = release-chef-11.10 5 | -------------------------------------------------------------------------------- /Berksfile: -------------------------------------------------------------------------------- 1 | source "https://supermarket.getchef.com" 2 | 3 | metadata 4 | isVagrant = ENV.include?('VAGRANT_EXECUTABLE') 5 | 6 | if isVagrant 7 | cookbook "deploy", path: 'opsworks/cookbooks/deploy' 8 | cookbook "apache2", path: 'opsworks/cookbooks/apache2' 9 | 10 | cookbook "ruby", path: 'opsworks/cookbooks/ruby' 11 | cookbook "opsworks_rubygems", path: 'opsworks/cookbooks/opsworks_rubygems' 12 | cookbook "opsworks_bundler", path: 'opsworks/cookbooks/opsworks_bundler' 13 | 14 | cookbook "opsworks_commons", path: 'opsworks/cookbooks/opsworks_commons' 15 | cookbook "scm_helper", path: 'opsworks/cookbooks/scm_helper' 16 | cookbook "mod_php5_apache2", path: 'opsworks/cookbooks/mod_php5_apache2' 17 | cookbook "ssh_users", path: 'opsworks/cookbooks/ssh_users' 18 | cookbook "opsworks_agent_monit", path: 'opsworks/cookbooks/opsworks_agent_monit' 19 | cookbook "opsworks_java", path: 'opsworks/cookbooks/opsworks_java' 20 | cookbook "opsworks_aws_flow_ruby", path: 'opsworks/cookbooks/opsworks_aws_flow_ruby' 21 | cookbook "gem_support", path: 'opsworks/cookbooks/gem_support' 22 | cookbook "opsworks_nodejs", path: 'opsworks/cookbooks/opsworks_nodejs' 23 | cookbook "opsworks_initial_setup", path: 'opsworks/cookbooks/opsworks_initial_setup' 24 | cookbook "mysql", path: 'opsworks/cookbooks/mysql' 25 | cookbook "dependencies", path: 'opsworks/cookbooks/dependencies' 26 | cookbook "opsworks_ganglia", path: 'opsworks/cookbooks/opsworks_ganglia' 27 | 28 | end -------------------------------------------------------------------------------- /Berksfile.lock: -------------------------------------------------------------------------------- 1 | DEPENDENCIES 2 | apache2 3 | path: opsworks/cookbooks/apache2 4 | dependencies 5 | path: opsworks/cookbooks/dependencies 6 | deploy 7 | path: opsworks/cookbooks/deploy 8 | gem_support 9 | path: opsworks/cookbooks/gem_support 10 | mod_php5_apache2 11 | path: opsworks/cookbooks/mod_php5_apache2 12 | mysql 13 | path: opsworks/cookbooks/mysql 14 | opsworks-example-project 15 | path: . 16 | metadata: true 17 | opsworks_agent_monit 18 | path: opsworks/cookbooks/opsworks_agent_monit 19 | opsworks_aws_flow_ruby 20 | path: opsworks/cookbooks/opsworks_aws_flow_ruby 21 | opsworks_bundler 22 | path: opsworks/cookbooks/opsworks_bundler 23 | opsworks_commons 24 | path: opsworks/cookbooks/opsworks_commons 25 | opsworks_ganglia 26 | path: opsworks/cookbooks/opsworks_ganglia 27 | opsworks_initial_setup 28 | path: opsworks/cookbooks/opsworks_initial_setup 29 | opsworks_java 30 | path: opsworks/cookbooks/opsworks_java 31 | opsworks_nodejs 32 | path: opsworks/cookbooks/opsworks_nodejs 33 | opsworks_rubygems 34 | path: opsworks/cookbooks/opsworks_rubygems 35 | ruby 36 | path: opsworks/cookbooks/ruby 37 | scm_helper 38 | path: opsworks/cookbooks/scm_helper 39 | ssh_users 40 | path: opsworks/cookbooks/ssh_users 41 | 42 | GRAPH 43 | apache2 (1.0.0) 44 | apt (2.6.1) 45 | bluepill (2.3.1) 46 | rsyslog (>= 0.0.0) 47 | build-essential (2.1.3) 48 | chef-sugar (2.5.0) 49 | chef_handler (1.1.6) 50 | dependencies (1.0.0) 51 | gem_support (>= 0.0.0) 52 | opsworks_nodejs (>= 0.0.0) 53 | packages (>= 0.0.0) 54 | ruby (>= 0.0.0) 55 | deploy (1.0.0) 56 | apache2 (>= 0.0.0) 57 | dependencies (>= 0.0.0) 58 | mod_php5_apache2 (>= 0.0.0) 59 | mysql (>= 0.0.0) 60 | nginx (>= 0.0.0) 61 | opsworks_agent_monit (>= 0.0.0) 62 | opsworks_aws_flow_ruby (>= 0.0.0) 63 | opsworks_java (>= 0.0.0) 64 | opsworks_nodejs (>= 0.0.0) 65 | passenger_apache2 (>= 0.0.0) 66 | php (>= 0.0.0) 67 | scm_helper (>= 0.0.0) 68 | ssh_users (>= 0.0.0) 69 | unicorn (>= 0.0.0) 70 | freebsd (0.3.0) 71 | gem_support (1.0.0) 72 | iis (2.1.6) 73 | windows (>= 1.34.6) 74 | iptables (0.14.1) 75 | logrotate (1.8.0) 76 | mod_php5_apache2 (1.0.0) 77 | apache2 (>= 0.0.0) 78 | deploy (>= 0.0.0) 79 | mysql (1.0.0) 80 | opsworks_commons (>= 0.0.0) 81 | nginx (2.7.4) 82 | apt (~> 2.2) 83 | bluepill (~> 2.3) 84 | build-essential (~> 2.0) 85 | ohai (~> 2.0) 86 | runit (~> 1.2) 87 | yum-epel (~> 0.3) 88 | ohai (2.0.1) 89 | opsworks-example-project (1.0.0) 90 | opsworks_agent_monit (1.0.0) 91 | opsworks_initial_setup (>= 0.0.0) 92 | opsworks_aws_flow_ruby (1.0.0) 93 | opsworks_bundler (1.0.0) 94 | opsworks_commons (1.0.0) 95 | dependencies (>= 0.0.0) 96 | opsworks_ganglia (1.0.0) 97 | apache2 (>= 0.0.0) 98 | opsworks_commons (>= 0.0.0) 99 | opsworks_initial_setup (>= 0.0.0) 100 | opsworks_initial_setup (1.0.0) 101 | opsworks_commons (>= 0.0.0) 102 | opsworks_java (1.0.0) 103 | apache2 (>= 0.0.0) 104 | opsworks_nodejs (1.0.0) 105 | deploy (>= 0.0.0) 106 | opsworks_commons (>= 0.0.0) 107 | opsworks_rubygems (1.0.0) 108 | opsworks_initial_setup (>= 0.0.0) 109 | packages (0.4.0) 110 | pacman (1.1.1) 111 | passenger_apache2 (2.2.3) 112 | apache2 (~> 1.0) 113 | build-essential (>= 0.0.0) 114 | php (1.5.0) 115 | build-essential (>= 0.0.0) 116 | iis (>= 0.0.0) 117 | mysql (>= 0.0.0) 118 | windows (>= 0.0.0) 119 | xml (>= 0.0.0) 120 | yum-epel (>= 0.0.0) 121 | rsyslog (1.14.0) 122 | ruby (1.0.0) 123 | opsworks_bundler (>= 0.0.0) 124 | opsworks_commons (>= 0.0.0) 125 | opsworks_initial_setup (>= 0.0.0) 126 | opsworks_rubygems (>= 0.0.0) 127 | runit (1.5.14) 128 | build-essential (>= 0.0.0) 129 | yum (~> 3.0) 130 | yum-epel (>= 0.0.0) 131 | scm_helper (1.0.0) 132 | opsworks_commons (>= 0.0.0) 133 | ssh_users (1.0.0) 134 | opsworks_commons (>= 0.0.0) 135 | opsworks_initial_setup (>= 0.0.0) 136 | unicorn (2.0.0) 137 | windows (1.36.1) 138 | chef_handler (>= 0.0.0) 139 | xml (1.2.9) 140 | build-essential (>= 0.0.0) 141 | chef-sugar (>= 0.0.0) 142 | yum (3.5.2) 143 | yum-epel (0.6.0) 144 | yum (~> 3.0) 145 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | example of running an opsworks box on your local vagrant 2 | Copyright (C) 2015 Eru Penkman 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Test your chef recipies before deploying them to opsworks 2 | 3 | So you want to use chef to provision aws opsworks like a boss? well first you'll need to test them locally. This project is an example that provisions a Vagrant VM with the default opsworks recipes and a starting point to build your own. 4 | 5 | #installation 6 | install Vagrant, Virtualbox, Vagrant-Berkshelf plugin. after installing I got 7 | 8 | 9 | Vagrant -v 10 | Vagrant 1.7.2 11 | 12 | Vagrant plugin list 13 | vagrant-berkshelf (4.0.2) 14 | vagrant-share (1.1.3, system) 15 | 16 | ruby -v 17 | ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14] 18 | 19 | This depends on the box file from this project https://github.com/wwestenbrink/vagrant-opsworks 20 | clone vagrant-opsworks seprately, it's dependencies and build the box file, I used commit `da9f341197` 21 | 22 | once finished you shouuld get this: 23 | 24 | vagrant box list 25 | 26 | ubuntu1204-opsworks (virtualbox, 0) 27 | 28 | # Running 29 | if all went well, run 30 | 31 | vagrant up --provision 32 | 33 | vagrant ssh 34 | 35 | cat /home/example-file 36 | 37 | If everything succeeded, default.rb created that file! Log in to opsworks, make sure it runs there too. Test your own recipes. Happy devop-ing! 38 | 39 | # Recommended reading 40 | I mostly followed these blog posts to get this far. 41 | 42 | http://pixelcog.com/blog/2014/virtualizing-aws-opsworks-with-vagrant/ 43 | http://dev.inventit.io/blog/aws/opsworks/vagrant/chef/berkshelf/2014/04/28/opsworks_vagrant_chef_berkshelf_tips.html 44 | http://joshsymonds.com/blog/2014/06/11/getting-started-with-aws-opsworks/ 45 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 5 | VAGRANTFILE_API_VERSION = '2' 6 | 7 | Vagrant.require_version '>= 1.5.0' 8 | 9 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 10 | # All Vagrant configuration is done here. The most common configuration 11 | # options are documented and commented below. For a complete reference, 12 | # please see the online documentation at vagrantup.com. 13 | 14 | config.vm.hostname = 'opsworks-example-project-berkshelf' 15 | 16 | 17 | # Every Vagrant virtual environment requires a box to build off of. 18 | # If this value is a shorthand to a box in Vagrant Cloud then 19 | # config.vm.box_url doesn't need to be specified. 20 | config.vm.box = 'ubuntu1204-opsworks'; 21 | 22 | 23 | # Assign this VM to a host-only network IP, allowing you to access it 24 | # via the IP. Host-only networks can talk to the host machine as well as 25 | # any other machines on the same network, but cannot be accessed (through this 26 | # network interface) by any external networks. 27 | # config.vm.network :private_network, type: 'dhcp' 28 | 29 | # Create a forwarded port mapping which allows access to a specific port 30 | # within the machine from a port on the host machine. In the example below, 31 | # accessing "localhost:8080" will access port 80 on the guest machine. 32 | 33 | # Share an additional folder to the guest VM. The first argument is 34 | # the path on the host to the actual folder. The second argument is 35 | # the path on the guest to mount the folder. And the optional third 36 | # argument is a set of non-required options. 37 | # config.vm.synced_folder "../data", "/vagrant_data" 38 | 39 | # Provider-specific configuration so you can fine-tune various 40 | # backing providers for Vagrant. These expose provider-specific options. 41 | # Example for VirtualBox: 42 | # 43 | # config.vm.provider :virtualbox do |vb| 44 | # # Don't boot with headless mode 45 | # vb.gui = true 46 | # 47 | # # Use VBoxManage to customize the VM. For example to change memory: 48 | # vb.customize ["modifyvm", :id, "--memory", "1024"] 49 | # end 50 | # 51 | # View the documentation for the provider you're using for more 52 | # information on available options. 53 | 54 | # The path to the Berksfile to use with Vagrant Berkshelf 55 | # config.berkshelf.berksfile_path = "./Berksfile" 56 | 57 | # Enabling the Berkshelf plugin. To enable this globally, add this configuration 58 | # option to your ~/.vagrant.d/Vagrantfile file 59 | config.berkshelf.enabled = true 60 | 61 | # An array of symbols representing groups of cookbook described in the Vagrantfile 62 | # to exclusively install and copy to Vagrant's shelf. 63 | # config.berkshelf.only = [] 64 | 65 | # An array of symbols representing groups of cookbook described in the Vagrantfile 66 | # to skip installing and copying to Vagrant's shelf. 67 | # config.berkshelf.except = [] 68 | 69 | config.vm.provision "shell", inline: "apt-get update > /dev/null" 70 | 71 | config.vm.provision :chef_solo do |chef| 72 | chef.roles_path = "opsworks-roles" 73 | 74 | chef.add_role "example-layer" 75 | chef.json = { 76 | :opsworks => { 77 | :ruby_stack => "ruby", 78 | :stack => { 79 | :name => "TestStack", 80 | "rds_instances"=> {} 81 | }, 82 | :layers => { 83 | "example-layer" => { 84 | "instances" => { 85 | "php-app1" => { 86 | "private-ip" => "10.10.10.10", 87 | "infrastructure_class" => "ec2" 88 | } 89 | } 90 | } 91 | }, 92 | :instance => { 93 | "infrastructure_class" => "ec2" 94 | } 95 | } 96 | } 97 | end 98 | end 99 | -------------------------------------------------------------------------------- /chefignore: -------------------------------------------------------------------------------- 1 | # Put files/directories that should be ignored in this file when uploading 2 | # or sharing to the community site. 3 | # Lines that start with '# ' are comments. 4 | 5 | # OS generated files # 6 | ###################### 7 | .DS_Store 8 | Icon? 9 | nohup.out 10 | ehthumbs.db 11 | Thumbs.db 12 | 13 | # SASS # 14 | ######## 15 | .sass-cache 16 | 17 | # EDITORS # 18 | ########### 19 | \#* 20 | .#* 21 | *~ 22 | *.sw[a-z] 23 | *.bak 24 | REVISION 25 | TAGS* 26 | tmtags 27 | *_flymake.* 28 | *_flymake 29 | *.tmproj 30 | .project 31 | .settings 32 | mkmf.log 33 | 34 | ## COMPILED ## 35 | ############## 36 | a.out 37 | *.o 38 | *.pyc 39 | *.so 40 | *.com 41 | *.class 42 | *.dll 43 | *.exe 44 | */rdoc/ 45 | 46 | # Testing # 47 | ########### 48 | .watchr 49 | .rspec 50 | spec/* 51 | spec/fixtures/* 52 | test/* 53 | features/* 54 | Guardfile 55 | Procfile 56 | 57 | # SCM # 58 | ####### 59 | .git 60 | */.git 61 | .gitignore 62 | .gitmodules 63 | .gitconfig 64 | .gitattributes 65 | .svn 66 | */.bzr/* 67 | */.hg/* 68 | */.svn/* 69 | 70 | # Berkshelf # 71 | ############# 72 | cookbooks/* 73 | tmp 74 | 75 | # Cookbooks # 76 | ############# 77 | CONTRIBUTING 78 | CHANGELOG* 79 | 80 | # Strainer # 81 | ############ 82 | Colanderfile 83 | Strainerfile 84 | .colander 85 | .strainer 86 | 87 | # Vagrant # 88 | ########### 89 | .vagrant 90 | Vagrantfile 91 | 92 | # Travis # 93 | ########## 94 | .travis.yml 95 | -------------------------------------------------------------------------------- /metadata.rb: -------------------------------------------------------------------------------- 1 | name 'opsworks-example-project' 2 | maintainer 'YOUR_NAME' 3 | maintainer_email 'YOUR_EMAIL' 4 | license 'All rights reserved' 5 | description 'Installs/Configures opsworks-example-project' 6 | long_description 'Installs/Configures opsworks-example-project' 7 | version '1.0.0' 8 | 9 | -------------------------------------------------------------------------------- /opsworks-roles/example-layer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-layer", 3 | "description": "OpsWorks recipe run-list for the app layer", 4 | "default_attributes": { 5 | 6 | }, 7 | "run_list": [ 8 | "recipe[dependencies]", 9 | "recipe[opsworks_initial_setup]", 10 | "recipe[mysql::client]", 11 | "recipe[opsworks_ganglia::client]", 12 | "recipe[opsworks_ganglia::configure-client]", 13 | "recipe[opsworks-example-project]" 14 | ], 15 | "chef_type": "role", 16 | "json_class": "Chef::Role" 17 | } -------------------------------------------------------------------------------- /recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: opsworks-example-project 3 | # Recipe:: default 4 | # Free and open source 5 | # 6 | 7 | file '/home/example-file' do 8 | content 'if you\'re reading this, something went horribly right!\n\n' 9 | end --------------------------------------------------------------------------------