added redis base
This commit is contained in:
commit
d78b715687
21
.gitignore
vendored
21
.gitignore
vendored
@ -58,4 +58,25 @@ typings/
|
|||||||
# dotenv environment variables file
|
# dotenv environment variables file
|
||||||
.env
|
.env
|
||||||
|
|
||||||
|
.vagrant
|
||||||
|
*~
|
||||||
|
*#
|
||||||
|
.#*
|
||||||
|
\#*#
|
||||||
|
.*.sw[a-z]
|
||||||
|
*.un~
|
||||||
|
|
||||||
|
# Bundler
|
||||||
|
Gemfile.lock
|
||||||
|
gems.locked
|
||||||
|
bin/*
|
||||||
|
.bundle/*
|
||||||
|
|
||||||
|
# test kitchen
|
||||||
|
.kitchen/
|
||||||
|
.kitchen.local.yml
|
||||||
|
|
||||||
|
# Chef
|
||||||
|
Berksfile.lock
|
||||||
|
.zero-knife.rb
|
||||||
|
Policyfile.lock.json
|
||||||
|
144
Vagrantfile
vendored
Normal file
144
Vagrantfile
vendored
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
require 'json'
|
||||||
|
begin
|
||||||
|
secrets = JSON.parse(File.read('secrets.json'))
|
||||||
|
puts 'Loading secrets file'
|
||||||
|
rescue
|
||||||
|
secrets = {}
|
||||||
|
puts 'Secrets file not found'
|
||||||
|
end
|
||||||
|
|
||||||
|
class ::Hash
|
||||||
|
def deep_merge(second)
|
||||||
|
second.each do |key, value|
|
||||||
|
if value.class == Hash and self[key.to_sym]
|
||||||
|
self[key.to_sym].deep_merge(value)
|
||||||
|
else
|
||||||
|
self[key.to_sym] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# -*- 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://vagrantcloud.com/search.
|
||||||
|
config.vm.box = "ubuntu/xenial64"
|
||||||
|
config.vm.synced_folder '.', '/vagrant' # The vagrant dir just stopped automounting
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
# NOTE: This will enable public access to the opened port
|
||||||
|
config.vm.network "forwarded_port", guest: 80, host: 8000
|
||||||
|
|
||||||
|
# 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|
|
||||||
|
# Customize the amount of memory on the VM:
|
||||||
|
vb.memory = '1024'
|
||||||
|
vb.default_nic_type = "virtio"
|
||||||
|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
|
||||||
|
end
|
||||||
|
#
|
||||||
|
# View the documentation for the provider you are using for more
|
||||||
|
# information on available options.
|
||||||
|
|
||||||
|
# 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
|
||||||
|
if ! apt list ruby2.5 | grep installed; then
|
||||||
|
apt-add-repository ppa:brightbox/ruby-ng -y
|
||||||
|
apt-get update
|
||||||
|
sudo apt-get install -y build-essential resolvconf ruby2.5 ruby2.5-dev gem
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! which berks >/dev/null; then
|
||||||
|
gem install berkshelf --no-ri --no-rdoc
|
||||||
|
# ln -s /opt/chef/embedded/bin/berks /usr/local/bin/berks
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd /vagrant
|
||||||
|
git submodule update --init --recursive
|
||||||
|
|
||||||
|
cd /vagrant/ops/cookbooks
|
||||||
|
rm -rf vendor
|
||||||
|
rm -rf $HOME/.berksfile
|
||||||
|
berks update
|
||||||
|
berks vendor vendor
|
||||||
|
SHELL
|
||||||
|
|
||||||
|
config.vm.provision 'chef_solo' do |chef|
|
||||||
|
chef.version = '14.12.3' # version 14.12.9 fails to run
|
||||||
|
chef.cookbooks_path = [
|
||||||
|
'ops/cookbooks/',
|
||||||
|
'ops/cookbooks/vendor/'
|
||||||
|
]
|
||||||
|
chef.roles_path ='ops/roles'
|
||||||
|
chef.add_role('common')
|
||||||
|
chef.json = {
|
||||||
|
'working-dir': '/vagrant',
|
||||||
|
'app': {
|
||||||
|
'name': 'change_me',
|
||||||
|
'domain': 'localhost',
|
||||||
|
},
|
||||||
|
# 'nodejs': {
|
||||||
|
# 'working-dir': 'node_rtc',
|
||||||
|
# 'port': '8001'
|
||||||
|
# },
|
||||||
|
# 'python': {
|
||||||
|
# 'working-dir': 'django',
|
||||||
|
# },
|
||||||
|
# 'db':{},
|
||||||
|
# 'redis':{
|
||||||
|
# 'unix': {
|
||||||
|
# 'perm': '777'
|
||||||
|
# }
|
||||||
|
# },
|
||||||
|
# 'django': {
|
||||||
|
# 'settings_path': 'project/settings',
|
||||||
|
# 'email': {
|
||||||
|
# 'host': 'smtp.gmail.com',
|
||||||
|
# 'port': '587',
|
||||||
|
# 'tls': 'True',
|
||||||
|
# },
|
||||||
|
# 'allowed_hosts': [
|
||||||
|
# '*'
|
||||||
|
# ],
|
||||||
|
# 'github': {
|
||||||
|
# 'TEST_ORG': 'ByteTesting',
|
||||||
|
# 'DISTRIBUTOR_ORG': 'ByteExercises',
|
||||||
|
# 'SOURCE_ORG': 'ByteAcademyCo'
|
||||||
|
# }
|
||||||
|
# },
|
||||||
|
# 'web':{
|
||||||
|
# 'admin_email': 'admin2342@example.com',
|
||||||
|
# 'do_ssl': false,
|
||||||
|
# 'static': [
|
||||||
|
# {'uri': '/static', 'path': 'django/staticfiles'},
|
||||||
|
# ],
|
||||||
|
# 'wsgi': {
|
||||||
|
# 'wsgi_path': 'django/project/wsgi.py',
|
||||||
|
# },
|
||||||
|
# 'socket.io': {
|
||||||
|
# 'host': 'localhost',
|
||||||
|
# 'port': '8001',
|
||||||
|
# }
|
||||||
|
# },
|
||||||
|
}.deep_merge(secrets);
|
||||||
|
end
|
||||||
|
end
|
100
docs/dev_setup.md
Normal file
100
docs/dev_setup.md
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
# Development environment setup
|
||||||
|
|
||||||
|
This project used vagrant for as standard development environment. This should
|
||||||
|
easy setting things up and reduce environment related errors.
|
||||||
|
|
||||||
|
## What you need
|
||||||
|
|
||||||
|
There are 3 things you will need to get before your local environment is up and
|
||||||
|
running.
|
||||||
|
|
||||||
|
### Git
|
||||||
|
|
||||||
|
This should already be installed on your system. If you are using Windows,
|
||||||
|
install [git bash for windows](https://git-scm.com/download/win)
|
||||||
|
|
||||||
|
### VirtualBox
|
||||||
|
|
||||||
|
Virtual box will be used to create a manged Linux VM on your computer. Please
|
||||||
|
install version 5.9 as version 6 is not supported.
|
||||||
|
|
||||||
|
### Vagrant
|
||||||
|
|
||||||
|
Vagrant is used to managed the local virtual environment and provision the VM.
|
||||||
|
**MAKE SURE GIT VIRTUAL BOX ARE INSTALLED FIRST!!!** At install time, vagrant
|
||||||
|
will integrate with them.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Once you have everything installed and the projected cloned on your local
|
||||||
|
computer, open a terminal( Git Bash for windows users ) and move to the root of
|
||||||
|
the project.
|
||||||
|
|
||||||
|
### Chef secrets
|
||||||
|
|
||||||
|
This project like many other used secret API tokens that we do want tracked in
|
||||||
|
the git repo. in the root of the project, create a file called 'secrets.json'
|
||||||
|
and populate like so:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"django": {
|
||||||
|
"github": {
|
||||||
|
"id": "<ID>",
|
||||||
|
"secret": "<SECRET>",
|
||||||
|
"token": "<TOKEN>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Basic vagrant usage and commands
|
||||||
|
|
||||||
|
We will interact with the project using vagrant. The work flow is `vagrant up`
|
||||||
|
creates a VM for your project and runs the provisioner to set everything up.
|
||||||
|
This command should be ran after the project is cloned or when you sit down to
|
||||||
|
start development. This command may take some time to complete depending on how
|
||||||
|
complex the project is. Once the VM is set up, you may now interact with it.
|
||||||
|
Vagrant will forward ports from the project to the user localhost address. For
|
||||||
|
example with this project, port 80 from the container will be mapped to
|
||||||
|
localhost:8000 and you will be able to access there. If you make a change to any
|
||||||
|
provisioning chef recipes, `vagrant provision` will need to ran. This will
|
||||||
|
run the chef provisioner on the VM making any changes needed.
|
||||||
|
|
||||||
|
Because we use the `secrets.json` file to store untracked configuration, all
|
||||||
|
vagrant command need to be ran where in the root of the project, where
|
||||||
|
`secrets.json` lives.
|
||||||
|
|
||||||
|
### `vagrant up`
|
||||||
|
|
||||||
|
Will start the local VM, creating it if needed. This command should always be
|
||||||
|
ran when a development session is started.
|
||||||
|
|
||||||
|
### `vagrant provision`
|
||||||
|
|
||||||
|
Will run the chef-solo provisioner. This will need to be ran anytime the chef
|
||||||
|
recipes or roles are changed.
|
||||||
|
|
||||||
|
### `vagrant status`
|
||||||
|
|
||||||
|
Will show you the status of local manged VM
|
||||||
|
|
||||||
|
### `vagrant halt`
|
||||||
|
|
||||||
|
Will shutdown the local VM. This should be done when you are finished working on
|
||||||
|
the project so you dont have a VM running in the background eating CPU/RAM and
|
||||||
|
battery. `vagrant up` can be used later to turn the VM back on.
|
||||||
|
|
||||||
|
### `vagrant destroy`
|
||||||
|
|
||||||
|
This will shutdown the VM and delete it. This command is useful if you have
|
||||||
|
messed up the VM and want to start from scratch. Or if you are done with the
|
||||||
|
project and want to free space from the computer.
|
||||||
|
|
||||||
|
### `vagrant ssh`
|
||||||
|
|
||||||
|
This will bring you into the local VM as the vagrant user. The vagrant user has
|
||||||
|
sudo. Use this only for debugging! **DO NOT INSTALL OR CHANGE THE STATE OF
|
||||||
|
PROJECT OR VM FROM HERE!!!!** that will break the concept of provisioning make
|
||||||
|
chef useless. Also make installation and configuration changes with chef.
|
6
ops/cookbooks/Berksfile
Normal file
6
ops/cookbooks/Berksfile
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
source 'https://supermarket.chef.io'
|
||||||
|
# cookbook 'mysql', '~> 8.5.1'
|
||||||
|
metadata
|
||||||
|
|
||||||
|
cookbook 'app', path: 'app'
|
||||||
|
cookbook 't42-common', git: 'https://git.theta42.com/theta42/t42-common.git'
|
21
ops/cookbooks/app/.delivery/build_cookbook/.kitchen.yml
Normal file
21
ops/cookbooks/app/.delivery/build_cookbook/.kitchen.yml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
driver:
|
||||||
|
name: vagrant
|
||||||
|
synced_folders:
|
||||||
|
- [<%= File.join(ENV['PWD'], '..', '..')%>, '/tmp/repo-data']
|
||||||
|
|
||||||
|
provisioner:
|
||||||
|
name: chef_zero
|
||||||
|
encrypted_data_bag_secret_key_path: 'secrets/fakey-mcfakerton'
|
||||||
|
data_bags_path: './data_bags'
|
||||||
|
product_name: chefdk
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: ubuntu-16.04
|
||||||
|
- name: centos-7
|
||||||
|
|
||||||
|
suites:
|
||||||
|
- name: default
|
||||||
|
run_list:
|
||||||
|
- recipe[test]
|
||||||
|
attributes:
|
7
ops/cookbooks/app/.delivery/build_cookbook/Berksfile
Normal file
7
ops/cookbooks/app/.delivery/build_cookbook/Berksfile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
source 'https://supermarket.chef.io'
|
||||||
|
|
||||||
|
metadata
|
||||||
|
|
||||||
|
group :delivery do
|
||||||
|
cookbook 'test', path: './test/fixtures/cookbooks/test'
|
||||||
|
end
|
3
ops/cookbooks/app/.delivery/build_cookbook/LICENSE
Normal file
3
ops/cookbooks/app/.delivery/build_cookbook/LICENSE
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Copyright 2019 The Authors
|
||||||
|
|
||||||
|
All rights reserved, do not redistribute.
|
146
ops/cookbooks/app/.delivery/build_cookbook/README.md
Normal file
146
ops/cookbooks/app/.delivery/build_cookbook/README.md
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
# build_cookbook
|
||||||
|
|
||||||
|
A build cookbook for running the parent project through Chef Delivery
|
||||||
|
|
||||||
|
This build cookbook should be customized to suit the needs of the parent project. Using this cookbook can be done outside of Chef Delivery, too. If the parent project is a Chef cookbook, we've detected that and "wrapped" [delivery-truck](https://github.com/chef-cookbooks/delivery-truck). That means it is a dependency, and each of its pipeline phase recipes is included in the appropriate phase recipes in this cookbook. If the parent project is not a cookbook, it's left as an exercise to the reader to customize the recipes as needed for each phase in the pipeline.
|
||||||
|
|
||||||
|
## .delivery/config.json
|
||||||
|
|
||||||
|
In the parent directory to this build_cookbook, the `config.json` can be modified as necessary. For example, phases can be skipped, publishing information can be added, and so on. Refer to customer support or the Chef Delivery documentation for assistance on what options are available for this configuration.
|
||||||
|
|
||||||
|
## Test Kitchen - Local Verify Testing
|
||||||
|
|
||||||
|
This cookbook also has a `.kitchen.yml` which can be used to create local build nodes with Test Kitchen to perform the verification phases, `unit`, `syntax`, and `lint`. When running `kitchen converge`, the instances will be set up like Chef Delivery "build nodes" with the [delivery_build cookbook](https://github.com/chef-cookbooks/delivery_build). The reason for this is to make sure that the same exact kind of nodes are used by this build cookbook are run on the local workstation as would run Delivery. It will run `delivery job verify PHASE` for the parent project.
|
||||||
|
|
||||||
|
Modify the `.kitchen.yml` if necessary to change the platforms or other configuration to run the verify phases. After making changes in the parent project, `cd` into this directory (`.delivery/build_cookbook`), and run:
|
||||||
|
|
||||||
|
```
|
||||||
|
kitchen test
|
||||||
|
```
|
||||||
|
|
||||||
|
## Recipes
|
||||||
|
|
||||||
|
Each of the recipes in this build_cookbook are run in the named phase during the Chef Delivery pipeline. The `unit`, `syntax`, and `lint` recipes are additionally run when using Test Kitchen for local testing as noted in the above section.
|
||||||
|
|
||||||
|
## Making Changes - Cookbook Example
|
||||||
|
|
||||||
|
When making changes in the parent project (that which lives in `../..` from this directory), or in the recipes in this build cookbook, there is a bespoke workflow for Chef Delivery. As an example, we'll discuss a Chef Cookbook as the parent.
|
||||||
|
|
||||||
|
First, create a new branch for the changes.
|
||||||
|
|
||||||
|
```
|
||||||
|
git checkout -b testing-build-cookbook
|
||||||
|
```
|
||||||
|
|
||||||
|
Next, increment the version in the metadata.rb. This should be in the _parent_, not in this, the build_cookbook. If this is not done, the verify phase will fail.
|
||||||
|
|
||||||
|
```
|
||||||
|
% git diff
|
||||||
|
<SNIP>
|
||||||
|
-version '0.1.0'
|
||||||
|
+version '0.1.1'
|
||||||
|
```
|
||||||
|
|
||||||
|
The change we'll use for an example is to install the `zsh` package. Write a failing ChefSpec in the cookbook project's `spec/unit/recipes/default_spec.rb`.
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'godzilla::default' do
|
||||||
|
context 'When all attributes are default, on Ubuntu 16.04' do
|
||||||
|
let(:chef_run) do
|
||||||
|
runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04')
|
||||||
|
runner.converge(described_recipe)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'installs zsh' do
|
||||||
|
expect(chef_run).to install_package('zsh')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
Commit the local changes as work in progress. The `delivery job` expects to use a clean git repository.
|
||||||
|
|
||||||
|
```
|
||||||
|
git add ../..
|
||||||
|
git commit -m 'WIP: Testing changes'
|
||||||
|
```
|
||||||
|
|
||||||
|
From _this_ directory (`.delivery/build_cookbook`, relative to the parent cookbook project), run
|
||||||
|
|
||||||
|
```
|
||||||
|
cd .delivery/build_cookbook
|
||||||
|
kitchen converge
|
||||||
|
```
|
||||||
|
|
||||||
|
This will take some time at first, because the VMs need to be created, Chef installed, the Delivery CLI installed, etc. Later runs will be faster until they are destroyed. It will also fail on the first VM, as expected, because we wrote the test first. Now edit the parent cookbook project's default recipe to install `zsh`.
|
||||||
|
|
||||||
|
```
|
||||||
|
cd ../../
|
||||||
|
$EDITOR/recipes/default.rb
|
||||||
|
```
|
||||||
|
|
||||||
|
It should look like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
package 'zsh'
|
||||||
|
```
|
||||||
|
|
||||||
|
Create another commit.
|
||||||
|
|
||||||
|
```
|
||||||
|
git add .
|
||||||
|
git commit -m 'WIP: Install zsh in default recipe'
|
||||||
|
```
|
||||||
|
|
||||||
|
Now rerun kitchen from the build_cookbook.
|
||||||
|
|
||||||
|
```
|
||||||
|
cd .delivery/build_cookbook
|
||||||
|
kitchen converge
|
||||||
|
```
|
||||||
|
|
||||||
|
This will take awhile because it will now pass on the first VM, and then create the second VM. We should have warned you this was a good time for a coffee break.
|
||||||
|
|
||||||
|
```
|
||||||
|
Recipe: test::default
|
||||||
|
|
||||||
|
- execute HOME=/home/vagrant delivery job verify unit --server localhost --ent test --org kitchen
|
||||||
|
* execute[HOME=/home/vagrant delivery job verify lint --server localhost --ent test --org kitchen] action run
|
||||||
|
- execute HOME=/home/vagrant delivery job verify lint --server localhost --ent test --org kitchen
|
||||||
|
|
||||||
|
- execute HOME=/home/vagrant delivery job verify syntax --server localhost --ent test --org kitchen
|
||||||
|
|
||||||
|
Running handlers:
|
||||||
|
Running handlers complete
|
||||||
|
Chef Client finished, 3/32 resources updated in 54.665445968 seconds
|
||||||
|
Finished converging <default-centos-71> (1m26.83s).
|
||||||
|
```
|
||||||
|
|
||||||
|
Victory is ours! Our verify phase passed on the build nodes.
|
||||||
|
|
||||||
|
We are ready to run this through our Delivery pipeline. Simply run `delivery review` on the local system from the parent project, and it will open a browser window up to the change we just added.
|
||||||
|
|
||||||
|
```
|
||||||
|
cd ../..
|
||||||
|
delivery review
|
||||||
|
```
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
### Why don't I just run rspec and foodcritic/rubocop on my local system?
|
||||||
|
|
||||||
|
An objection to the Test Kitchen approach is that it is much faster to run the unit, lint, and syntax commands for the project on the local system. That is totally true, and also totally valid. Do that for the really fast feedback loop. However, the dance we do with Test Kitchen brings a much higher degree of confidence in the changes we're making, that everything will run on the build nodes in Chef Delivery. We strongly encourage this approach before actually pushing the changes to Delivery.
|
||||||
|
|
||||||
|
### Why do I have to make a commit every time?
|
||||||
|
|
||||||
|
When running `delivery job`, it expects to merge the commit for the changeset against the clean master branch. If we don't save our progress by making a commit, our local changes aren't run through `delivery job` in the Test Kitchen build instances. We can always perform an interactive rebase, and modify the original changeset message in Delivery with `delivery review --edit`. The latter won't modify the git commits, only the changeset in Delivery.
|
||||||
|
|
||||||
|
### What do I do next?
|
||||||
|
|
||||||
|
Make changes in the cookbook project as required for organizational goals and needs. Modify the `build_cookbook` as necessary for the pipeline phases that the cookbook should go through.
|
||||||
|
|
||||||
|
### What if I get stuck?
|
||||||
|
|
||||||
|
Contact Chef Support, or your Chef Customer Success team and they will help you get unstuck.
|
104
ops/cookbooks/app/.delivery/build_cookbook/chefignore
Normal file
104
ops/cookbooks/app/.delivery/build_cookbook/chefignore
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
# Put files/directories that should be ignored in this file when uploading
|
||||||
|
# to a chef-server or supermarket.
|
||||||
|
# Lines that start with '# ' are comments.
|
||||||
|
|
||||||
|
# OS generated files #
|
||||||
|
######################
|
||||||
|
.DS_Store
|
||||||
|
Icon?
|
||||||
|
nohup.out
|
||||||
|
ehthumbs.db
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# SASS #
|
||||||
|
########
|
||||||
|
.sass-cache
|
||||||
|
|
||||||
|
# EDITORS #
|
||||||
|
###########
|
||||||
|
\#*
|
||||||
|
.#*
|
||||||
|
*~
|
||||||
|
*.sw[a-z]
|
||||||
|
*.bak
|
||||||
|
REVISION
|
||||||
|
TAGS*
|
||||||
|
tmtags
|
||||||
|
*_flymake.*
|
||||||
|
*_flymake
|
||||||
|
*.tmproj
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
mkmf.log
|
||||||
|
|
||||||
|
## COMPILED ##
|
||||||
|
##############
|
||||||
|
a.out
|
||||||
|
*.o
|
||||||
|
*.pyc
|
||||||
|
*.so
|
||||||
|
*.com
|
||||||
|
*.class
|
||||||
|
*.dll
|
||||||
|
*.exe
|
||||||
|
*/rdoc/
|
||||||
|
|
||||||
|
# Testing #
|
||||||
|
###########
|
||||||
|
.watchr
|
||||||
|
.rspec
|
||||||
|
spec/*
|
||||||
|
spec/fixtures/*
|
||||||
|
test/*
|
||||||
|
features/*
|
||||||
|
examples/*
|
||||||
|
Guardfile
|
||||||
|
Procfile
|
||||||
|
.kitchen*
|
||||||
|
kitchen.yml*
|
||||||
|
.rubocop.yml
|
||||||
|
spec/*
|
||||||
|
Rakefile
|
||||||
|
.travis.yml
|
||||||
|
.foodcritic
|
||||||
|
.codeclimate.yml
|
||||||
|
|
||||||
|
# SCM #
|
||||||
|
#######
|
||||||
|
.git
|
||||||
|
*/.git
|
||||||
|
.gitignore
|
||||||
|
.gitmodules
|
||||||
|
.gitconfig
|
||||||
|
.gitattributes
|
||||||
|
.svn
|
||||||
|
*/.bzr/*
|
||||||
|
*/.hg/*
|
||||||
|
*/.svn/*
|
||||||
|
|
||||||
|
# Berkshelf #
|
||||||
|
#############
|
||||||
|
Berksfile
|
||||||
|
Berksfile.lock
|
||||||
|
cookbooks/*
|
||||||
|
tmp
|
||||||
|
|
||||||
|
# Bundler #
|
||||||
|
###########
|
||||||
|
vendor/*
|
||||||
|
|
||||||
|
# Policyfile #
|
||||||
|
##############
|
||||||
|
Policyfile.rb
|
||||||
|
Policyfile.lock.json
|
||||||
|
|
||||||
|
# Cookbooks #
|
||||||
|
#############
|
||||||
|
CONTRIBUTING*
|
||||||
|
CHANGELOG*
|
||||||
|
TESTING*
|
||||||
|
|
||||||
|
# Vagrant #
|
||||||
|
###########
|
||||||
|
.vagrant
|
||||||
|
Vagrantfile
|
@ -0,0 +1 @@
|
|||||||
|
{"id": "delivery_builder_keys"}
|
8
ops/cookbooks/app/.delivery/build_cookbook/metadata.rb
Normal file
8
ops/cookbooks/app/.delivery/build_cookbook/metadata.rb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
name 'build_cookbook'
|
||||||
|
maintainer 'The Authors'
|
||||||
|
maintainer_email 'you@example.com'
|
||||||
|
license 'all_rights'
|
||||||
|
version '0.1.0'
|
||||||
|
chef_version '>= 13.0'
|
||||||
|
|
||||||
|
depends 'delivery-truck'
|
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# Cookbook:: build_cookbook
|
||||||
|
# Recipe:: default
|
||||||
|
#
|
||||||
|
# Copyright:: 2019, The Authors, All Rights Reserved.
|
||||||
|
include_recipe 'delivery-truck::default'
|
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# Cookbook:: build_cookbook
|
||||||
|
# Recipe:: deploy
|
||||||
|
#
|
||||||
|
# Copyright:: 2019, The Authors, All Rights Reserved.
|
||||||
|
include_recipe 'delivery-truck::deploy'
|
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# Cookbook:: build_cookbook
|
||||||
|
# Recipe:: functional
|
||||||
|
#
|
||||||
|
# Copyright:: 2019, The Authors, All Rights Reserved.
|
||||||
|
include_recipe 'delivery-truck::functional'
|
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# Cookbook:: build_cookbook
|
||||||
|
# Recipe:: lint
|
||||||
|
#
|
||||||
|
# Copyright:: 2019, The Authors, All Rights Reserved.
|
||||||
|
include_recipe 'delivery-truck::lint'
|
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# Cookbook:: build_cookbook
|
||||||
|
# Recipe:: provision
|
||||||
|
#
|
||||||
|
# Copyright:: 2019, The Authors, All Rights Reserved.
|
||||||
|
include_recipe 'delivery-truck::provision'
|
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# Cookbook:: build_cookbook
|
||||||
|
# Recipe:: publish
|
||||||
|
#
|
||||||
|
# Copyright:: 2019, The Authors, All Rights Reserved.
|
||||||
|
include_recipe 'delivery-truck::publish'
|
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# Cookbook:: build_cookbook
|
||||||
|
# Recipe:: quality
|
||||||
|
#
|
||||||
|
# Copyright:: 2019, The Authors, All Rights Reserved.
|
||||||
|
include_recipe 'delivery-truck::quality'
|
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# Cookbook:: build_cookbook
|
||||||
|
# Recipe:: security
|
||||||
|
#
|
||||||
|
# Copyright:: 2019, The Authors, All Rights Reserved.
|
||||||
|
include_recipe 'delivery-truck::security'
|
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# Cookbook:: build_cookbook
|
||||||
|
# Recipe:: smoke
|
||||||
|
#
|
||||||
|
# Copyright:: 2019, The Authors, All Rights Reserved.
|
||||||
|
include_recipe 'delivery-truck::smoke'
|
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# Cookbook:: build_cookbook
|
||||||
|
# Recipe:: syntax
|
||||||
|
#
|
||||||
|
# Copyright:: 2019, The Authors, All Rights Reserved.
|
||||||
|
include_recipe 'delivery-truck::syntax'
|
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# Cookbook:: build_cookbook
|
||||||
|
# Recipe:: unit
|
||||||
|
#
|
||||||
|
# Copyright:: 2019, The Authors, All Rights Reserved.
|
||||||
|
include_recipe 'delivery-truck::unit'
|
2
ops/cookbooks/app/.delivery/build_cookbook/test/fixtures/cookbooks/test/metadata.rb
vendored
Normal file
2
ops/cookbooks/app/.delivery/build_cookbook/test/fixtures/cookbooks/test/metadata.rb
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
name 'test'
|
||||||
|
version '0.1.0'
|
9
ops/cookbooks/app/.delivery/build_cookbook/test/fixtures/cookbooks/test/recipes/default.rb
vendored
Normal file
9
ops/cookbooks/app/.delivery/build_cookbook/test/fixtures/cookbooks/test/recipes/default.rb
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
%w(unit lint syntax).each do |phase|
|
||||||
|
# TODO: This works on Linux/Unix. Not Windows.
|
||||||
|
execute "HOME=/home/vagrant delivery job verify #{phase} --server localhost --ent test --org kitchen" do
|
||||||
|
cwd '/tmp/repo-data'
|
||||||
|
user 'vagrant'
|
||||||
|
environment('GIT_DISCOVERY_ACROSS_FILESYSTEM' => '1')
|
||||||
|
end
|
||||||
|
end
|
17
ops/cookbooks/app/.delivery/config.json
Normal file
17
ops/cookbooks/app/.delivery/config.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"version": "2",
|
||||||
|
"build_cookbook": {
|
||||||
|
"name": "build_cookbook",
|
||||||
|
"path": ".delivery/build_cookbook"
|
||||||
|
},
|
||||||
|
"delivery-truck": {
|
||||||
|
"lint": {
|
||||||
|
"enable_cookstyle": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"skip_phases": [],
|
||||||
|
"job_dispatch": {
|
||||||
|
"version": "v2"
|
||||||
|
},
|
||||||
|
"dependencies": []
|
||||||
|
}
|
36
ops/cookbooks/app/.delivery/project.toml
Normal file
36
ops/cookbooks/app/.delivery/project.toml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# Delivery Prototype for Local Phases Execution
|
||||||
|
#
|
||||||
|
# The purpose of this file is to prototype a new way to execute
|
||||||
|
# phases locally on your workstation. The delivery-cli will read
|
||||||
|
# this file and execute the command(s) that are configured for
|
||||||
|
# each phase. You can customize them by just modifying the phase
|
||||||
|
# key on this file.
|
||||||
|
#
|
||||||
|
# By default these phases are configured for Cookbook Workflow only
|
||||||
|
#
|
||||||
|
# As this is still a prototype we are not modifying the current
|
||||||
|
# config.json file and it will continue working as usual.
|
||||||
|
|
||||||
|
[local_phases]
|
||||||
|
unit = "chef exec rspec spec/"
|
||||||
|
lint = "chef exec cookstyle"
|
||||||
|
# Foodcritic includes rules only appropriate for community cookbooks
|
||||||
|
# uploaded to Supermarket. We turn off any rules tagged "supermarket"
|
||||||
|
# by default. If you plan to share this cookbook you should remove
|
||||||
|
# '-t ~supermarket' below to enable supermarket rules.
|
||||||
|
syntax = "chef exec foodcritic . -t ~supermarket"
|
||||||
|
provision = "chef exec kitchen create"
|
||||||
|
deploy = "chef exec kitchen converge"
|
||||||
|
smoke = "chef exec kitchen verify"
|
||||||
|
# The functional phase is optional, you can define it by uncommenting
|
||||||
|
# the line below and running the command: `delivery local functional`
|
||||||
|
# functional = ""
|
||||||
|
cleanup = "chef exec kitchen destroy"
|
||||||
|
|
||||||
|
# Remote project.toml file
|
||||||
|
#
|
||||||
|
# Specify a remote URI location for the `project.toml` file.
|
||||||
|
# This is useful for teams that wish to centrally manage the behavior
|
||||||
|
# of the `delivery local` command across many different projects.
|
||||||
|
#
|
||||||
|
# remote_file = "https://url/project.toml"
|
22
ops/cookbooks/app/.gitignore
vendored
Normal file
22
ops/cookbooks/app/.gitignore
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
.vagrant
|
||||||
|
*~
|
||||||
|
*#
|
||||||
|
.#*
|
||||||
|
\#*#
|
||||||
|
.*.sw[a-z]
|
||||||
|
*.un~
|
||||||
|
|
||||||
|
# Bundler
|
||||||
|
Gemfile.lock
|
||||||
|
gems.locked
|
||||||
|
bin/*
|
||||||
|
.bundle/*
|
||||||
|
|
||||||
|
# test kitchen
|
||||||
|
.kitchen/
|
||||||
|
.kitchen.local.yml
|
||||||
|
|
||||||
|
# Chef
|
||||||
|
Berksfile.lock
|
||||||
|
.zero-knife.rb
|
||||||
|
Policyfile.lock.json
|
26
ops/cookbooks/app/.kitchen.yml
Normal file
26
ops/cookbooks/app/.kitchen.yml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
driver:
|
||||||
|
name: vagrant
|
||||||
|
|
||||||
|
provisioner:
|
||||||
|
name: chef_zero
|
||||||
|
# You may wish to disable always updating cookbooks in CI or other testing environments.
|
||||||
|
# For example:
|
||||||
|
# always_update_cookbooks: <%= !ENV['CI'] %>
|
||||||
|
always_update_cookbooks: true
|
||||||
|
|
||||||
|
verifier:
|
||||||
|
name: inspec
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: ubuntu-16.04
|
||||||
|
- name: centos-7
|
||||||
|
|
||||||
|
suites:
|
||||||
|
- name: default
|
||||||
|
run_list:
|
||||||
|
- recipe[django-bakend::default]
|
||||||
|
verifier:
|
||||||
|
inspec_tests:
|
||||||
|
- test/integration/default
|
||||||
|
attributes:
|
5
ops/cookbooks/app/Berksfile
Normal file
5
ops/cookbooks/app/Berksfile
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
source 'https://supermarket.chef.io'
|
||||||
|
# cookbook 'mysql', '~> 8.5.1'
|
||||||
|
cookbook "library-cookbook", "~> 0.1.1", git: "https://github.com/example/library-cookbook.git"
|
||||||
|
metadata
|
11
ops/cookbooks/app/CHANGELOG.md
Normal file
11
ops/cookbooks/app/CHANGELOG.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# django-bakend CHANGELOG
|
||||||
|
|
||||||
|
This file is used to list changes made in each version of the django-bakend cookbook.
|
||||||
|
|
||||||
|
# 0.1.0
|
||||||
|
|
||||||
|
Initial release.
|
||||||
|
|
||||||
|
- change 0
|
||||||
|
- change 1
|
||||||
|
|
3
ops/cookbooks/app/LICENSE
Normal file
3
ops/cookbooks/app/LICENSE
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Copyright 2019 The Authors
|
||||||
|
|
||||||
|
All rights reserved, do not redistribute.
|
4
ops/cookbooks/app/README.md
Normal file
4
ops/cookbooks/app/README.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# django-backend
|
||||||
|
|
||||||
|
TODO: Enter the cookbook description here.
|
||||||
|
|
104
ops/cookbooks/app/chefignore
Normal file
104
ops/cookbooks/app/chefignore
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
# Put files/directories that should be ignored in this file when uploading
|
||||||
|
# to a chef-server or supermarket.
|
||||||
|
# Lines that start with '# ' are comments.
|
||||||
|
|
||||||
|
# OS generated files #
|
||||||
|
######################
|
||||||
|
.DS_Store
|
||||||
|
Icon?
|
||||||
|
nohup.out
|
||||||
|
ehthumbs.db
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# SASS #
|
||||||
|
########
|
||||||
|
.sass-cache
|
||||||
|
|
||||||
|
# EDITORS #
|
||||||
|
###########
|
||||||
|
\#*
|
||||||
|
.#*
|
||||||
|
*~
|
||||||
|
*.sw[a-z]
|
||||||
|
*.bak
|
||||||
|
REVISION
|
||||||
|
TAGS*
|
||||||
|
tmtags
|
||||||
|
*_flymake.*
|
||||||
|
*_flymake
|
||||||
|
*.tmproj
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
mkmf.log
|
||||||
|
|
||||||
|
## COMPILED ##
|
||||||
|
##############
|
||||||
|
a.out
|
||||||
|
*.o
|
||||||
|
*.pyc
|
||||||
|
*.so
|
||||||
|
*.com
|
||||||
|
*.class
|
||||||
|
*.dll
|
||||||
|
*.exe
|
||||||
|
*/rdoc/
|
||||||
|
|
||||||
|
# Testing #
|
||||||
|
###########
|
||||||
|
.watchr
|
||||||
|
.rspec
|
||||||
|
spec/*
|
||||||
|
spec/fixtures/*
|
||||||
|
test/*
|
||||||
|
features/*
|
||||||
|
examples/*
|
||||||
|
Guardfile
|
||||||
|
Procfile
|
||||||
|
.kitchen*
|
||||||
|
kitchen.yml*
|
||||||
|
.rubocop.yml
|
||||||
|
spec/*
|
||||||
|
Rakefile
|
||||||
|
.travis.yml
|
||||||
|
.foodcritic
|
||||||
|
.codeclimate.yml
|
||||||
|
|
||||||
|
# SCM #
|
||||||
|
#######
|
||||||
|
.git
|
||||||
|
*/.git
|
||||||
|
.gitignore
|
||||||
|
.gitmodules
|
||||||
|
.gitconfig
|
||||||
|
.gitattributes
|
||||||
|
.svn
|
||||||
|
*/.bzr/*
|
||||||
|
*/.hg/*
|
||||||
|
*/.svn/*
|
||||||
|
|
||||||
|
# Berkshelf #
|
||||||
|
#############
|
||||||
|
Berksfile
|
||||||
|
Berksfile.lock
|
||||||
|
cookbooks/*
|
||||||
|
tmp
|
||||||
|
|
||||||
|
# Bundler #
|
||||||
|
###########
|
||||||
|
vendor/*
|
||||||
|
|
||||||
|
# Policyfile #
|
||||||
|
##############
|
||||||
|
Policyfile.rb
|
||||||
|
Policyfile.lock.json
|
||||||
|
|
||||||
|
# Cookbooks #
|
||||||
|
#############
|
||||||
|
CONTRIBUTING*
|
||||||
|
CHANGELOG*
|
||||||
|
TESTING*
|
||||||
|
|
||||||
|
# Vagrant #
|
||||||
|
###########
|
||||||
|
.vagrant
|
||||||
|
Vagrantfile
|
22
ops/cookbooks/app/metadata.rb
Normal file
22
ops/cookbooks/app/metadata.rb
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
name 'app'
|
||||||
|
maintainer 'The Authors'
|
||||||
|
maintainer_email 'you@example.com'
|
||||||
|
license 'All Rights Reserved'
|
||||||
|
description 'Installs/Configures django-backend'
|
||||||
|
long_description 'Installs/Configures django-backend'
|
||||||
|
version '0.1.0'
|
||||||
|
chef_version '>= 13.0'
|
||||||
|
|
||||||
|
depends 't42-common'
|
||||||
|
|
||||||
|
# The `issues_url` points to the location where issues for this cookbook are
|
||||||
|
# tracked. A `View Issues` link will be displayed on this cookbook's page when
|
||||||
|
# uploaded to a Supermarket.
|
||||||
|
#
|
||||||
|
# issues_url 'https://github.com/<insert_org_here>/django-backend/issues'
|
||||||
|
|
||||||
|
# The `source_url` points to the development repository for this cookbook. A
|
||||||
|
# `View Source` link will be displayed on this cookbook's page when uploaded to
|
||||||
|
# a Supermarket.
|
||||||
|
#
|
||||||
|
# source_url 'https://github.com/<insert_org_here>/django-backend'
|
0
ops/cookbooks/app/recipes/default.rb
Normal file
0
ops/cookbooks/app/recipes/default.rb
Normal file
3
ops/cookbooks/app/spec/spec_helper.rb
Normal file
3
ops/cookbooks/app/spec/spec_helper.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
require 'chefspec'
|
||||||
|
require 'chefspec/berkshelf'
|
35
ops/cookbooks/app/spec/unit/recipes/default_spec.rb
Normal file
35
ops/cookbooks/app/spec/unit/recipes/default_spec.rb
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#
|
||||||
|
# Cookbook:: app
|
||||||
|
# Spec:: default
|
||||||
|
#
|
||||||
|
# Copyright:: 2019, The Authors, All Rights Reserved.
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'app::default' do
|
||||||
|
context 'When all attributes are default, on Ubuntu 16.04' do
|
||||||
|
let(:chef_run) do
|
||||||
|
# for a complete list of available platforms and versions see:
|
||||||
|
# https://github.com/customink/fauxhai/blob/master/PLATFORMS.md
|
||||||
|
runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04')
|
||||||
|
runner.converge(described_recipe)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'converges successfully' do
|
||||||
|
expect { chef_run }.to_not raise_error
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'When all attributes are default, on CentOS 7.4.1708' do
|
||||||
|
let(:chef_run) do
|
||||||
|
# for a complete list of available platforms and versions see:
|
||||||
|
# https://github.com/customink/fauxhai/blob/master/PLATFORMS.md
|
||||||
|
runner = ChefSpec::ServerRunner.new(platform: 'centos', version: '7.4.1708')
|
||||||
|
runner.converge(described_recipe)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'converges successfully' do
|
||||||
|
expect { chef_run }.to_not raise_error
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
16
ops/cookbooks/app/test/integration/default/default_test.rb
Normal file
16
ops/cookbooks/app/test/integration/default/default_test.rb
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# InSpec test for recipe django-bakend::default
|
||||||
|
|
||||||
|
# The InSpec reference, with examples and extensive documentation, can be
|
||||||
|
# found at http://inspec.io/docs/reference/resources/
|
||||||
|
|
||||||
|
unless os.windows?
|
||||||
|
# This is an example test, replace with your own test.
|
||||||
|
describe user('root'), :skip do
|
||||||
|
it { should exist }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# This is an example test, replace it with your own test.
|
||||||
|
describe port(80), :skip do
|
||||||
|
it { should_not be_listening }
|
||||||
|
end
|
3
ops/cookbooks/metadata.rb
Normal file
3
ops/cookbooks/metadata.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name 'change-me'
|
||||||
|
|
||||||
|
depnds 'app'
|
13
ops/roles/common.rb
Normal file
13
ops/roles/common.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
name :common
|
||||||
|
description "A basic role"
|
||||||
|
|
||||||
|
run_list(
|
||||||
|
# "recipe[t42-common::postgres]",
|
||||||
|
# "recipe[t42-common::redis]",
|
||||||
|
# "recipe[t42-common::nodejs]",
|
||||||
|
# "recipe[t42-common::python]",
|
||||||
|
"recipe[t42-common::apache]",
|
||||||
|
# "recipe[t42-common::openresty]",
|
||||||
|
"recipe[t42-common::php]",
|
||||||
|
"recipe[t42-common::mysql]",
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user