These puppet manifests are intended to be a starting point for using Ruby, with PostgreSQL, Nginx, and Redis.
Some of my projects no longer seem to fit neatly into the Heroku's offerings, so I decided to migrate them to VPS services like Linode, Digital Ocean or others that offer SSH access. This saves on cost and increases control of deployment.
Clearly, as applications grow this will certainly need to be customized, but for new projects this should hopefully prevent you from having to reinvent the wheel. My goal with this is to make it easy to host one or more rails applications on the same server while minimizing lock-in to a given provider, while refactoring sensitive information so that it can easily stay outside of source control.
This project should also help with setting up Vagrant for development, which will alleviate the problems that arise from collaborators using different development environments.
If you've ever heard someone say, "your code doesn't work on my computer," then you know what I'm talking about.
- Install Virtual Box
- Install Vagrant using the installer. Previously you could install it as a rubygem, but that behavior has since been deprecated. Go to the website. This was built with version 1.8.5.
$> brew cask install virtualbox vagrant- Clone this repository with
git clone git@github.com:cyrusstoller/gardenbed.git cdinto the cloned repository- Double check that you have
bundlerinstalled - Run the following command
$> scripts/bootstrap.sh development- Warning During this initial provisioning your CPU will be very busy. Close any unnecessary applications. Web browsers especially. This process will take a while. Don't worry about some error messages on during this initial run. Just let it keep going until you have your command prompt back. Go get some coffee and come back in a half hour.
- Everything in this the
gardenbeddirectory will be accessible from your virtual machine at/vagrant. In other words your files will be both on your virtual machine and on your host machine, meaning you can continue to use your favorite text editor and maintain a similar workflow without having to worry about system dependencies. - SSH into your machine with:
$> vagrant ssh- Then go to your project directory in
/vagrantandbundle installandbundle exec rails sorbundle exec foreman startand you should be good to go. - Your website should be viewable at
http://localhost:3000orhttp://localhost:5000depending on how your application is configured. - If you want to add additional packages from
aptconfigurehiera/common.yamlwhich was created during the bootstrap process. Thehiera/common.yamlis used for setting up sensitive information that is unique to each system that is being setup. For more instructions on this read see the configuration section.
- rbenv with ruby v2.3.0 installed
- postgresql version 9.6+ with role/username
vagrantwith passwordfoobarand encodingUTF8and localeen_US.UTF-8. - nodejs needed for the asset pipeline
- redis
- Install Virtual Box
- Install Vagrant using the installer. Previously you could install it as a rubygem, but that behavior has since been deprecated. Go to the website. This was built with version 1.8.5.
- Clone this repository with
git clone git@github.com:cyrusstoller/gardenbed.git cdinto the cloned repositorycp hiera/common.yaml.example hiera/common.yaml- Go to
https://github.com/<<GITHUB_USERNAME>>.keysand copy your SSH key into the last line of yourhiera/common.yaml - Double check that you have
bundlerinstalled - Run the following command
$> scripts/bootstrap.sh staging- This configures a
deployeruser that has you can SSH into using:
$> ssh deployer@192.168.33.11- a firewall as recommended by https://library.linode.com/securing-your-server#sph_creating-a-firewall
- an ssh key for the
deployeruser, which is ideal for practicing deployment with a tool like Capistrano - after deploying to this machine you will be able to view
http://192.168.33.11on port 80 - rbenv with ruby v2.3.0 installed
- postgresql version 9.6+ with role/username
deployerwith passwordfoobarand encodingUTF8and localeen_US.UTF-8. This will also perform acronjob for daily backups. - nodejs needed for the asset pipeline
- nginx for serving static assets
- fail2ban
- redis
The hiera/common.yaml makes it really easy to provision more system users, create more roles and databases for postgresql,
and install more rubies. See below for more details.
If you've never used Vagrant before, go check out: http://docs.vagrantup.com/v2/
Here's an old Railscasts episode that explains many of the steps that this project is helping you bypass.
If you are interested in using a non-debian-based box, I suggest checking out: http://www.vagrantbox.es/
See configuration.md
If you want to make modifications to the modules, be sure to do so in the private_modules directory.
The modules directory that is used during puppet apply is overwritten each time you run
librarian-puppet update. Speaking of which, to use a change you make in the private_modules directory you
need to run librarian-puppet update before you run vagrant provision.
If you find a bug or something that could improve the user experience, please file an issue on this github project.
Even if you plan on filing a patch for the issue yourself it'd be great if you could still file an issue so that we don't have people duplicating work unnecessarily.
- Fork this project
- Make a feature branch
git checkout -b feature - Make your changes and commit them to your feature branch
- Submit a pull request