Merge branch 'master' into feature/ubuntu-16.04
This commit is contained in:
commit
5385813eda
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
||||
/.chef/encrypted_data_bag_secret
|
||||
/.bundle/
|
||||
/.vagrant/
|
||||
/nodes/vagrant-node.json
|
||||
|
35
Batali
35
Batali
@ -10,33 +10,30 @@ Batali.define do
|
||||
git: 'https://github.com/67P/wordpress-cookbook.git',
|
||||
ref: 'relax_dependencies'
|
||||
cookbook 'postfix'
|
||||
cookbook 'unattended-upgrades'
|
||||
cookbook 'application_nodejs',
|
||||
git: 'https://github.com/67p/application_nodejs.git',
|
||||
ref: 'master'
|
||||
cookbook 'php-fpm', '0.7.8'
|
||||
cookbook 'application', '4.1.6'
|
||||
cookbook 'php', '~> 3.0.0'
|
||||
cookbook 'users'
|
||||
cookbook 'sudo'
|
||||
cookbook 'poise-ruby-build', '~> 1.1.0'
|
||||
cookbook 'application', '~> 5.2.0'
|
||||
cookbook 'application_javascript'
|
||||
cookbook 'application_ruby', '~> 4.1.0'
|
||||
cookbook 'application_git', '~> 1.1.0' # 1.2.0 doesn't work with knife-solo
|
||||
cookbook 'users', '~> 5.0.0'
|
||||
cookbook 'sudo', '~> 3.5.0'
|
||||
cookbook 'hostname'
|
||||
cookbook 'redis',
|
||||
git: 'https://github.com/phlipper/chef-redis.git',
|
||||
ref: 'v0.5.6'
|
||||
cookbook 'ufw'
|
||||
cookbook 'firewall'
|
||||
cookbook 'nginx'
|
||||
cookbook 'firewall', '~> 2.6.1'
|
||||
cookbook 'chef_nginx', '~> 6.0.2'
|
||||
cookbook 'build-essential'
|
||||
cookbook 'mysql', '~> 8.3.0'
|
||||
cookbook 'mysql'
|
||||
cookbook 'postgresql', '~> 6.1'
|
||||
cookbook 'database'
|
||||
cookbook 'mysql2_chef_gem', '~> 2.0.1'
|
||||
cookbook 'omnibus_updater'
|
||||
cookbook 'mysql2_chef_gem'
|
||||
cookbook 'chef_client_updater', '~> 1.0.2'
|
||||
cookbook 'timezone-ii'
|
||||
cookbook 'nodejs', '~> 3.0.0'
|
||||
cookbook 'ark'
|
||||
cookbook 'logrotate'
|
||||
|
||||
# Unused
|
||||
cookbook "yum-epel", '0.3.6'
|
||||
cookbook 'ark', '~> 3.0.0'
|
||||
cookbook 'logrotate', '~> 2.1.0'
|
||||
cookbook 'openssl', '~> 7.0.1'
|
||||
end
|
||||
|
||||
|
18
Gemfile.lock
18
Gemfile.lock
@ -3,7 +3,7 @@ GEM
|
||||
specs:
|
||||
addressable (2.5.0)
|
||||
public_suffix (~> 2.0, >= 2.0.2)
|
||||
artifactory (2.7.0)
|
||||
artifactory (2.8.1)
|
||||
ast (2.3.0)
|
||||
attribute_struct (0.3.4)
|
||||
bogo (>= 0.1.31, < 0.3.0)
|
||||
@ -77,7 +77,7 @@ GEM
|
||||
colored (1.2)
|
||||
command_line_reporter (3.3.6)
|
||||
colored (>= 1.2)
|
||||
cookstyle (1.3.0)
|
||||
cookstyle (1.3.1)
|
||||
rubocop (= 0.47.1)
|
||||
diff-lcs (1.3)
|
||||
domain_name (0.5.20170223)
|
||||
@ -157,7 +157,9 @@ GEM
|
||||
proxifier (1.0.3)
|
||||
public_suffix (2.0.5)
|
||||
rack (2.0.1)
|
||||
rainbow (2.2.1)
|
||||
rainbow (2.2.2)
|
||||
rake
|
||||
rake (12.0.0)
|
||||
rspec (3.5.0)
|
||||
rspec-core (~> 3.5.0)
|
||||
rspec-expectations (~> 3.5.0)
|
||||
@ -199,19 +201,19 @@ GEM
|
||||
sfl
|
||||
syslog-logger (1.6.8)
|
||||
systemu (2.6.5)
|
||||
test-kitchen (1.15.0)
|
||||
test-kitchen (1.16.0)
|
||||
mixlib-install (>= 1.2, < 3.0)
|
||||
mixlib-shellout (>= 1.2, < 3.0)
|
||||
net-scp (~> 1.1)
|
||||
net-ssh (>= 2.9, < 5.0)
|
||||
net-ssh-gateway (~> 1.2)
|
||||
safe_yaml (~> 1.0)
|
||||
thor (~> 0.18)
|
||||
thor (0.19.4)
|
||||
thor (~> 0.19, < 0.19.2)
|
||||
thor (0.19.1)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.7.2)
|
||||
unicode-display_width (1.1.3)
|
||||
unicode-display_width (1.2.1)
|
||||
uuidtools (2.1.5)
|
||||
wmi-lite (1.0.0)
|
||||
|
||||
@ -227,4 +229,4 @@ DEPENDENCIES
|
||||
test-kitchen
|
||||
|
||||
BUNDLED WITH
|
||||
1.14.3
|
||||
1.14.6
|
||||
|
39
Vagrantfile
vendored
39
Vagrantfile
vendored
@ -13,7 +13,19 @@ Vagrant.configure(2) do |config|
|
||||
# Every Vagrant development environment requires a box. You can search for
|
||||
# boxes at https://atlas.hashicorp.com/search.
|
||||
config.vm.box = "bento/ubuntu-16.04"
|
||||
# config.vm.box = "bento/debian-8.7"
|
||||
|
||||
config.vm.provider :virtualbox do |vb|
|
||||
# Customize the amount of memory on the VM:
|
||||
vb.memory = "1024"
|
||||
vb.cpus = 2
|
||||
end
|
||||
|
||||
config.vm.provider :docker do |d, override|
|
||||
d.image = "nishidayuya/docker-vagrant-ubuntu:xenial"
|
||||
d.has_ssh = true
|
||||
override.vm.box = nil
|
||||
override.ssh.port = 22
|
||||
end
|
||||
|
||||
# Disable automatic box update checking. If you disable this, then
|
||||
# boxes will only be checked for updates when the user runs
|
||||
@ -70,16 +82,27 @@ Vagrant.configure(2) do |config|
|
||||
# sudo apt-get install -y apache2
|
||||
# SHELL
|
||||
|
||||
config.vm.provision :chef_solo do |chef|
|
||||
chef.cookbooks_path = ['./cookbooks', './site-cookbooks']
|
||||
chef.data_bags_path = './data_bags'
|
||||
chef.roles_path = './roles'
|
||||
# Install latest Chef via Omnibus
|
||||
# Needs `vagrant plugin install vagrant-omnibus`
|
||||
if Vagrant.has_plugin?("vagrant-omnibus")
|
||||
config.omnibus.chef_version = "12.19.36"
|
||||
end
|
||||
|
||||
config.vm.provision :chef_zero do |chef|
|
||||
chef.cookbooks_path = ['cookbooks', 'site-cookbooks']
|
||||
chef.data_bags_path = 'data_bags'
|
||||
chef.roles_path = 'roles'
|
||||
chef.node_name = "vagrant-node"
|
||||
chef.environments_path = './environments'
|
||||
chef.nodes_path = 'nodes'
|
||||
chef.environments_path = 'environments'
|
||||
chef.encrypted_data_bag_secret_key_path = '.chef/encrypted_data_bag_secret'
|
||||
chef.environment = 'development'
|
||||
chef.add_recipe 'kosmos-base'
|
||||
chef.add_recipe 'kosmos-wordpress'
|
||||
chef.add_recipe 'sockethub'
|
||||
|
||||
# chef.add_recipe 'sockethub'
|
||||
# chef.add_recipe 'kosmos-mastodon'
|
||||
# chef.add_recipe 'kosmos-mastodon::nginx'
|
||||
# chef.add_recipe '5apps-hubot::xmpp_botka'
|
||||
# chef.add_recipe 'kosmos-hubot'
|
||||
end
|
||||
end
|
||||
|
729
batali.manifest
729
batali.manifest
@ -21,7 +21,7 @@
|
||||
"> 0"
|
||||
],
|
||||
[
|
||||
"nginx",
|
||||
"chef_nginx",
|
||||
"> 0"
|
||||
],
|
||||
[
|
||||
@ -33,10 +33,10 @@
|
||||
"> 0"
|
||||
]
|
||||
],
|
||||
"version": "0.2.0",
|
||||
"version": "0.3.0",
|
||||
"source": {
|
||||
"url": "https://github.com/67P/mediawiki-cookbook.git",
|
||||
"ref": "41d3c5129b5a6cd9c473e99339885bc1feac5d57",
|
||||
"ref": "8da675abc28b1b1ccf00d32df8a1923208e762c9",
|
||||
"type": "Batali::Source::Git",
|
||||
"subdirectory": null
|
||||
}
|
||||
@ -100,11 +100,11 @@
|
||||
">= 1.1"
|
||||
]
|
||||
],
|
||||
"version": "8.0.0",
|
||||
"version": "8.0.1",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/build-essential/versions/8.0.0/download",
|
||||
"version": "8.0.0"
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/build-essential/versions/8.0.1/download",
|
||||
"version": "8.0.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -115,11 +115,11 @@
|
||||
">= 1.2.2"
|
||||
]
|
||||
],
|
||||
"version": "1.0.4",
|
||||
"version": "2.0.2",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/seven_zip/versions/1.0.4/download",
|
||||
"version": "1.0.4"
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/seven_zip/versions/2.0.2/download",
|
||||
"version": "2.0.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -268,142 +268,78 @@
|
||||
"name": "postgresql",
|
||||
"dependencies": [
|
||||
[
|
||||
"apt",
|
||||
">= 1.9.0"
|
||||
"compat_resource",
|
||||
">= 12.16.3"
|
||||
],
|
||||
[
|
||||
"build-essential",
|
||||
">= 0.0.0"
|
||||
">= 2.0.0"
|
||||
],
|
||||
[
|
||||
"openssl",
|
||||
"~> 4.0"
|
||||
">= 4.0"
|
||||
]
|
||||
],
|
||||
"version": "4.0.0",
|
||||
"version": "6.1.1",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/postgresql/versions/4.0.0/download",
|
||||
"version": "4.0.0"
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/postgresql/versions/6.1.1/download",
|
||||
"version": "6.1.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "apt",
|
||||
"name": "compat_resource",
|
||||
"dependencies": [
|
||||
|
||||
],
|
||||
"version": "2.9.2",
|
||||
"version": "12.19.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/apt/versions/2.9.2/download",
|
||||
"version": "2.9.2"
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/compat_resource/versions/12.19.0/download",
|
||||
"version": "12.19.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "openssl",
|
||||
"dependencies": [
|
||||
[
|
||||
"chef-sugar",
|
||||
">= 3.1.1"
|
||||
]
|
||||
|
||||
],
|
||||
"version": "4.4.0",
|
||||
"version": "7.0.1",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/openssl/versions/4.4.0/download",
|
||||
"version": "4.4.0"
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/openssl/versions/7.0.1/download",
|
||||
"version": "7.0.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "nginx",
|
||||
"name": "chef_nginx",
|
||||
"dependencies": [
|
||||
[
|
||||
"apt",
|
||||
"~> 2.2"
|
||||
],
|
||||
[
|
||||
"bluepill",
|
||||
"~> 2.3"
|
||||
],
|
||||
[
|
||||
"build-essential",
|
||||
"~> 2.0"
|
||||
">= 0.0.0"
|
||||
],
|
||||
[
|
||||
"ohai",
|
||||
"~> 2.0"
|
||||
],
|
||||
[
|
||||
"runit",
|
||||
"~> 1.2"
|
||||
">= 4.1.0"
|
||||
],
|
||||
[
|
||||
"yum-epel",
|
||||
"~> 0.3"
|
||||
]
|
||||
">= 0.0.0"
|
||||
],
|
||||
"version": "2.7.6",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/nginx/versions/2.7.6/download",
|
||||
"version": "2.7.6"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "bluepill",
|
||||
"dependencies": [
|
||||
[
|
||||
"rsyslog",
|
||||
">= 2.0"
|
||||
]
|
||||
"compat_resource",
|
||||
">= 12.16.3"
|
||||
],
|
||||
"version": "2.4.3",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/bluepill/versions/2.4.3/download",
|
||||
"version": "2.4.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "rsyslog",
|
||||
"dependencies": [
|
||||
|
||||
],
|
||||
"version": "2.2.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/rsyslog/versions/2.2.0/download",
|
||||
"version": "2.2.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "build-essential",
|
||||
"dependencies": [
|
||||
[
|
||||
"7-zip",
|
||||
"zypper",
|
||||
">= 0.0.0"
|
||||
]
|
||||
],
|
||||
"version": "2.4.0",
|
||||
"version": "6.0.2",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/build-essential/versions/2.4.0/download",
|
||||
"version": "2.4.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "7-zip",
|
||||
"dependencies": [
|
||||
[
|
||||
"windows",
|
||||
">= 1.2.2"
|
||||
]
|
||||
],
|
||||
"version": "1.0.2",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/7-zip/versions/1.0.2/download",
|
||||
"version": "1.0.2"
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/chef_nginx/versions/6.0.2/download",
|
||||
"version": "6.0.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -411,38 +347,23 @@
|
||||
"dependencies": [
|
||||
|
||||
],
|
||||
"version": "2.1.0",
|
||||
"version": "5.0.4",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/ohai/versions/2.1.0/download",
|
||||
"version": "2.1.0"
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/ohai/versions/5.0.4/download",
|
||||
"version": "5.0.4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "runit",
|
||||
"dependencies": [
|
||||
[
|
||||
"packagecloud",
|
||||
">= 0.0.0"
|
||||
]
|
||||
],
|
||||
"version": "1.7.6",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/runit/versions/1.7.6/download",
|
||||
"version": "1.7.6"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "packagecloud",
|
||||
"name": "zypper",
|
||||
"dependencies": [
|
||||
|
||||
],
|
||||
"version": "0.2.0",
|
||||
"version": "0.4.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/packagecloud/versions/0.2.0/download",
|
||||
"version": "0.2.0"
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/zypper/versions/0.4.0/download",
|
||||
"version": "0.4.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -491,6 +412,18 @@
|
||||
"version": "0.3.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "apt",
|
||||
"dependencies": [
|
||||
|
||||
],
|
||||
"version": "2.9.2",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/apt/versions/2.9.2/download",
|
||||
"version": "2.9.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "php-fpm",
|
||||
"dependencies": [
|
||||
@ -550,8 +483,8 @@
|
||||
">= 0.3.1"
|
||||
],
|
||||
[
|
||||
"nginx",
|
||||
"~> 2.7.4"
|
||||
"chef_nginx",
|
||||
"> 0"
|
||||
],
|
||||
[
|
||||
"php-fpm",
|
||||
@ -562,10 +495,10 @@
|
||||
"~> 0.7"
|
||||
]
|
||||
],
|
||||
"version": "3.0.0",
|
||||
"version": "3.1.0",
|
||||
"source": {
|
||||
"url": "https://github.com/67P/wordpress-cookbook.git",
|
||||
"ref": "d6401db517476e6f3ab36aa92dfc0f5ed6a8a264",
|
||||
"ref": "a80b8a17fb823a01b769f690349d745c40fff04c",
|
||||
"type": "Batali::Source::Git",
|
||||
"subdirectory": null
|
||||
}
|
||||
@ -607,40 +540,405 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "unattended-upgrades",
|
||||
"name": "poise-ruby-build",
|
||||
"dependencies": [
|
||||
[
|
||||
"apt",
|
||||
">= 0.0.0"
|
||||
"poise",
|
||||
"~> 2.0"
|
||||
],
|
||||
[
|
||||
"poise-build-essential",
|
||||
"~> 1.0"
|
||||
],
|
||||
[
|
||||
"poise-git",
|
||||
"~> 1.0"
|
||||
],
|
||||
[
|
||||
"poise-ruby",
|
||||
"~> 2.1"
|
||||
]
|
||||
],
|
||||
"version": "0.1.2",
|
||||
"version": "1.1.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/unattended-upgrades/versions/0.1.2/download",
|
||||
"version": "0.1.2"
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/poise-ruby-build/versions/1.1.0/download",
|
||||
"version": "1.1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "application_nodejs",
|
||||
"name": "poise",
|
||||
"dependencies": [
|
||||
|
||||
],
|
||||
"version": "2.7.2",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/poise/versions/2.7.2/download",
|
||||
"version": "2.7.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "poise-build-essential",
|
||||
"dependencies": [
|
||||
[
|
||||
"nodejs",
|
||||
"> 0"
|
||||
"poise",
|
||||
"~> 2.6"
|
||||
]
|
||||
],
|
||||
"version": "1.0.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/poise-build-essential/versions/1.0.0/download",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "poise-git",
|
||||
"dependencies": [
|
||||
[
|
||||
"poise",
|
||||
"~> 2.6"
|
||||
],
|
||||
[
|
||||
"poise-languages",
|
||||
"~> 2.1"
|
||||
]
|
||||
],
|
||||
"version": "1.0.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/poise-git/versions/1.0.0/download",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "poise-languages",
|
||||
"dependencies": [
|
||||
[
|
||||
"poise",
|
||||
"~> 2.5"
|
||||
],
|
||||
[
|
||||
"poise-archive",
|
||||
"~> 1.0"
|
||||
]
|
||||
],
|
||||
"version": "2.1.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/poise-languages/versions/2.1.0/download",
|
||||
"version": "2.1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "poise-archive",
|
||||
"dependencies": [
|
||||
[
|
||||
"poise",
|
||||
"~> 2.6"
|
||||
]
|
||||
],
|
||||
"version": "1.4.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/poise-archive/versions/1.4.0/download",
|
||||
"version": "1.4.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "poise-ruby",
|
||||
"dependencies": [
|
||||
[
|
||||
"poise",
|
||||
"~> 2.0"
|
||||
],
|
||||
[
|
||||
"poise-languages",
|
||||
"~> 2.0"
|
||||
]
|
||||
],
|
||||
"version": "2.2.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/poise-ruby/versions/2.2.0/download",
|
||||
"version": "2.2.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "application",
|
||||
"dependencies": [
|
||||
[
|
||||
"poise",
|
||||
"~> 2.4"
|
||||
],
|
||||
[
|
||||
"poise-service",
|
||||
"~> 1.0"
|
||||
]
|
||||
],
|
||||
"version": "5.2.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/application/versions/5.2.0/download",
|
||||
"version": "5.2.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "poise-service",
|
||||
"dependencies": [
|
||||
[
|
||||
"poise",
|
||||
"~> 2.0"
|
||||
]
|
||||
],
|
||||
"version": "1.4.2",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/poise-service/versions/1.4.2/download",
|
||||
"version": "1.4.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "application_javascript",
|
||||
"dependencies": [
|
||||
[
|
||||
"poise",
|
||||
"~> 2.0"
|
||||
],
|
||||
[
|
||||
"application",
|
||||
"~> 5.0"
|
||||
],
|
||||
[
|
||||
"poise-javascript",
|
||||
"~> 1.0"
|
||||
],
|
||||
[
|
||||
"poise-service",
|
||||
"~> 1.0"
|
||||
]
|
||||
],
|
||||
"version": "1.0.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/application_javascript/versions/1.0.0/download",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "poise-javascript",
|
||||
"dependencies": [
|
||||
[
|
||||
"poise",
|
||||
"~> 2.0"
|
||||
],
|
||||
[
|
||||
"poise-languages",
|
||||
"~> 2.0"
|
||||
]
|
||||
],
|
||||
"version": "1.1.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/poise-javascript/versions/1.1.0/download",
|
||||
"version": "1.1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "application_ruby",
|
||||
"dependencies": [
|
||||
[
|
||||
"poise",
|
||||
"~> 2.0"
|
||||
],
|
||||
[
|
||||
"application",
|
||||
"~> 5.0"
|
||||
],
|
||||
[
|
||||
"poise-ruby",
|
||||
"~> 2.1"
|
||||
],
|
||||
[
|
||||
"poise-service",
|
||||
"~> 1.0"
|
||||
]
|
||||
],
|
||||
"version": "4.1.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/application_ruby/versions/4.1.0/download",
|
||||
"version": "4.1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "application_git",
|
||||
"dependencies": [
|
||||
[
|
||||
"git",
|
||||
">= 0.0.0"
|
||||
],
|
||||
[
|
||||
"poise",
|
||||
"~> 2.0"
|
||||
],
|
||||
[
|
||||
"application",
|
||||
"~> 5.0"
|
||||
]
|
||||
],
|
||||
"version": "1.1.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/application_git/versions/1.1.0/download",
|
||||
"version": "1.1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "git",
|
||||
"dependencies": [
|
||||
[
|
||||
"build-essential",
|
||||
">= 0.0.0"
|
||||
],
|
||||
[
|
||||
"dmg",
|
||||
">= 0.0.0"
|
||||
],
|
||||
[
|
||||
"yum-epel",
|
||||
">= 0.0.0"
|
||||
]
|
||||
],
|
||||
"version": "6.0.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/git/versions/6.0.0/download",
|
||||
"version": "6.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dmg",
|
||||
"dependencies": [
|
||||
|
||||
],
|
||||
"version": "4.0.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/dmg/versions/4.0.0/download",
|
||||
"version": "4.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "users",
|
||||
"dependencies": [
|
||||
|
||||
],
|
||||
"version": "5.0.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/users/versions/5.0.0/download",
|
||||
"version": "5.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "sudo",
|
||||
"dependencies": [
|
||||
|
||||
],
|
||||
"version": "3.5.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/sudo/versions/3.5.0/download",
|
||||
"version": "3.5.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "hostname",
|
||||
"dependencies": [
|
||||
[
|
||||
"hostsfile",
|
||||
">= 0.0.0"
|
||||
]
|
||||
],
|
||||
"version": "0.4.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/hostname/versions/0.4.0/download",
|
||||
"version": "0.4.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "hostsfile",
|
||||
"dependencies": [
|
||||
|
||||
],
|
||||
"version": "2.4.5",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/hostsfile/versions/2.4.5/download",
|
||||
"version": "2.4.5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "redis",
|
||||
"dependencies": [
|
||||
[
|
||||
"apt",
|
||||
"> 0"
|
||||
]
|
||||
],
|
||||
"version": "2.0.1",
|
||||
"version": "0.5.6",
|
||||
"source": {
|
||||
"url": "https://github.com/67p/application_nodejs.git",
|
||||
"ref": "0c3494b0cae87bd1e9cbf360e91f1a290b517a66",
|
||||
"url": "https://github.com/phlipper/chef-redis.git",
|
||||
"ref": "7476279fc9c8727f082b8d77b5e1922dc2ef437b",
|
||||
"type": "Batali::Source::Git",
|
||||
"subdirectory": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "firewall",
|
||||
"dependencies": [
|
||||
[
|
||||
"chef-sugar",
|
||||
">= 0.0.0"
|
||||
]
|
||||
],
|
||||
"version": "2.6.1",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/firewall/versions/2.6.1/download",
|
||||
"version": "2.6.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "chef_client_updater",
|
||||
"dependencies": [
|
||||
[
|
||||
"compat_resource",
|
||||
">= 12.16.3"
|
||||
]
|
||||
],
|
||||
"version": "1.0.2",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/chef_client_updater/versions/1.0.2/download",
|
||||
"version": "1.0.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "timezone-ii",
|
||||
"dependencies": [
|
||||
|
||||
],
|
||||
"version": "0.2.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/timezone-ii/versions/0.2.0/download",
|
||||
"version": "0.2.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "nodejs",
|
||||
"dependencies": [
|
||||
@ -688,171 +986,38 @@
|
||||
">= 0.0.0"
|
||||
]
|
||||
],
|
||||
"version": "2.2.1",
|
||||
"version": "3.0.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/ark/versions/2.2.1/download",
|
||||
"version": "2.2.1"
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/ark/versions/3.0.0/download",
|
||||
"version": "3.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "homebrew",
|
||||
"dependencies": [
|
||||
[
|
||||
"build-essential",
|
||||
">= 2.1.2"
|
||||
]
|
||||
],
|
||||
"version": "2.0.5",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/homebrew/versions/2.0.5/download",
|
||||
"version": "2.0.5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "application",
|
||||
"dependencies": [
|
||||
|
||||
],
|
||||
"version": "4.1.6",
|
||||
"version": "3.0.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/application/versions/4.1.6/download",
|
||||
"version": "4.1.6"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "users",
|
||||
"dependencies": [
|
||||
|
||||
],
|
||||
"version": "4.0.3",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/users/versions/4.0.3/download",
|
||||
"version": "4.0.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "sudo",
|
||||
"dependencies": [
|
||||
|
||||
],
|
||||
"version": "3.3.1",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/sudo/versions/3.3.1/download",
|
||||
"version": "3.3.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "hostname",
|
||||
"dependencies": [
|
||||
[
|
||||
"hostsfile",
|
||||
">= 0.0.0"
|
||||
]
|
||||
],
|
||||
"version": "0.4.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/hostname/versions/0.4.0/download",
|
||||
"version": "0.4.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "hostsfile",
|
||||
"dependencies": [
|
||||
|
||||
],
|
||||
"version": "2.4.5",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/hostsfile/versions/2.4.5/download",
|
||||
"version": "2.4.5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "redis",
|
||||
"dependencies": [
|
||||
[
|
||||
"apt",
|
||||
"> 0"
|
||||
]
|
||||
],
|
||||
"version": "0.5.6",
|
||||
"source": {
|
||||
"url": "https://github.com/phlipper/chef-redis.git",
|
||||
"ref": "7476279fc9c8727f082b8d77b5e1922dc2ef437b",
|
||||
"type": "Batali::Source::Git",
|
||||
"subdirectory": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ufw",
|
||||
"dependencies": [
|
||||
[
|
||||
"firewall",
|
||||
">= 2.0"
|
||||
]
|
||||
],
|
||||
"version": "3.1.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/ufw/versions/3.1.0/download",
|
||||
"version": "3.1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "firewall",
|
||||
"dependencies": [
|
||||
[
|
||||
"chef-sugar",
|
||||
">= 0.0.0"
|
||||
]
|
||||
],
|
||||
"version": "2.5.4",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/firewall/versions/2.5.4/download",
|
||||
"version": "2.5.4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "omnibus_updater",
|
||||
"dependencies": [
|
||||
|
||||
],
|
||||
"version": "3.0.2",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/omnibus_updater/versions/3.0.2/download",
|
||||
"version": "3.0.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "timezone-ii",
|
||||
"dependencies": [
|
||||
|
||||
],
|
||||
"version": "0.2.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/timezone-ii/versions/0.2.0/download",
|
||||
"version": "0.2.0"
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/homebrew/versions/3.0.0/download",
|
||||
"version": "3.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "logrotate",
|
||||
"dependencies": [
|
||||
|
||||
[
|
||||
"compat_resource",
|
||||
">= 0.0.0"
|
||||
]
|
||||
],
|
||||
"version": "1.9.2",
|
||||
"version": "2.1.0",
|
||||
"source": {
|
||||
"type": "Batali::Source::Site",
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/logrotate/versions/1.9.2/download",
|
||||
"version": "1.9.2"
|
||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/logrotate/versions/2.1.0/download",
|
||||
"version": "2.1.0"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -1,13 +0,0 @@
|
||||
7-zip Cookbook CHANGELOG
|
||||
========================
|
||||
This file is used to list changes made in each version of the 7-zip cookbook.
|
||||
|
||||
|
||||
v1.0.2
|
||||
------
|
||||
### Improvement
|
||||
- **[COOK-3476](https://tickets.opscode.com/browse/COOK-3476)** - Upgrade to 7-zip 9.22
|
||||
|
||||
1.0.0
|
||||
-----
|
||||
- initial release
|
@ -1,50 +0,0 @@
|
||||
7-zip Cookbook
|
||||
==============
|
||||
[7-Zip](http://www.7-zip.org/) is a file archiver with a high compression ratio. This cookbook installs the full 7-zip suite of tools (GUI and CLI).
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
### Platform
|
||||
- Windows XP
|
||||
- Windows Vista
|
||||
- Windows Server 2003 R2
|
||||
- Windows 7
|
||||
- Windows Server 2008 (R1, R2)
|
||||
- Windows 8
|
||||
- Windows Server 2012
|
||||
|
||||
### Cookbooks
|
||||
- windows
|
||||
|
||||
|
||||
Attributes
|
||||
----------
|
||||
- `node['7-zip']['home']` - location to install 7-zip files to. default is `%SYSTEMDRIVE%\7-zip`
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
### default
|
||||
Downloads and installs 7-zip to the location specified by `node['7-zip']['home']`. Also ensures `node['7-zip']['home']` is in the system path.
|
||||
|
||||
|
||||
License & Authors
|
||||
-----------------
|
||||
- Author:: Seth Chisamore (<schisamo@opscode.com>)
|
||||
|
||||
```text
|
||||
Copyright:: 2011, Opscode, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
```
|
@ -1,31 +0,0 @@
|
||||
#
|
||||
# Author:: Seth Chisamore (<schisamo@opscode.com>)
|
||||
# Cookbook Name:: 7-zip
|
||||
# Attribute:: default
|
||||
#
|
||||
# Copyright:: Copyright (c) 2011 Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
if kernel['machine'] =~ /x86_64/
|
||||
default['7-zip']['url'] = "http://downloads.sourceforge.net/sevenzip/7z922-x64.msi"
|
||||
default['7-zip']['checksum'] = "f09bf515289eea45185a4cc673e3bbc18ce608c55b4cf96e77833435c9cdf3dc"
|
||||
default['7-zip']['package_name'] = "7-Zip 9.22 (x64 edition)"
|
||||
else
|
||||
default['7-zip']['url'] = "http://downloads.sourceforge.net/sevenzip/7z922.msi"
|
||||
default['7-zip']['checksum'] = "86df264d22c3dd3ab80cb55a118da2d41bdd95c2db2cd09a6bbdf48f069e3d7a"
|
||||
default['7-zip']['package_name'] = "7-Zip 9.22"
|
||||
end
|
||||
|
||||
default['7-zip']['home'] = "#{ENV['SYSTEMDRIVE']}\\7-zip"
|
@ -1,31 +0,0 @@
|
||||
{
|
||||
"name": "7-zip",
|
||||
"version": "1.0.2",
|
||||
"description": "Installs/Configures the 7-zip file archiver",
|
||||
"long_description": "7-zip Cookbook\n==============\n[7-Zip](http://www.7-zip.org/) is a file archiver with a high compression ratio. This cookbook installs the full 7-zip suite of tools (GUI and CLI).\n\n\nRequirements\n------------\n### Platform\n- Windows XP\n- Windows Vista\n- Windows Server 2003 R2\n- Windows 7\n- Windows Server 2008 (R1, R2)\n- Windows 8\n- Windows Server 2012\n\n### Cookbooks\n- windows\n\n\nAttributes\n----------\n- `node['7-zip']['home']` - location to install 7-zip files to. default is `%SYSTEMDRIVE%\\7-zip`\n\n\nUsage\n-----\n### default\nDownloads and installs 7-zip to the location specified by `node['7-zip']['home']`. Also ensures `node['7-zip']['home']` is in the system path.\n\n\nLicense & Authors\n-----------------\n- Author:: Seth Chisamore (<schisamo@opscode.com>)\n\n```text\nCopyright:: 2011, Opscode, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n",
|
||||
"maintainer": "Opscode, Inc.",
|
||||
"maintainer_email": "cookbooks@opscode.com",
|
||||
"license": "Apache 2.0",
|
||||
"platforms": {
|
||||
"windows": ">= 0.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"windows": ">= 1.2.2"
|
||||
},
|
||||
"recommendations": {
|
||||
},
|
||||
"suggestions": {
|
||||
},
|
||||
"conflicting": {
|
||||
},
|
||||
"providing": {
|
||||
},
|
||||
"replacing": {
|
||||
},
|
||||
"attributes": {
|
||||
},
|
||||
"groupings": {
|
||||
},
|
||||
"recipes": {
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
name "7-zip"
|
||||
maintainer "Opscode, Inc."
|
||||
maintainer_email "cookbooks@opscode.com"
|
||||
license "Apache 2.0"
|
||||
description "Installs/Configures the 7-zip file archiver"
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version "1.0.2"
|
||||
supports "windows"
|
||||
|
||||
depends "windows", ">= 1.2.2"
|
@ -1,103 +1,101 @@
|
||||
application Cookbook CHANGELOG
|
||||
=======================
|
||||
This file is used to list changes made in each version of the application cookbook.
|
||||
# Application Changelog
|
||||
|
||||
## v5.2.0
|
||||
|
||||
v4.1.6
|
||||
------
|
||||
- Support for Chef 12.
|
||||
- Add `strict_ssh` option to enable host key checking.
|
||||
- Add `keep_releases` option to control number of releases to keep.
|
||||
- Allow passing a path to a file for `deploy_key`.
|
||||
* Add `application_directory` resource.
|
||||
* Chef 13 compatibility.
|
||||
|
||||
v4.1.4
|
||||
------
|
||||
### Bug
|
||||
- **[COOK-3343](https://tickets.opscode.com/browse/COOK-3343)** - Can't parse release candidate version number
|
||||
## v5.1.0
|
||||
|
||||
* Add `application_cookbook_file`, `application_file`, and `application_template` resources.
|
||||
|
||||
v4.1.2
|
||||
------
|
||||
### Bug
|
||||
- **[COOK-3343](https://tickets.opscode.com/browse/COOK-3343)** - Can't parse release candidate version number
|
||||
## v5.0.0
|
||||
|
||||
* Massive rewrite on top of newer Chef patterns. See the 5.0 README for details.
|
||||
|
||||
v4.1.0
|
||||
------
|
||||
### Bug
|
||||
- [COOK-3343] - Can't parse release candidate version number
|
||||
## v4.1.6
|
||||
|
||||
* Support for Chef 12.
|
||||
* Add `strict_ssh` option to enable host key checking.
|
||||
* Add `keep_releases` option to control number of releases to keep.
|
||||
* Allow passing a path to a file for `deploy_key`.
|
||||
|
||||
v4.0.0
|
||||
------
|
||||
### Breaking
|
||||
- Removes compatability with Chef 10
|
||||
## v4.1.4
|
||||
|
||||
* [COOK-3343](https://tickets.opscode.com/browse/COOK-3343) - Can't parse release candidate version number.
|
||||
|
||||
## v4.1.2
|
||||
|
||||
* [COOK-3343](https://tickets.opscode.com/browse/COOK-3343) - Can't parse release candidate version number.
|
||||
|
||||
## v4.1.0
|
||||
|
||||
* [COOK-3343] - Can't parse release candidate version number.
|
||||
|
||||
## v4.0.0
|
||||
|
||||
* Removes compatability with Chef 10.
|
||||
* [COOK-3564](https://tickets.opscode.com/browse/COOK-3564) - Replace calls to `Chef::Mixin::RecipeDefinitionDSLCore`.
|
||||
|
||||
## v3.0.0
|
||||
|
||||
* [COOK-3306]: Multiple Memory Leaks in Application Cookbook.
|
||||
|
||||
## v2.0.4
|
||||
|
||||
* [COOK-2812]: application cookbook doesn't allow to specify a block as `restart_command`.
|
||||
|
||||
## v2.0.2
|
||||
|
||||
* [COOK-2537]: Provide proper `respond_to` behavior when using `method_missing`.
|
||||
* [COOK-2713]: application resource should Allow sub-resource attributes to propogate up.
|
||||
|
||||
### Improvement
|
||||
- **[COOK-3564](https://tickets.opscode.com/browse/COOK-3564)** - Replace calls to `Chef::Mixin::RecipeDefinitionDSLCore`
|
||||
* [COOK-2597]: Allow customization for `shallow_clone` when doing a git deploy.
|
||||
|
||||
v3.0.0
|
||||
------
|
||||
### Bug
|
||||
- [COOK-3306]: Multiple Memory Leaks in Application Cookbook
|
||||
## v2.0.0
|
||||
|
||||
v2.0.4
|
||||
------
|
||||
### Bug
|
||||
- [COOK-2812]: application cookbook doesn't allow to specify a block as `restart_command`
|
||||
|
||||
v2.0.2
|
||||
------
|
||||
### Bug
|
||||
- [COOK-2537]: Provide proper `respond_to` behavior when using `method_missing`
|
||||
- [COOK-2713]: application resource should Allow sub-resource attributes to propogate up
|
||||
|
||||
### Improvement
|
||||
- [COOK-2597]: Allow customization for `shallow_clone` when doing a git deploy
|
||||
|
||||
v2.0.0
|
||||
------
|
||||
This release is incompatible with previous releases (hence major version change). The recipes used in older versions are deprecated and completely removed. See README.md for further detail.
|
||||
|
||||
- [COOK-1673] - `deploy_revision` in the application cookbook gives an argument error
|
||||
- [COOK-1820] - Application cookbook: remove deprecated recipes
|
||||
* [COOK-1673] - `deploy_revision` in the application cookbook gives an argument error.
|
||||
* [COOK-1820] - Application cookbook: remove deprecated recipes.
|
||||
|
||||
v1.0.4
|
||||
------
|
||||
- [COOK-1567] - Add git submodules to application cookbook
|
||||
## v1.0.4
|
||||
|
||||
v1.0.2
|
||||
------
|
||||
- [COOK-1312] - string callbacks fail with method not found (really included this time)
|
||||
- [COOK-1332] - add `release_path` and `shared_path` methods
|
||||
- [COOK-1333] - add example for running migrations
|
||||
- [COOK-1360] - fix minor typos in README
|
||||
- [COOK-1374] - use runit attributes in unicorn run script
|
||||
* [COOK-1567] - Add git submodules to application cookbook.
|
||||
|
||||
## v1.0.2
|
||||
|
||||
* [COOK-1312] - string callbacks fail with method not found (really included this time).
|
||||
* [COOK-1332] - add `release_path` and `shared_path` methods.
|
||||
* [COOK-1333] - add example for running migrations.
|
||||
* [COOK-1360] - fix minor typos in README.
|
||||
* [COOK-1374] - use runit attributes in unicorn run script.
|
||||
|
||||
## v1.0.0
|
||||
|
||||
v1.0.0
|
||||
------
|
||||
This release introduces the LWRP for application deployment, as well as other improvements. The recipes will be deprecated in August 2012 as indicated by their warning messages and in the README.md.
|
||||
|
||||
- [COOK-634] - Implement LWRP for application deployment
|
||||
- [COOK-1116] - use other SCMs than git
|
||||
- [COOK-1252] - add `:force_deploy` that maps to corresponding action of deploy resource
|
||||
- [COOK-1253] - fix rollback error
|
||||
- [COOK-1312] - string callbacks fail with method not found
|
||||
- [COOK-1313] - implicit file based hooks aren't invoked
|
||||
- [COOK-1318] - Create `to_ary` method to resolve issue in resources() lookup on "application[foo]" resources
|
||||
* [COOK-634] - Implement LWRP for application deployment.
|
||||
* [COOK-1116] - use other SCMs than git.
|
||||
* [COOK-1252] - add `:force_deploy` that maps to corresponding action of deploy resource.
|
||||
* [COOK-1253] - fix rollback error.
|
||||
* [COOK-1312] - string callbacks fail with method not found.
|
||||
* [COOK-1313] - implicit file based hooks aren't invoked.
|
||||
* [COOK-1318] - Create `to_ary` method to resolve issue in resources() lookup on "application[foo]" resources.
|
||||
|
||||
v0.99.14
|
||||
--------
|
||||
- [COOK-1065] - use pip in virtualenv during deploy
|
||||
## v0.99.14
|
||||
|
||||
v0.99.12
|
||||
--------
|
||||
- [COOK-606] application cookbook deployment recipes should use ipaddress instead of fqdn
|
||||
* [COOK-1065] - use pip in virtualenv during deploy.
|
||||
|
||||
v0.99.11
|
||||
--------
|
||||
- make the `_default` `chef_environment` look like production rails env
|
||||
## v0.99.12
|
||||
|
||||
v0.99.10
|
||||
--------
|
||||
- Use Chef 0.10's `node.chef_environment` instead of `node['app_environment']`.
|
||||
* [COOK-606] application cookbook deployment recipes should use ipaddress instead of fqdn.
|
||||
|
||||
## v0.99.11
|
||||
|
||||
* make the `_default` `chef_environment` look like production rails env.
|
||||
|
||||
## v0.99.10
|
||||
|
||||
* Use Chef 0.10's `node.chef_environment` instead of `node['app_environment']`.
|
||||
|
@ -1,206 +1,260 @@
|
||||
Application cookbook
|
||||
====================
|
||||
This cookbook is designed to be able to describe and deploy web applications. It provides the basic infrastructure; other cookbooks are required to support specific combinations of frameworks and application servers. The following cookbooks are available at this time:
|
||||
# Application cookbook
|
||||
|
||||
- [application_java](https://github.com/opscode-cookbooks/application_java) (Java and Tomcat)
|
||||
- [application_nginx](https://github.com/opscode-cookbooks/application_nginx) (nginx reverse proxy)
|
||||
- [application_php](https://github.com/opscode-cookbooks/application_php) (PHP with `mod_php_apache2`)
|
||||
- [application_python](https://github.com/opscode-cookbooks/application_python) (Django with Gunicorn)
|
||||
- [application_ruby](https://github.com/opscode-cookbooks/application_ruby) (Rails with Passenger or Unicorn)
|
||||
[](https://travis-ci.org/poise/application)
|
||||
[](https://rubygems.org/gems/poise-application)
|
||||
[](https://supermarket.chef.io/cookbooks/application)
|
||||
[](https://codeclimate.com/github/poise/application)
|
||||
[](https://gemnasium.com/poise/application)
|
||||
[](https://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
A [Chef](https://www.chef.io/) cookbook to deploy applications.
|
||||
|
||||
Backwards Compatibility
|
||||
-----------------------
|
||||
- Version 4.0.0 dropped support for Chef 10
|
||||
- Version 2.0.0 dropped support for the `apps` data bag.
|
||||
## Getting Started
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
The previous dependencies have been moved out to the application-stack-specific cookbooks, and this cookbook has no external dependencies.
|
||||
|
||||
|
||||
Resources/Providers
|
||||
-------------------
|
||||
The `application` LWRP configures the basic properties of most applications, regardless of the framework or application server they use. These include:
|
||||
|
||||
- SCM information for the deployment, such as the repository URL and branch name;
|
||||
- deployment destination, including the filesystem path to deploy to;
|
||||
- any OS packages to install as dependencies;
|
||||
- optional callback to control the deployment.
|
||||
|
||||
This LWRP uses the `deploy_revision` LWRP to perform the bulk of its tasks, and many concepts and parameters map directly to it. Check the documentation for `deploy_revision` for more information.
|
||||
|
||||
Configuration of framework-specific aspects of the application are performed by invoking a sub-resource; see the appropriate cookbook for more documentation.
|
||||
|
||||
### Actions
|
||||
- `:deploy`: deploy an application, including any necessary configuration, restarting the associated service if necessary
|
||||
- `:force_deploy`: same as `:deploy`, but it will send a `:force_deploy` action to the deploy resource, directing it to deploy the application even if the same revision is already deployed
|
||||
|
||||
### Attribute Parameters
|
||||
- `name`: name attribute. The name of the application you are setting up. This will be used to derive the default value for other attribute
|
||||
- `packages`: an Array or Hash of packages to be installed before starting the deployment
|
||||
- `path`: target path of the deployment; it will be created if it does not exist
|
||||
- `owner`: the user that shall own the target path
|
||||
- `group`: the group that shall own the target path
|
||||
- `keep_releases`: count of keep releases
|
||||
- `strategy`: the underlying LWRP that will be used to perform the deployment. The default is `:deploy_revision`, and it should never be necessary to change it
|
||||
- `scm_provider`: the provider class to use for the deployment. It defaults to `Chef::Provider::Git`, you can set it to `Chef::Provider::Subversion` to deploy from an SVN repository
|
||||
- `repository`: the URL of the repository the application should be checked out from
|
||||
- `revision`: an identifier pointing to the revision that should be checked out
|
||||
- `deploy_key`: the private key to use to access the repository via SSH, or path to a file containing the key
|
||||
- `rollback_on_error`: if true, exceptions during a deployment will be caught and a clean rollback to the previous version will be attempted; the exception will then be re-raised. Defaults to true; change it only if you know what you are doing
|
||||
- `environment`: a Hash of environment variables to set while running migrations
|
||||
- `purge_before_symlink`: an Array of paths (relative to the checkout) to remove before creating symlinks
|
||||
- `create_dirs_before_symlink`: an Array of paths (relative to the checkout) pointing to directories to create before creating symlinks
|
||||
- `symlinks`: a Hash of shared/dir/path => release/dir/path. It determines which files and dirs in the shared directory get symlinked to the current release directory
|
||||
- `symlink_before_migrate`: similar to symlinks, except that they will be linked before any migration is run
|
||||
- `migrate`: if `true` then migrations will be run; defaults to false
|
||||
- `migration_command`: a command to run to migrate the application from the previous to the current state
|
||||
- `restart_command`: a command to run when restarting the application
|
||||
- `environment_name`: the name of a framework-specific "environment" (for example the Rails environment). By default it is the same as the Chef environment, unless it is `_default`, in which case it is set to `production`
|
||||
- `enable_submodules`: whether to enable git submodules in the deploy, passed into the deploy resource.
|
||||
|
||||
### Callback Attributes
|
||||
You can also set a few attributes on this LWRP that are interpreted as callback to be called at specific points during a deployment. If you pass a block, it will be evaluated within a new context. If you pass a string, it will be interpreted as a path (relative to the release directory) to a file; if it exists, it will be loaded and evaluated as though it were a Chef recipe.
|
||||
|
||||
The following callback attributes are available:
|
||||
|
||||
- `before_deploy`: invoked immediately after initial setup and before the deployment proper is started. This callback will be invoked on every Chef run
|
||||
- `before_migrate`
|
||||
- `before_symlink`
|
||||
- `before_restart`
|
||||
- `after_restart`
|
||||
|
||||
### Sub-resources
|
||||
Anything that is not a known attribute will be interpreted as the name of a sub-resource; the resource will be looked up, and any nested attribute will be passed to it. More than one sub-resource can be added to an application; the order is significant, with the latter sub-resources overriding any sub-resource that comes before.
|
||||
|
||||
Sub-resources can set their own values for some attributes; if they do, they will be merged together with the attribute set on the main resource. The attributes that support this behavior are the following:
|
||||
|
||||
- `environment`: environment variables from the application and from sub-resources will be merged together, with later resources overriding values set in the application or previous resources
|
||||
- `migration_command`: commands from the application and from sub-resources will be concatenated together joined with '&&' and run as a single shell command. The migration will only succeed if all the commands succeed
|
||||
- `restart_command`: commands from the application and from sub-resources will be evaluated in order
|
||||
- `symlink_before_migrate`: will be concatenated as a single array
|
||||
- `callbacks`: sub-resources callbacks will be invoked first, followed by the application callbacks
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
To use the application cookbook we recommend creating a cookbook named after the application, e.g. `my_app`. In `metadata.rb` you should declare a dependency on this cookbook and any framework cookbook the application may need. For example a Rails application may include:
|
||||
The application cookbook provides a central framework to deploy applications
|
||||
using Chef. Generally this will be web applications using things like Rails,
|
||||
Django, or NodeJS, but the framework makes no specific assumptions. The core
|
||||
`application` resource provides DSL support and helpers, but the heavy lifting
|
||||
is all done in specific plugins detailed below. Each deployment starts with
|
||||
an `application` resource:
|
||||
|
||||
```ruby
|
||||
depends 'application'
|
||||
depends 'application_ruby'
|
||||
application '/path/to/deploy' do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
|
||||
# ...
|
||||
end
|
||||
```
|
||||
|
||||
The default recipe should describe your application using the `application` LWRP; you may also include additional recipes, for example to set up a database, queues, search engines and other components of your application.
|
||||
|
||||
A recipe using this LWRP may look like this:
|
||||
The `application` resource uses the Poise subresource system for plugins. This
|
||||
means you configure the steps of the deployment like normal recipe code inside
|
||||
the `application` resource, with a few special additions:
|
||||
|
||||
```ruby
|
||||
application 'my_app' do
|
||||
path '/deploy/to/dir'
|
||||
owner 'app-user'
|
||||
group 'app-group'
|
||||
application '/path/to/deploy' do
|
||||
# Application resource properties.
|
||||
owner 'root'
|
||||
group 'root'
|
||||
|
||||
repository 'http://git.example.com/my-app.git'
|
||||
revision 'production'
|
||||
|
||||
# Apply the rails LWRP from application_ruby
|
||||
rails do
|
||||
# Rails-specific configuration. See the README in the
|
||||
# application_ruby cookbook for more information.
|
||||
# Subresources, like normal recipe code.
|
||||
package 'ruby'
|
||||
git '/path/to/deploy' do
|
||||
repository 'https://github.com/example/myapp.git'
|
||||
end
|
||||
|
||||
# Apply the passenger_apache2 LWRP, also from application_ruby
|
||||
passenger_apache2 do
|
||||
# Passenger-specific configuration.
|
||||
application_rails '/path/to/deploy' do
|
||||
database 'mysql://dbhost/myapp'
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
You can of course use any code necessary to determine the value of attributes:
|
||||
When evaluating the recipe inside the `application` resource, it first checks
|
||||
for `application_#{resource}`, as well as looking for an LWRP of the same name
|
||||
in any cookbook starting with `application_`. This means that a resource named
|
||||
`application_foo` can be used as `foo` inside the `application` resource:
|
||||
|
||||
```ruby
|
||||
application 'my_app' do
|
||||
repository 'http://git.example.com/my-app.git'
|
||||
revision node.chef_environment == 'production' ? 'production' : 'develop'
|
||||
application '/path/to/deploy' do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
|
||||
rails '/path/to/deploy' do
|
||||
database 'mysql://dbhost/myapp'
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
Attributes from the application and from sub-resources are merged together:
|
||||
Additionally if a resource inside the `application` block doesn't have a name,
|
||||
it uses the same name as the application resource itself:
|
||||
|
||||
```ruby
|
||||
application 'my_app' do
|
||||
restart_command 'kill -1 `cat /var/run/one.pid`'
|
||||
environment 'LC_ALL' => 'en', 'FOO' => 'bar'
|
||||
application '/path/to/deploy' do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
|
||||
rails do
|
||||
restart_command 'touch /tmp/something'
|
||||
environment 'LC_ALL' => 'en_US'
|
||||
end
|
||||
|
||||
passenger_apache2 do
|
||||
environment 'FOO' => 'baz'
|
||||
end
|
||||
end
|
||||
|
||||
# at the end, you will have:
|
||||
#
|
||||
# restart_command #=> kill -1 `cat /var/run/one.pid` && touch /tmp/something
|
||||
# environment #=> LC_ALL=en_US FOO=baz
|
||||
```
|
||||
|
||||
Most databases have the concept of migrations (or you can just use your own):
|
||||
|
||||
```ruby
|
||||
application 'my_app' do
|
||||
path '/deploy/to/dir'
|
||||
owner 'app-user'
|
||||
group 'app-group'
|
||||
|
||||
repository 'http://git.example.com/my-app.git'
|
||||
revision 'production'
|
||||
|
||||
php do
|
||||
migrate true
|
||||
migration_command 'your-applications-migrate-command'
|
||||
database 'mysql://dbhost/myapp'
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
This will run `your-applications-migrate-command`, with the current directory set to the directory of the current checkout.
|
||||
Other than those two special features, the recipe code inside the `application`
|
||||
resource is processed just like any other recipe.
|
||||
|
||||
To use the application cookbook, we recommend creating a role named after the application, e.g. `my_app`. Create a Ruby DSL role in your chef-repo, or create the role directly with knife.
|
||||
## Available Plugins
|
||||
|
||||
* [`application_git`](https://github.com/poise/application_git) – Deploy
|
||||
application code from a git repository.
|
||||
* [`application_ruby`](https://github.com/poise/application_ruby) – Manage Ruby
|
||||
deployments, such as Rails or Sinatra applications.
|
||||
* [`application_python`](https://github.com/poise/application_python) – Manage
|
||||
Python deployments, such as Django or Flask applications.
|
||||
* [`application_javascript`](https://github.com/poise/application_javascript) –
|
||||
Manage server-side JavaScript deployments using Node.js or io.js.
|
||||
* `application_java` – *Coming soon!*
|
||||
* `application_go` – *Coming soon!*
|
||||
* `application_erlang` – *Coming soon!*
|
||||
|
||||
## Requirements
|
||||
|
||||
Chef 12 or newer is required.
|
||||
|
||||
## Resources
|
||||
|
||||
### `application`
|
||||
|
||||
The `application` resource has top-level configuration properties for each
|
||||
deployment and acts as a container for other deployment plugin resources.
|
||||
|
||||
```ruby
|
||||
name 'my_app'
|
||||
description 'My application deployment'
|
||||
run_list([
|
||||
'recipe[my_app::default]'
|
||||
])
|
||||
application '/opt/test_sinatra' do
|
||||
git 'https://github.com/example/my_sinatra_app.git'
|
||||
bundle_install do
|
||||
deployment true
|
||||
end
|
||||
unicorn do
|
||||
port 9000
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
License and Authors
|
||||
-------------------
|
||||
- Author: Adam Jacob (<adam@opscode.com>)
|
||||
- Author: Andrea Campi (<andrea.campi@zephirworks.com.com>)
|
||||
- Author: Joshua Timberman (<joshua@opscode.com>)
|
||||
- Author: Noah Kantrowitz (<noah@opscode.com>)
|
||||
- Author: Seth Chisamore (<schisamo@opscode.com>)
|
||||
#### Actions
|
||||
|
||||
```text
|
||||
Copyright 2009-2013, Opscode, Inc.
|
||||
* `:deploy` – Deploy the application. *(default)*
|
||||
* `:start` - Run `:start` on all subresources that support it.
|
||||
* `:stop` - Run `:stop` on all subresources that support it.
|
||||
* `:restart` - Run `:restart` on all subresources that support it.
|
||||
* `:reload` - Run `:reload` on all subresources that support it.
|
||||
|
||||
#### Properties
|
||||
|
||||
* `path` – Path to deploy the application to. *(name attribute)*
|
||||
* `environment` – Environment variables for all application deployment steps.
|
||||
* `group` – System group to deploy the application as.
|
||||
* `owner` – System user to deploy the application as.
|
||||
* `action_on_update` – Action to run on the application resource when any
|
||||
subresource is updated. *(default: restart)*
|
||||
* `action_on_update_immediately` – Run the `action_on_update` notification with
|
||||
`:immediately`. *(default: false)*
|
||||
|
||||
### `application_cookbook_file`, `application_directory`, `application_file`, `application_template`
|
||||
|
||||
The `application_cookbook_file`, `application_directory`, `application_file`, and `application_template`
|
||||
resources extend the core Chef resources to take some application-level
|
||||
configuration in to account:
|
||||
|
||||
```ruby
|
||||
application '/opt/myapp' do
|
||||
template 'myapp.conf' do
|
||||
source 'myapp.conf.erb'
|
||||
end
|
||||
directory 'logs'
|
||||
end
|
||||
```
|
||||
|
||||
If the resource name is a relative path, it will be expanded relative to the
|
||||
application path. If an owner or group is declared for the application, those
|
||||
will be the default user and group for the resource.
|
||||
|
||||
All other actions and properties are the same as the similar resource in core Chef.
|
||||
|
||||
## Examples
|
||||
|
||||
Some test recipes are available as examples for common application frameworks:
|
||||
|
||||
* [Sinatra](https://github.com/poise/application_ruby/blob/master/test/cookbooks/application_ruby_test/recipes/sinatra.rb)
|
||||
* [Rails](https://github.com/poise/application_ruby/blob/master/test/cookbooks/application_ruby_test/recipes/rails.rb)
|
||||
* [Flask](https://github.com/poise/application_python/blob/master/test/cookbook/recipes/flask.rb)
|
||||
* [Django](https://github.com/poise/application_python/blob/master/test/cookbook/recipes/django.rb)
|
||||
* [Express](https://github.com/poise/application_javascript/blob/master/test/cookbook/recipes/express.rb)
|
||||
|
||||
## Upgrading From 4.x
|
||||
|
||||
While the overall design of the revamped application resource is similar to the
|
||||
4.x version, some changes will need to be made. The `name` property no longer
|
||||
exists, with the name attribute being used as the path to the deployment.
|
||||
The `packages` property has been removed as this is more easily handled via
|
||||
normal recipe code.
|
||||
|
||||
The SCM-related properties like `repository` and `revision` are now handled by
|
||||
normal plugins. If you were deploying from a private git repository you will
|
||||
likely want to use the `application_git` cookbook, otherwise just use the
|
||||
built-in `git` or `svn` resources as per normal.
|
||||
|
||||
The properties related to the `deploy` resource like `strategy` and `symlinks`
|
||||
have been removed. The `deploy` resource is no longer used so these aren't
|
||||
relevant. As a side effect of this, you'll likely want to point the upgraded
|
||||
deployment at a new folder or manually clean the `current` and `shared` folders
|
||||
from the existing folder. The pseudo-Capistrano layout used by the `deploy`
|
||||
resource has few benefits in a config-managed world and introduced a lot of
|
||||
complexity and moving pieces that are no longer required.
|
||||
|
||||
With the removal of the `deploy` resource, the callback properties and commands
|
||||
are no longer used as well. Subresources no longer use the complex
|
||||
actions-as-callbacks arrangement as existed before, instead following normal
|
||||
Chef recipe flow. Individual subresources may need to be tweaked to work with
|
||||
newer versions of the cookbooks they come from, though most have stayed similar
|
||||
in overall approach.
|
||||
|
||||
## Database Migrations and Chef
|
||||
|
||||
Several of the web application deployment plugins include optional support to
|
||||
run database migrations from Chef. For "toy" applications where the app and
|
||||
database run together on a single machine, this is fine and is a nice time
|
||||
saver. For anything more complex I highly recommend not running database
|
||||
migrations from Chef. Some initial operations like creating the database and/or
|
||||
database user are more reasonable as they tend to be done only once and by their
|
||||
nature the application does not yet have users so some level of eventual
|
||||
consistency is more acceptable. With migrations on a production application, I
|
||||
encourage using Chef and the application cookbooks to handle deploying the code
|
||||
and writing configuration files, but use something more specific to run the
|
||||
actual migration task. [Fabric](http://www.fabfile.org/),
|
||||
[Capistrano](http://capistranorb.com/), and [Rundeck](http://rundeck.org/) are
|
||||
all good choices for this orchestration tooling.
|
||||
|
||||
Migrations can generally be applied idempotently but they have unique
|
||||
constraints (pun definitely intended) that make them tricky in a Chef-like,
|
||||
convergence-based system. First and foremost is that many table alterations
|
||||
lock the table for updating for at least some period of time. That can mean that
|
||||
while staging the new code or configuration data can happen within a window, the
|
||||
migration itself needs to be run in careful lockstep with the rest of the
|
||||
deployment process (eg. moving things in and out of load balancers). Beyond
|
||||
that, while most web frameworks have internal idempotence checks for migrations,
|
||||
running the process on two servers at the same time can have unexpected effects.
|
||||
|
||||
Overall migrations are best thought of as a procedural step rather than a
|
||||
declaratively modeled piece of the system.
|
||||
|
||||
## Application Signals and Updates
|
||||
|
||||
The `application` resource exposes `start`, `stop`, `restart`, and `reload`
|
||||
actions which will dispatch to any subresources attached to the application.
|
||||
This allows for generic application-level restart or reload signals that will
|
||||
work with any type of deployment.
|
||||
|
||||
Additionally the `action_on_update` property is used to set a default
|
||||
notification so any subresource that updates will trigger an application
|
||||
restart or reload. This can be disabled by setting `action_on_update false` if
|
||||
you want to take manual control of service restarts.
|
||||
|
||||
## Sponsors
|
||||
|
||||
Development sponsored by [Chef Software](https://www.chef.io/), [Symonds & Son](http://symondsandson.com/), and [Orion](https://www.orionlabs.co/).
|
||||
|
||||
The Poise test server infrastructure is sponsored by [Rackspace](https://rackspace.com/).
|
||||
|
||||
## License
|
||||
|
||||
Copyright 2015-2016, Noah Kantrowitz
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
```
|
||||
|
25
cookbooks/application/files/halite_gem/poise_application.rb
Normal file
25
cookbooks/application/files/halite_gem/poise_application.rb
Normal file
@ -0,0 +1,25 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
|
||||
module PoiseApplication
|
||||
autoload :AppMixin, 'poise_application/app_mixin'
|
||||
autoload :Error, 'poise_application/error'
|
||||
autoload :Resources, 'poise_application/resources'
|
||||
autoload :ServiceMixin, 'poise_application/service_mixin'
|
||||
autoload :Utils, 'poise_application/utils'
|
||||
autoload :VERSION, 'poise_application/version'
|
||||
end
|
@ -0,0 +1,64 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise/utils'
|
||||
|
||||
require 'poise_application/app_mixin'
|
||||
|
||||
|
||||
module PoiseApplication
|
||||
# A helper mixin for `file`-like resources to make them take application
|
||||
# resource data. Relative paths are expanded against the application path and
|
||||
# the app owner/group are the default user/group for the resource.
|
||||
#
|
||||
# @api private
|
||||
# @since 5.1.0
|
||||
module AppFileMixin
|
||||
include Poise::Utils::ResourceProviderMixin
|
||||
|
||||
module Resource
|
||||
include PoiseApplication::AppMixin
|
||||
|
||||
def initialize(*)
|
||||
super
|
||||
# So our lazy default below can work. Not needed on 12.7+.
|
||||
remove_instance_variable(:@path) if instance_variable_defined?(:@path)
|
||||
end
|
||||
|
||||
# @!attribute path
|
||||
# Override the default path to be relative to the app path.
|
||||
# @return [String]
|
||||
attribute(:path, kind_of: String, default: lazy { parent ? ::File.expand_path(name, parent.path) : name })
|
||||
|
||||
# @!attribute group
|
||||
# Override the default group to be the app group if unspecified.
|
||||
# @return [String, Integer]
|
||||
attribute(:group, kind_of: [String, Integer, NilClass], default: lazy { parent && parent.group })
|
||||
|
||||
# @!attribute owner
|
||||
# Override the default user to be the app owner if unspecified.
|
||||
# @return [String, Integer]
|
||||
attribute(:owner, kind_of: [String, Integer, NilClass], default: lazy { parent && parent.owner })
|
||||
|
||||
# For the forgetful.
|
||||
alias_method :user, :owner
|
||||
end
|
||||
|
||||
module Provider
|
||||
include PoiseApplication::AppMixin
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,69 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'chef/mash'
|
||||
require 'poise/provider'
|
||||
require 'poise/resource'
|
||||
require 'poise/utils'
|
||||
|
||||
|
||||
module PoiseApplication
|
||||
# A helper mixin for application resources and providers. These are things
|
||||
# intended to be used as subresources of the `application` resource.
|
||||
#
|
||||
# @since 5.0.0
|
||||
module AppMixin
|
||||
include Poise::Utils::ResourceProviderMixin
|
||||
|
||||
# A helper mixin for application resources.
|
||||
module Resource
|
||||
include Poise::Resource
|
||||
|
||||
# Set the parent type and optional flag.
|
||||
poise_subresource(:application, true)
|
||||
|
||||
# @!attribute path
|
||||
# Base path for the application.
|
||||
# @return [String]
|
||||
attribute(:path, kind_of: String, name_attribute: true)
|
||||
|
||||
# A delegator for accessing the application state. If no application
|
||||
# parent is found, the state will be tracked internally within the
|
||||
# resource.
|
||||
#
|
||||
# @return [Hash<Symbol, Object>]
|
||||
def app_state
|
||||
if parent
|
||||
parent.app_state
|
||||
else
|
||||
# If there isn't a parent, just track within the resource.
|
||||
@local_app_state ||= Mash.new
|
||||
end
|
||||
end
|
||||
|
||||
# Environment variables stored in the application state.
|
||||
#
|
||||
# @return [Hash<String, String>]
|
||||
def app_state_environment
|
||||
app_state[:environment] ||= Mash.new
|
||||
end
|
||||
end
|
||||
|
||||
module Provider
|
||||
include Poise::Provider
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,17 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_application/resources'
|
@ -0,0 +1,24 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
|
||||
module PoiseApplication
|
||||
# Base exception class for poise-application errors.
|
||||
#
|
||||
# @since 5.0.0
|
||||
class Error < Exception
|
||||
end
|
||||
end
|
@ -0,0 +1,30 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_application/resources/application'
|
||||
require 'poise_application/resources/application_cookbook_file'
|
||||
require 'poise_application/resources/application_directory'
|
||||
require 'poise_application/resources/application_file'
|
||||
require 'poise_application/resources/application_template'
|
||||
|
||||
|
||||
module PoiseApplication
|
||||
# Chef resources and providers for poise-application.
|
||||
#
|
||||
# @since 5.0.0
|
||||
module Resources
|
||||
end
|
||||
end
|
@ -0,0 +1,259 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'chef/dsl/recipe' # On 12.4+ this will pull in chef/dsl/resources.
|
||||
require 'chef/resource'
|
||||
require 'chef/provider'
|
||||
require 'poise'
|
||||
|
||||
|
||||
module PoiseApplication
|
||||
module Resources
|
||||
# (see Application::Resource)
|
||||
# @since 5.0.0
|
||||
module Application
|
||||
# An `application` resource to manage application deployment.
|
||||
#
|
||||
# @since 5.0.0
|
||||
# @provides application
|
||||
# @action deploy
|
||||
# @action start
|
||||
# @action stop
|
||||
# @action restart
|
||||
# @action reload
|
||||
# @example
|
||||
# application '/srv/myapp' do
|
||||
# git '...'
|
||||
# poise_service 'myapp' do
|
||||
# command '/srv/myapp/main'
|
||||
# end
|
||||
# end
|
||||
class Resource < Chef::Resource
|
||||
include Poise(container: true, container_namespace: false)
|
||||
provides(:application)
|
||||
actions(:deploy, :start, :stop, :restart, :reload)
|
||||
|
||||
# @!attribute path
|
||||
# Application base path.
|
||||
# @return [String]
|
||||
attribute(:path, kind_of: String, name_attribute: true)
|
||||
# @!attribute environment
|
||||
# Environment variables to set for the whole application.
|
||||
# @return [Hash<String, String>]
|
||||
attribute(:environment, kind_of: Hash, default: lazy { Mash.new })
|
||||
# @!attribute owner
|
||||
# System user that will own the application. This can be overriden in
|
||||
# individual subresources.
|
||||
# @return [String]
|
||||
attribute(:owner, kind_of: String)
|
||||
# @!attribute group
|
||||
# System group that will own the application. This can be overriden in
|
||||
# individual subresources.
|
||||
# @return [String]
|
||||
attribute(:group, kind_of: String)
|
||||
# @!attribute action_on_update
|
||||
# Action to run when any subresource is updated. Defaults to `:restart`.
|
||||
# @return [String, Symbol, nil, false]
|
||||
attribute(:action_on_update, kind_of: [Symbol, String, NilClass, FalseClass], default: :restart)
|
||||
# @!attribute action_on_update_immediately
|
||||
# Run the {#action_on_update} notification with `:immediately`.
|
||||
# @return [Boolean]
|
||||
attribute(:action_on_update_immediately, equal_to: [true, false], default: false)
|
||||
|
||||
# Run the DSL rewire when the resource object is created.
|
||||
# @api private
|
||||
def initialize(*args)
|
||||
super
|
||||
_rewire_dsl! if node
|
||||
end
|
||||
|
||||
# Application-specific state values used as a way to communicate between
|
||||
# subresources.
|
||||
#
|
||||
# @return [Mash]
|
||||
# @example
|
||||
# if new_resource.parent && new_resource.parent.app_state['gemfile_path']
|
||||
def app_state
|
||||
@app_state ||= Mash.new(environment: environment)
|
||||
end
|
||||
|
||||
# Override Container#register_subresource to add our action_on_update.
|
||||
#
|
||||
# @api private
|
||||
def register_subresource(resource)
|
||||
super.tap do |added|
|
||||
if added && action_on_update
|
||||
Chef::Log.debug("[#{self}] Registering #{action_on_update_immediately ? 'immediate ' : ''}#{action_on_update} notification from #{resource}")
|
||||
resource.notifies action_on_update.to_sym, self, (action_on_update_immediately ? :immediately : :delayed)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Find all resources that need to be rewired. This is anything with a
|
||||
# name starting with application_.
|
||||
#
|
||||
# @return [Array<String>]
|
||||
def _rewire_resources
|
||||
if defined?(Chef::DSL::Resources)
|
||||
# Chef >= 12.4.
|
||||
Chef::DSL::Resources.instance_methods
|
||||
else
|
||||
# Chef < 12.4 >= 12.0.
|
||||
Chef::Resource.descendants.map do |klass|
|
||||
klass.node_map.instance_variable_get(:@map).keys + if klass.dsl_name.include?('::')
|
||||
# Probably not valid.
|
||||
# :nocov:
|
||||
[]
|
||||
# :nocov:
|
||||
else
|
||||
# Needed for things that don't call provides().
|
||||
[klass.dsl_name]
|
||||
end
|
||||
end.flatten
|
||||
end.map {|name| name.to_s }.select {|name| name.start_with?('application_') }.uniq
|
||||
end
|
||||
|
||||
# Find all cookbooks that might contain LWRPs matching our name scheme.
|
||||
#
|
||||
# @return [Array<String>]
|
||||
def _rewire_cookbooks
|
||||
# Run context might be unset during test setup.
|
||||
if run_context
|
||||
run_context.cookbook_collection.keys.select {|cookbook_name| cookbook_name.start_with?('application_') }
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
# Build the mapping of new_name => old_name for each resource to rewire.
|
||||
#
|
||||
# @return [Hash<String, String>]
|
||||
def _rewire_map
|
||||
application_cookbooks = _rewire_cookbooks
|
||||
_rewire_resources.inject({}) do |memo, name|
|
||||
# Grab the resource class to check if it is an LWRP.
|
||||
klass = Chef::Resource.resource_for_node(name.to_sym, node)
|
||||
# Find the part to trim. Check for LWRP first, then just application_.
|
||||
trim = if klass < Chef::Resource::LWRPBase
|
||||
application_cookbooks.find {|cookbook_name| name.start_with?(cookbook_name) && name != cookbook_name } || 'application'
|
||||
else
|
||||
# Non-LWRPs are assumed to have a better name.
|
||||
'application'
|
||||
end
|
||||
# Map trimmed to untrimmed.
|
||||
memo[name[trim.length+1..-1]] = name
|
||||
memo
|
||||
end
|
||||
end
|
||||
|
||||
# Build new DSL methods to implement the foo -> application_foo behavior.
|
||||
#
|
||||
# @return [void]
|
||||
def _rewire_dsl!
|
||||
# Generate stub methods for all the rewiring.
|
||||
_rewire_map.each do |new_name, old_name|
|
||||
# This is defined as a singleton method on self so it looks like
|
||||
# the DSL but is scoped to just this context.
|
||||
define_singleton_method(new_name) do |name=nil, *args, &block|
|
||||
# Store the caller to correct the source_line.
|
||||
created_at = caller[0]
|
||||
public_send(old_name, name, *args) do
|
||||
# Set the declared type to be the native name.
|
||||
self.declared_type = self.class.resource_name
|
||||
# Fix the source location. For Chef 12.4 we could do this with the
|
||||
# declared_at parameter on the initial send.
|
||||
self.source_line = created_at
|
||||
# Run the original block.
|
||||
instance_exec(&block) if block
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Provider for `application`.
|
||||
#
|
||||
# @since 5.0.0
|
||||
# @see Resource
|
||||
# @provides application
|
||||
class Provider < Chef::Provider
|
||||
include Poise
|
||||
provides(:application)
|
||||
|
||||
# `deploy` action for `application`. Creates the application base folder.
|
||||
#
|
||||
# @return [void]
|
||||
def action_deploy
|
||||
notifying_block do
|
||||
directory new_resource.path do
|
||||
owner new_resource.owner
|
||||
group new_resource.group
|
||||
mode '755'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# `start` action for `application`. Proxies to subresources.
|
||||
#
|
||||
# @return [void]
|
||||
def action_start
|
||||
proxy_action(:start)
|
||||
end
|
||||
|
||||
# `stop` action for `application`. Proxies to subresources.
|
||||
#
|
||||
# @return [void]
|
||||
def action_stop
|
||||
proxy_action(:stop)
|
||||
end
|
||||
|
||||
# `restart` action for `application`. Proxies to subresources.
|
||||
#
|
||||
# @return [void]
|
||||
def action_restart
|
||||
proxy_action(:restart)
|
||||
end
|
||||
|
||||
# `reload` action for `application`. Proxies to subresources.
|
||||
#
|
||||
# @return [void]
|
||||
def action_reload
|
||||
proxy_action(:reload)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Proxy an action to any subresources that support it.
|
||||
#
|
||||
# @param action [Symbol] Action to proxy.
|
||||
# @return [void]
|
||||
def proxy_action(action)
|
||||
Chef::Log.debug("[#{new_resource} Running proxied #{action} action")
|
||||
new_resource.subresources.each do |r|
|
||||
begin
|
||||
r.run_action(action) if r.allowed_actions.include?(action)
|
||||
rescue Chef::Exceptions::UnsupportedAction
|
||||
# Don't care, just move on.
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,54 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_application/app_file_mixin'
|
||||
|
||||
|
||||
module PoiseApplication
|
||||
module Resources
|
||||
# (see ApplicationCookbookFile::Resource)
|
||||
# @since 5.1.0
|
||||
module ApplicationCookbookFile
|
||||
# An `application_cookbook_file` resource to manage Chef cookbook_files inside and
|
||||
# Application cookbook deployment.
|
||||
#
|
||||
# @provides application_cookbook_file
|
||||
# @action create
|
||||
# @action create_if_missing
|
||||
# @action delete
|
||||
# @action touch
|
||||
# @example
|
||||
# application '/srv/myapp' do
|
||||
# cookbook_file 'myapp.conf' do
|
||||
# source 'myapp.conf'
|
||||
# end
|
||||
# end
|
||||
class Resource < Chef::Resource::CookbookFile
|
||||
include PoiseApplication::AppFileMixin
|
||||
provides(:application_cookbook_file)
|
||||
actions(:create, :create_if_missing, :delete, :touch)
|
||||
subclass_providers!
|
||||
|
||||
def initialize(*args)
|
||||
super
|
||||
# For older Chef.
|
||||
@resource_name = :application_cookbook_file
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,50 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_application/app_file_mixin'
|
||||
|
||||
|
||||
module PoiseApplication
|
||||
module Resources
|
||||
# (see ApplicationDirectory::Resource)
|
||||
# @since 5.1.0
|
||||
module ApplicationDirectory
|
||||
# An `application_directory` resource to manage Chef files inside and
|
||||
# Application cookbook deployment.
|
||||
#
|
||||
# @provides application_directory
|
||||
# @action create
|
||||
# @action delete
|
||||
# @example
|
||||
# application '/srv/myapp' do
|
||||
# directory 'logs'
|
||||
# end
|
||||
class Resource < Chef::Resource::Directory
|
||||
include PoiseApplication::AppFileMixin
|
||||
provides(:application_directory)
|
||||
actions(:create, :delete)
|
||||
subclass_providers!
|
||||
|
||||
def initialize(*args)
|
||||
super
|
||||
# For older Chef.
|
||||
@resource_name = :application_directory
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,54 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_application/app_file_mixin'
|
||||
|
||||
|
||||
module PoiseApplication
|
||||
module Resources
|
||||
# (see ApplicationFile::Resource)
|
||||
# @since 5.1.0
|
||||
module ApplicationFile
|
||||
# An `application_file` resource to manage Chef files inside and
|
||||
# Application cookbook deployment.
|
||||
#
|
||||
# @provides application_file
|
||||
# @action create
|
||||
# @action create_if_missing
|
||||
# @action delete
|
||||
# @action touch
|
||||
# @example
|
||||
# application '/srv/myapp' do
|
||||
# file 'myapp.conf' do
|
||||
# source 'myapp.conf.erb'
|
||||
# end
|
||||
# end
|
||||
class Resource < Chef::Resource::File
|
||||
include PoiseApplication::AppFileMixin
|
||||
provides(:application_file)
|
||||
actions(:create, :create_if_missing, :delete, :touch)
|
||||
subclass_providers!
|
||||
|
||||
def initialize(*args)
|
||||
super
|
||||
# For older Chef.
|
||||
@resource_name = :application_file
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,54 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_application/app_file_mixin'
|
||||
|
||||
|
||||
module PoiseApplication
|
||||
module Resources
|
||||
# (see ApplicationTemplate::Resource)
|
||||
# @since 5.1.0
|
||||
module ApplicationTemplate
|
||||
# An `application_template` resource to manage Chef templates inside and
|
||||
# Application cookbook deployment.
|
||||
#
|
||||
# @provides application_template
|
||||
# @action create
|
||||
# @action create_if_missing
|
||||
# @action delete
|
||||
# @action touch
|
||||
# @example
|
||||
# application '/srv/myapp' do
|
||||
# template 'myapp.conf' do
|
||||
# source 'myapp.conf.erb'
|
||||
# end
|
||||
# end
|
||||
class Resource < Chef::Resource::Template
|
||||
include PoiseApplication::AppFileMixin
|
||||
provides(:application_template)
|
||||
actions(:create, :create_if_missing, :delete, :touch)
|
||||
subclass_providers!
|
||||
|
||||
def initialize(*args)
|
||||
super
|
||||
# For older Chef.
|
||||
@resource_name = :application_template
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,116 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'chef/resource'
|
||||
require 'chef/provider'
|
||||
require 'poise/utils'
|
||||
require 'poise_service/service_mixin'
|
||||
require 'poise_service/utils'
|
||||
|
||||
require 'poise_application/app_mixin'
|
||||
require 'poise_application/utils'
|
||||
|
||||
|
||||
module PoiseApplication
|
||||
# Mixin for application services. This is any resource that will be part of
|
||||
# an application deployment and involves running a persistent service.
|
||||
#
|
||||
# @api public
|
||||
# @since 5.0.0
|
||||
# @example
|
||||
# module MyApp
|
||||
# class Resource < Chef::Resource
|
||||
# include Poise
|
||||
# provides(:my_app)
|
||||
# include PoiseApplication::ServiceMixin
|
||||
# end
|
||||
#
|
||||
# class Provider < Chef::Provider
|
||||
# include Poise
|
||||
# provides(:my_app)
|
||||
# include PoiseApplication::ServiceMixin
|
||||
#
|
||||
# def action_enable
|
||||
# notifying_block do
|
||||
# template '/etc/myapp.conf' do
|
||||
# # ...
|
||||
# end
|
||||
# end
|
||||
# super
|
||||
# end
|
||||
#
|
||||
# def service_options(r)
|
||||
# super
|
||||
# r.command('myapp --serve')
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
module ServiceMixin
|
||||
include Poise::Utils::ResourceProviderMixin
|
||||
|
||||
# Mixin for application service resources.
|
||||
#
|
||||
# @see ServiceMixin
|
||||
module Resource
|
||||
include PoiseService::ServiceMixin::Resource
|
||||
include PoiseApplication::AppMixin::Resource
|
||||
|
||||
module ClassMethods
|
||||
# @api private
|
||||
def included(klass)
|
||||
super
|
||||
klass.extend(ClassMethods)
|
||||
klass.class_exec do
|
||||
attribute(:path, kind_of: String, name_attribute: true)
|
||||
# Redefines from the PoiseService version so we get a better default.
|
||||
attribute(:service_name, kind_of: String, default: lazy { PoiseService::Utils.parse_service_name(path) })
|
||||
attribute(:user, kind_of: [String, Integer], default: lazy { parent ? parent.owner : 'root' })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
extend ClassMethods
|
||||
end
|
||||
|
||||
# Mixin for application service providers.
|
||||
#
|
||||
# @see ServiceMixin
|
||||
module Provider
|
||||
include PoiseService::ServiceMixin::Provider
|
||||
include PoiseApplication::AppMixin::Provider
|
||||
|
||||
private
|
||||
|
||||
# Abstract hook to set parameters on {#service_resource} when it is
|
||||
# created. This is required to set at least `resource.command`.
|
||||
#
|
||||
# @api public
|
||||
# @param resource [Chef::Resource] Resource instance to set parameters on.
|
||||
# @return [void]
|
||||
# @example
|
||||
# def service_options(resource)
|
||||
# super
|
||||
# resource.command('myapp --serve')
|
||||
# end
|
||||
def service_options(resource)
|
||||
super
|
||||
resource.directory(new_resource.path)
|
||||
resource.user(new_resource.user)
|
||||
resource.environment.update(new_resource.app_state_environment) if new_resource.parent
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,51 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'etc'
|
||||
|
||||
|
||||
module PoiseApplication
|
||||
# Utility methods for PoiseApplication.
|
||||
#
|
||||
# @api public
|
||||
# @since 5.0.0
|
||||
module Utils
|
||||
# Methods are also available as module-level methods as well as a mixin.
|
||||
extend self
|
||||
|
||||
# Try to find the primary group name for a given user.
|
||||
#
|
||||
# @param user [String, Integer] User to check, if given as an integer this
|
||||
# is used as a UID, otherwise it is the username.
|
||||
# @return [String]
|
||||
# @example
|
||||
# attribute(:group, kind_of: [String, Integer], default: lazy { PoiseApplication::Utils.primary_group_for(user) })
|
||||
def primary_group_for(user)
|
||||
# Force a reload in case any users were created earlier in the run.
|
||||
Etc.endpwent
|
||||
Etc.endgrent
|
||||
user = if user.is_a?(Integer)
|
||||
Etc.getpwuid(user)
|
||||
else
|
||||
Etc.getpwnam(user.to_s)
|
||||
end
|
||||
Etc.getgrgid(user.gid).name
|
||||
rescue ArgumentError
|
||||
# One of the get* calls exploded. ¯\_(ツ)_/¯
|
||||
user.to_s
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,20 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
|
||||
module PoiseApplication
|
||||
VERSION = '5.2.0'
|
||||
end
|
@ -1,9 +1,5 @@
|
||||
#
|
||||
# Author:: Noah Kantrowitz <noah@opscode.com>
|
||||
# Cookbook Name:: application
|
||||
# Library:: default
|
||||
#
|
||||
# Copyright:: 2011-2012, Opscode, Inc <legal@opscode.com>
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@ -18,172 +14,6 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require "chef/mixin/from_file"
|
||||
|
||||
class Chef
|
||||
class Resource
|
||||
# Monkey-Patch the blacklists to prevent infinite recursion in #to_json and similar
|
||||
# (this is global state,thus the set-union operator to change it idempotently + to not leak)
|
||||
[ :@application, :@application_provider ].each do |ivar|
|
||||
FORBIDDEN_IVARS << ivar unless FORBIDDEN_IVARS.include?(ivar)
|
||||
HIDDEN_IVARS << ivar unless HIDDEN_IVARS.include?(ivar)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class ApplicationCookbook
|
||||
|
||||
module OptionsCollector
|
||||
def options
|
||||
@options ||= {}
|
||||
end
|
||||
|
||||
def method_missing(method_sym, value=nil, &block)
|
||||
super
|
||||
rescue NameError
|
||||
value ||= block
|
||||
method_sym = method_sym.to_s.chomp('=').to_sym
|
||||
options[method_sym] = value if value
|
||||
options[method_sym] ||= nil
|
||||
end
|
||||
end
|
||||
|
||||
module ResourceBase
|
||||
def self.included(klass)
|
||||
klass.actions :before_compile, :before_deploy, :before_migrate, :before_symlink, :before_restart, :after_restart
|
||||
klass.attribute :id, :kind_of => String, :name_attribute => true
|
||||
klass.attribute :environment, :kind_of => Hash, :default => {}
|
||||
klass.attribute :purge_before_symlink, :kind_of => Array, :default => []
|
||||
klass.attribute :create_dirs_before_symlink, :kind_of => Array, :default => []
|
||||
klass.attribute :symlinks, :kind_of => Hash, :default => {}
|
||||
klass.attribute :symlink_before_migrate, :kind_of => Hash, :default => {}
|
||||
klass.attribute :migration_command, :kind_of => [String, NilClass], :default => nil
|
||||
klass.attribute :application
|
||||
klass.attribute :application_provider
|
||||
klass.attribute :type
|
||||
end
|
||||
|
||||
def restart_command(arg=nil, &block)
|
||||
arg ||= block
|
||||
raise "Invalid restart command" unless !arg || arg.is_a?(String) || arg.is_a?(Proc)
|
||||
@restart_command = arg if arg
|
||||
@restart_command
|
||||
end
|
||||
|
||||
def method_missing(name, *args)
|
||||
if application.respond_to? name
|
||||
application.send(name, *args)
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
class OptionsBlock
|
||||
include ApplicationCookbook::OptionsCollector
|
||||
end
|
||||
|
||||
def options_block(options=nil, &block)
|
||||
options ||= {}
|
||||
if block
|
||||
collector = OptionsBlock.new
|
||||
collector.instance_eval(&block)
|
||||
options.update(collector.options)
|
||||
end
|
||||
options
|
||||
end
|
||||
|
||||
def find_matching_role(role, single=true, &block)
|
||||
return nil if !role
|
||||
nodes = []
|
||||
if node['roles'].include? role
|
||||
nodes << node
|
||||
end
|
||||
if !single || nodes.empty?
|
||||
search(:node, "role:#{role} AND chef_environment:#{node.chef_environment}") do |n|
|
||||
nodes << n
|
||||
end
|
||||
end
|
||||
if block
|
||||
nodes.each do |n|
|
||||
yield n
|
||||
end
|
||||
else
|
||||
if single
|
||||
nodes.first
|
||||
else
|
||||
nodes
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def find_database_server(role)
|
||||
dbm = find_matching_role(role)
|
||||
Chef::Log.warn("No node with role #{role}") if role && !dbm
|
||||
|
||||
if respond_to?(:database) && database.has_key?('host')
|
||||
database['host']
|
||||
elsif dbm && dbm.attribute?('cloud')
|
||||
dbm['cloud']['local_ipv4']
|
||||
elsif dbm
|
||||
dbm['ipaddress']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module ProviderBase
|
||||
|
||||
def self.included(klass)
|
||||
klass.send(:include, Chef::Mixin::FromFile)
|
||||
end
|
||||
|
||||
def deploy_provider
|
||||
@deploy_provider ||= begin
|
||||
provider = @deploy_resource.provider_for_action(:nothing)
|
||||
provider.load_current_resource
|
||||
provider
|
||||
end
|
||||
end
|
||||
|
||||
def release_path
|
||||
deploy_provider.release_path
|
||||
end
|
||||
|
||||
def shared_path
|
||||
@deploy_resource.shared_path
|
||||
end
|
||||
|
||||
def callback(what, callback_code=nil)
|
||||
Chef::Log.debug("Got callback #{what}: #{callback_code.inspect}")
|
||||
@collection = Chef::ResourceCollection.new
|
||||
case callback_code
|
||||
when Proc
|
||||
Chef::Log.info "#{@new_resource} running callback #{what}"
|
||||
safe_recipe_eval(&callback_code)
|
||||
when String
|
||||
callback_file = "#{release_path}/#{callback_code}"
|
||||
unless ::File.exist?(callback_file)
|
||||
raise RuntimeError, "Can't find your callback file #{callback_file}"
|
||||
end
|
||||
run_callback_from_file(callback_file)
|
||||
when nil
|
||||
nil
|
||||
else
|
||||
raise RuntimeError, "You gave me a callback I don't know what to do with: #{callback_code.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
def run_callback_from_file(callback_file)
|
||||
if ::File.exist?(callback_file)
|
||||
Dir.chdir(release_path) do
|
||||
Chef::Log.info "#{@new_resource} running deploy hook #{callback_file}"
|
||||
safe_recipe_eval { from_file(callback_file) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def safe_recipe_eval(&callback_code)
|
||||
recipe_eval(&callback_code)
|
||||
converge if respond_to?(:converge)
|
||||
end
|
||||
end
|
||||
end
|
||||
raise 'Halite is not compatible with no_lazy_load false, please set no_lazy_load true in your Chef configuration file.' unless Chef::Config[:no_lazy_load]
|
||||
$LOAD_PATH << File.expand_path('../../files/halite_gem', __FILE__)
|
||||
require "poise_application/cheftie"
|
||||
|
@ -1,11 +0,0 @@
|
||||
if defined?(ChefSpec)
|
||||
|
||||
def deploy_application(resource)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:application, :deploy, resource)
|
||||
end
|
||||
|
||||
def force_deploy_application(resource)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:application, :force_deploy, resource)
|
||||
end
|
||||
|
||||
end
|
File diff suppressed because one or more lines are too long
@ -1,191 +0,0 @@
|
||||
#
|
||||
# Author:: Noah Kantrowitz <noah@opscode.com>
|
||||
# Cookbook Name:: application
|
||||
# Provider:: default
|
||||
#
|
||||
# Copyright:: 2011-2012, Opscode, Inc <legal@opscode.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include ApplicationCookbook::ProviderBase
|
||||
|
||||
action :deploy do
|
||||
|
||||
before_compile
|
||||
|
||||
before_deploy
|
||||
|
||||
run_deploy
|
||||
|
||||
end
|
||||
|
||||
action :force_deploy do
|
||||
|
||||
before_compile
|
||||
|
||||
before_deploy
|
||||
|
||||
run_deploy(true)
|
||||
|
||||
end
|
||||
|
||||
action :restart do
|
||||
|
||||
before_compile
|
||||
|
||||
run_actions_with_context(:before_restart, @run_context)
|
||||
|
||||
run_restart
|
||||
|
||||
run_actions_with_context(:after_restart, @run_context)
|
||||
|
||||
@new_resource.updated_by_last_action(true)
|
||||
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def before_compile
|
||||
new_resource.application_provider self
|
||||
new_resource.sub_resources.each do |resource|
|
||||
resource.application_provider self
|
||||
resource.run_action :before_compile
|
||||
end
|
||||
end
|
||||
|
||||
def before_deploy
|
||||
new_resource.packages.each do |pkg,ver|
|
||||
package pkg do
|
||||
action :install
|
||||
version ver if ver && ver.length > 0
|
||||
end
|
||||
end
|
||||
|
||||
directory new_resource.path do
|
||||
owner new_resource.owner
|
||||
group new_resource.group
|
||||
mode '0755'
|
||||
recursive true
|
||||
end
|
||||
|
||||
directory "#{new_resource.path}/shared" do
|
||||
owner new_resource.owner
|
||||
group new_resource.group
|
||||
mode '0755'
|
||||
recursive true
|
||||
end
|
||||
|
||||
if new_resource.deploy_key
|
||||
|
||||
if ::File.exists?(new_resource.deploy_key)
|
||||
deploy_key = open(new_resource.deploy_key, &:read)
|
||||
else
|
||||
deploy_key = new_resource.deploy_key
|
||||
end
|
||||
|
||||
file "#{new_resource.path}/id_deploy" do
|
||||
content deploy_key
|
||||
owner new_resource.owner
|
||||
group new_resource.group
|
||||
mode '0600'
|
||||
end
|
||||
|
||||
template "#{new_resource.path}/deploy-ssh-wrapper" do
|
||||
source "deploy-ssh-wrapper.erb"
|
||||
cookbook "application"
|
||||
owner new_resource.owner
|
||||
group new_resource.group
|
||||
mode "0755"
|
||||
variables :id => new_resource.name, :deploy_to => new_resource.path, :strict_ssh => new_resource.strict_ssh
|
||||
end
|
||||
end
|
||||
|
||||
ruby_block "#{new_resource.name} before_deploy" do
|
||||
block do
|
||||
new_resource.sub_resources.each do |resource|
|
||||
resource.run_action :before_deploy
|
||||
end
|
||||
callback(:before_deploy, new_resource.before_deploy)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def run_deploy(force = false)
|
||||
# Alias to a variable so I can use in sub-resources
|
||||
new_resource = @new_resource
|
||||
# Also alias to variable so it can be used in sub-resources
|
||||
app_provider = self
|
||||
|
||||
@deploy_resource = send(new_resource.strategy.to_sym, new_resource.name) do
|
||||
action force ? :force_deploy : :deploy
|
||||
scm_provider new_resource.scm_provider
|
||||
revision new_resource.revision
|
||||
repository new_resource.repository
|
||||
enable_submodules new_resource.enable_submodules
|
||||
user new_resource.owner
|
||||
group new_resource.group
|
||||
keep_releases new_resource.keep_releases
|
||||
deploy_to new_resource.path
|
||||
ssh_wrapper "#{new_resource.path}/deploy-ssh-wrapper" if new_resource.deploy_key
|
||||
shallow_clone new_resource.shallow_clone
|
||||
rollback_on_error new_resource.rollback_on_error
|
||||
all_environments = ([new_resource.environment]+new_resource.sub_resources.map{|res| res.environment}).inject({}){|acc, val| acc.merge(val)}
|
||||
environment all_environments
|
||||
migrate new_resource.migrate
|
||||
all_migration_commands = ([new_resource.migration_command]+new_resource.sub_resources.map{|res| res.migration_command}).select{|cmd| cmd && !cmd.empty?}
|
||||
migration_command all_migration_commands.join(' && ')
|
||||
restart_command do
|
||||
([new_resource]+new_resource.sub_resources).each do |res|
|
||||
cmd = res.restart_command
|
||||
if cmd.is_a? Proc
|
||||
app_provider.deploy_provider.instance_eval(&cmd) # @see libraries/default.rb
|
||||
elsif cmd && !cmd.empty?
|
||||
execute cmd do
|
||||
user new_resource.owner
|
||||
group new_resource.group
|
||||
environment all_environments
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
purge_before_symlink (new_resource.purge_before_symlink + new_resource.sub_resources.map(&:purge_before_symlink)).flatten
|
||||
create_dirs_before_symlink (new_resource.create_dirs_before_symlink + new_resource.sub_resources.map(&:create_dirs_before_symlink)).flatten
|
||||
all_symlinks = [new_resource.symlinks]+new_resource.sub_resources.map{|res| res.symlinks}
|
||||
symlinks all_symlinks.inject({}){|acc, val| acc.merge(val)}
|
||||
all_symlinks_before_migrate = [new_resource.symlink_before_migrate]+new_resource.sub_resources.map{|res| res.symlink_before_migrate}
|
||||
symlink_before_migrate all_symlinks_before_migrate.inject({}){|acc, val| acc.merge(val)}
|
||||
before_migrate do
|
||||
app_provider.send(:run_actions_with_context, :before_migrate, @run_context)
|
||||
end
|
||||
before_symlink do
|
||||
app_provider.send(:run_actions_with_context, :before_symlink, @run_context)
|
||||
end
|
||||
before_restart do
|
||||
app_provider.send(:run_actions_with_context, :before_restart, @run_context)
|
||||
end
|
||||
after_restart do
|
||||
app_provider.send(:run_actions_with_context, :after_restart, @run_context)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def run_actions_with_context(action, context)
|
||||
new_resource.sub_resources.each do |resource|
|
||||
saved_run_context = resource.instance_variable_get :@run_context
|
||||
resource.instance_variable_set :@run_context, context
|
||||
resource.run_action action
|
||||
resource.instance_variable_set :@run_context, saved_run_context
|
||||
end
|
||||
callback(action, new_resource.send(action))
|
||||
end
|
@ -1,178 +0,0 @@
|
||||
#
|
||||
# Author:: Noah Kantrowitz <noah@opscode.com>
|
||||
# Cookbook Name:: application
|
||||
# Resource:: default
|
||||
#
|
||||
# Copyright:: 2011-2012, Opscode, Inc <legal@opscode.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'weakref'
|
||||
|
||||
include Chef::DSL::Recipe
|
||||
|
||||
def initialize(*args)
|
||||
super
|
||||
@action = :deploy
|
||||
@sub_resources = []
|
||||
end
|
||||
|
||||
actions :deploy, :force_deploy
|
||||
|
||||
attribute :name, :kind_of => String, :name_attribute => true
|
||||
attribute :environment_name, :kind_of => String, :default => (node.chef_environment =~ /_default/ ? "production" : node.chef_environment)
|
||||
attribute :path, :kind_of => String
|
||||
attribute :owner, :kind_of => String
|
||||
attribute :group, :kind_of => String
|
||||
attribute :keep_releases, :kind_of => Integer, :default => 5
|
||||
attribute :strategy, :kind_of => [String, Symbol], :default => :deploy_revision
|
||||
attribute :scm_provider, :kind_of => [Class, String, Symbol]
|
||||
attribute :revision, :kind_of => String
|
||||
attribute :repository, :kind_of => String
|
||||
attribute :enable_submodules, :kind_of => [TrueClass, FalseClass], :default => false
|
||||
attribute :environment, :kind_of => Hash, :default => {}
|
||||
attribute :deploy_key, :kind_of => [String, NilClass], :default => nil
|
||||
attribute :strict_ssh, :kind_of => [TrueClass, FalseClass], :default => false
|
||||
attribute :shallow_clone, :kind_of => [TrueClass, FalseClass], :default => false
|
||||
attribute :force, :kind_of => [TrueClass, FalseClass], :default => false
|
||||
attribute :rollback_on_error, :kind_of => [TrueClass, FalseClass], :default => true
|
||||
attribute :purge_before_symlink, :kind_of => Array, :default => []
|
||||
attribute :create_dirs_before_symlink, :kind_of => Array, :default => []
|
||||
attribute :symlinks, :kind_of => Hash, :default => {}
|
||||
attribute :symlink_before_migrate, :kind_of => Hash, :default => {}
|
||||
attribute :migrate, :kind_of => [TrueClass, FalseClass], :default => false
|
||||
attribute :migration_command, :kind_of => [String, NilClass], :default => nil
|
||||
attribute :packages, :kind_of => [Array, Hash], :default => []
|
||||
attribute :application_provider
|
||||
attr_reader :sub_resources
|
||||
|
||||
def restart_command(arg=nil, &block)
|
||||
arg ||= block
|
||||
set_or_return(:restart_command, arg, :kind_of => [Proc, String])
|
||||
end
|
||||
|
||||
# Callback fires before deploy is started.
|
||||
def before_deploy(arg=nil, &block)
|
||||
arg ||= block
|
||||
set_or_return(:before_deploy, arg, :kind_of => [Proc, String])
|
||||
end
|
||||
|
||||
# Callback fires before migration is run.
|
||||
def before_migrate(arg=nil, &block)
|
||||
arg ||= block
|
||||
set_or_return(:before_migrate, arg, :kind_of => [Proc, String])
|
||||
end
|
||||
|
||||
# Callback fires before symlinking
|
||||
def before_symlink(arg=nil, &block)
|
||||
arg ||= block
|
||||
set_or_return(:before_symlink, arg, :kind_of => [Proc, String])
|
||||
end
|
||||
|
||||
# Callback fires before restart
|
||||
def before_restart(arg=nil, &block)
|
||||
arg ||= block
|
||||
set_or_return(:before_restart, arg, :kind_of => [Proc, String])
|
||||
end
|
||||
|
||||
# Callback fires after restart
|
||||
def after_restart(arg=nil, &block)
|
||||
arg ||= block
|
||||
set_or_return(:after_restart, arg, :kind_of => [Proc, String])
|
||||
end
|
||||
|
||||
def release_path
|
||||
application_provider.release_path
|
||||
end
|
||||
|
||||
def shared_path
|
||||
application_provider.shared_path
|
||||
end
|
||||
|
||||
def method_missing(name, *args, &block)
|
||||
# Build the set of names to check for a valid resource
|
||||
lookup_path = ["application_#{name}"]
|
||||
run_context.cookbook_collection.each do |cookbook_name, cookbook_ver|
|
||||
if cookbook_name.start_with?("application_")
|
||||
lookup_path << "#{cookbook_name}_#{name}"
|
||||
end
|
||||
end
|
||||
lookup_path << name
|
||||
resource = nil
|
||||
# Try to find our resource
|
||||
lookup_path.each do |resource_name|
|
||||
begin
|
||||
Chef::Log.debug "Trying to load application resource #{resource_name} for #{name}"
|
||||
resource = super(resource_name.to_sym, self.name, &block)
|
||||
break
|
||||
rescue NameError => e
|
||||
# Works on any MRI ruby
|
||||
if e.name == resource_name.to_sym || e.inspect =~ /\b#{resource_name}\b/
|
||||
next
|
||||
else
|
||||
raise e
|
||||
end
|
||||
end
|
||||
end
|
||||
raise NameError, "No resource found for #{name}. Tried #{lookup_path.join(', ')}" unless resource
|
||||
# Enforce action :nothing in case people forget
|
||||
resource.action :nothing
|
||||
# Make this a weakref to prevent a cycle between the application resource and the sub resources
|
||||
resource.application WeakRef.new(self)
|
||||
resource.type name
|
||||
@sub_resources << resource
|
||||
resource
|
||||
end
|
||||
|
||||
def do_i_respond_to?(*args)
|
||||
name = args.first.to_s
|
||||
# Build the set of names to check for a valid resource
|
||||
lookup_path = ["application_#{name}"]
|
||||
run_context.cookbook_collection.each do |cookbook_name, cookbook_ver|
|
||||
if cookbook_name.start_with?("application_")
|
||||
lookup_path << "#{cookbook_name}_#{name}"
|
||||
end
|
||||
end
|
||||
lookup_path << name
|
||||
found = false
|
||||
# Try to find our resource
|
||||
lookup_path.each do |resource_name|
|
||||
begin
|
||||
Chef::Log.debug "Looking for application resource #{resource_name} for #{name}"
|
||||
Chef::Resource.resource_for_node(resource_name.to_sym, node)
|
||||
found = true
|
||||
break
|
||||
rescue NameError => e
|
||||
# Keep calm and carry on
|
||||
end
|
||||
end
|
||||
found
|
||||
end
|
||||
|
||||
# If we are using a current version of ruby, use respond_to_missing?
|
||||
# instead of respond_to? so we provide proper behavior
|
||||
if(Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('1.9.1'))
|
||||
def respond_to_missing?(*args)
|
||||
super || do_i_respond_to?(*args)
|
||||
end
|
||||
else
|
||||
def respond_to?(*args)
|
||||
super || do_i_respond_to?(*args)
|
||||
end
|
||||
end
|
||||
|
||||
def to_ary
|
||||
nil
|
||||
end
|
||||
alias :to_a :to_ary
|
@ -1,8 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Deploy SSH Wrapper
|
||||
# App: <%= @id %>
|
||||
#
|
||||
# Rendered by Chef - local changes will be replaced
|
||||
|
||||
/usr/bin/env ssh <% unless @strict_ssh %>-o "StrictHostKeyChecking=no" <% end %>-i "<%= @deploy_to %>/id_deploy" $@
|
10
cookbooks/application_git/CHANGELOG.md
Normal file
10
cookbooks/application_git/CHANGELOG.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Application_Git Changelog
|
||||
|
||||
## v1.1.0
|
||||
|
||||
* [#2](https://github.com/poise/application_git/issues/2) – Inherit user and group values from the parent `application` resource.
|
||||
* [#3](https://github.com/poise/application_git/issues/3) – Fix usage with users created during the current Chef run.
|
||||
|
||||
## v1.0.0
|
||||
|
||||
* Initial release.
|
108
cookbooks/application_git/README.md
Normal file
108
cookbooks/application_git/README.md
Normal file
@ -0,0 +1,108 @@
|
||||
# Application_Git Cookbook
|
||||
|
||||
[](https://travis-ci.org/poise/application_git)
|
||||
[](https://rubygems.org/gems/poise-application-git)
|
||||
[](https://supermarket.chef.io/cookbooks/application_git)
|
||||
[](https://codecov.io/github/poise/application_git)
|
||||
[](https://gemnasium.com/poise/application_git)
|
||||
[](https://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
A [Chef](https://www.chef.io/) cookbook to handle deploying code from git when
|
||||
using the [application cookbook](https://github.com/poise/application).
|
||||
|
||||
## Quick Start
|
||||
|
||||
To deploy from a private GitHub repository:
|
||||
|
||||
```ruby
|
||||
application '/srv/myapp' do
|
||||
git 'git@github.com:example/myapp.git' do
|
||||
deploy_key chef_vault_item('deploy_keys', 'myapp')['key']
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
Chef 12 or newer is required.
|
||||
|
||||
## Resources
|
||||
|
||||
### `application_git`
|
||||
|
||||
The `application_git` resource deploys code from git. It extends the core `git`
|
||||
resource to support deploy keys and disabling strict host key verification.
|
||||
|
||||
```ruby
|
||||
application '/srv/myapp' do
|
||||
git 'git@github.com:example/myapp.git'
|
||||
end
|
||||
```
|
||||
|
||||
#### Actions
|
||||
|
||||
All actions work the same as the core `git` resource.
|
||||
|
||||
* `:sync` – Clone and checkout the requested revision *(default)*
|
||||
* `:checkout` – Checkout the request revision. If the repository isn't already
|
||||
cloned, this action does nothing.
|
||||
* `:export` – Export the repository without the `.git` folder.
|
||||
|
||||
#### Properties
|
||||
|
||||
All properties from the core `git` resource work the same way with the following
|
||||
additions:
|
||||
|
||||
* `deploy_key` – SSH key to use with git. Can be specified either as a path to
|
||||
key file already created or as a string value containing the key directly.
|
||||
* `strict_ssh` – Enable strict SSH host key checking. *(default: false)*
|
||||
|
||||
### DSL Usage
|
||||
|
||||
The `application_git` resource can be used directly as a replacement for the
|
||||
core `git` resource:
|
||||
|
||||
```ruby
|
||||
application_git '/srv/myapp' do
|
||||
repository 'git@github.com:example/myapp.git'
|
||||
deploy_key chef_vault_item('deploy_keys', 'myapp')['key']
|
||||
end
|
||||
```
|
||||
|
||||
Within the `application` resource, a simplified DSL is available. As with other
|
||||
`application` plugins, the default name of the resource if unspecified is the
|
||||
application path. The following two examples are equivalent:
|
||||
|
||||
```ruby
|
||||
application '/srv/myapp' do
|
||||
git do
|
||||
repository 'git@github.com:example/myapp.git'
|
||||
end
|
||||
end
|
||||
|
||||
application '/srv/myapp' do
|
||||
git 'git@github.com:example/myapp.git'
|
||||
end
|
||||
```
|
||||
|
||||
## Sponsors
|
||||
|
||||
Development sponsored by [Chef Software](https://www.chef.io/), [Symonds & Son](http://symondsandson.com/), and [Orion](https://www.orionlabs.co/).
|
||||
|
||||
The Poise test server infrastructure is sponsored by [Rackspace](https://rackspace.com/).
|
||||
|
||||
## License
|
||||
|
||||
Copyright 2015-2016, Noah Kantrowitz
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
@ -0,0 +1,17 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_application_git'
|
@ -0,0 +1,21 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_application_git/resource'
|
||||
|
||||
|
||||
module PoiseApplicationGit
|
||||
end
|
@ -0,0 +1,17 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_application_git/resource'
|
@ -0,0 +1,204 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'zlib'
|
||||
|
||||
require 'chef/provider'
|
||||
require 'chef/resource'
|
||||
require 'poise_application/app_mixin'
|
||||
require 'poise_application/resources/application'
|
||||
|
||||
require 'poise_application_git/safe_string'
|
||||
|
||||
|
||||
module PoiseApplicationGit
|
||||
# An `application_git` resource to clone application code from git.
|
||||
#
|
||||
# @since 1.0.0
|
||||
# @provides application_git
|
||||
# @action sync
|
||||
# @action checkout
|
||||
# @action export
|
||||
# @example
|
||||
# application '/srv/myapp' do
|
||||
# git 'git@github.com:example/myapp.git' do
|
||||
# deploy_key data_bag_item('deploy_keys', 'myapp')['key']
|
||||
# end
|
||||
# end
|
||||
class Resource < Chef::Resource::Git
|
||||
include PoiseApplication::AppMixin
|
||||
provides(:application_git)
|
||||
|
||||
# @api private
|
||||
def initialize(*args)
|
||||
super
|
||||
# Because the superclass declares this, we have to as well. Should be
|
||||
# removable at some point when Chef makes everything use the provider
|
||||
# resolver system instead.
|
||||
@resource_name = :application_git
|
||||
@provider = PoiseApplicationGit::Provider
|
||||
# Clear defaults in older versions of Chef.
|
||||
remove_instance_variable(:@group) if instance_variable_defined?(:@group)
|
||||
remove_instance_variable(:@user) if instance_variable_defined?(:@user)
|
||||
end
|
||||
|
||||
# @!attribute group
|
||||
# Group to run git as. Defaults to the application group.
|
||||
# @return [String, Integer, nil, false]
|
||||
attribute(:group, kind_of: [String, Integer, NilClass, FalseClass], default: lazy { parent && parent.group })
|
||||
# @!attribute strict_ssh
|
||||
# Enable strict SSH host key checking. Defaults to false.
|
||||
# @return [Boolean]
|
||||
attribute(:strict_ssh, equal_to: [true, false], default: false)
|
||||
# @!attribute user
|
||||
# User to run git as. Defaults to the application owner.
|
||||
# @return [String, Integer, nil, false]
|
||||
attribute(:user, kind_of: [String, Integer, NilClass, FalseClass], default: lazy { parent && parent.owner })
|
||||
|
||||
# @api private
|
||||
def after_created
|
||||
# Allow using the repository as the name in an application block.
|
||||
if parent && !repository
|
||||
destination(parent.path)
|
||||
repository(name)
|
||||
end
|
||||
end
|
||||
|
||||
# @!attribute deploy_key
|
||||
# SSH deploy key as either a string value or a path to a key file.
|
||||
# @return [String]
|
||||
def deploy_key(val=nil)
|
||||
# Use a SafeString for literal deploy keys so they aren't shown.
|
||||
val = SafeString.new(val) if val && !deploy_key_is_local?(val)
|
||||
set_or_return(:deploy_key, val, kind_of: String)
|
||||
end
|
||||
|
||||
# Default SSH wrapper path.
|
||||
#
|
||||
# @api private
|
||||
# @return [String]
|
||||
def ssh_wrapper_path
|
||||
@ssh_wrapper_path ||= ::File.expand_path("~#{user}/.ssh/ssh_wrapper_#{Zlib.crc32(name)}")
|
||||
end
|
||||
|
||||
# Guess if the deploy key is a local path or literal value.
|
||||
#
|
||||
# @api private
|
||||
# @param key [String, nil] Key value to check. Defaults to self.key.
|
||||
# @return [Boolean]
|
||||
def deploy_key_is_local?(key=nil)
|
||||
key ||= deploy_key
|
||||
key && key[0] == '/'
|
||||
end
|
||||
|
||||
# Path to deploy key.
|
||||
#
|
||||
# @api private
|
||||
# @return [String]
|
||||
def deploy_key_path
|
||||
@deploy_key_path ||= if deploy_key_is_local?
|
||||
deploy_key
|
||||
else
|
||||
::File.expand_path("~#{user}/.ssh/id_deploy_#{Zlib.crc32(name)}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Provider for `application_git`.
|
||||
#
|
||||
# @since 1.0.0
|
||||
# @see Resource
|
||||
# @provides application_git
|
||||
class Provider < Chef::Provider::Git
|
||||
include PoiseApplication::AppMixin
|
||||
provides(:application_git)
|
||||
|
||||
# @api private
|
||||
def initialize(*args)
|
||||
super
|
||||
# Set the SSH wrapper path in a late-binding kind of way. This better
|
||||
# supports situations where the user doesn't exist until Chef converges.
|
||||
new_resource.ssh_wrapper(new_resource.ssh_wrapper_path) if new_resource.deploy_key
|
||||
end
|
||||
|
||||
# @api private
|
||||
def whyrun_supported?
|
||||
false # Just not dealing with this right now
|
||||
end
|
||||
|
||||
# Hack our special login in before load_current_resource runs because that
|
||||
# needs access to the git remote.
|
||||
#
|
||||
# @api private
|
||||
def load_current_resource
|
||||
include_recipe('git')
|
||||
notifying_block do
|
||||
create_dotssh
|
||||
write_deploy_key
|
||||
write_ssh_wrapper
|
||||
end if new_resource.deploy_key
|
||||
super
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Create a .ssh folder for the user.
|
||||
#
|
||||
# @return [void]
|
||||
def create_dotssh
|
||||
directory ::File.expand_path("~#{new_resource.user}/.ssh") do
|
||||
owner new_resource.user
|
||||
group new_resource.group
|
||||
mode '755'
|
||||
end
|
||||
end
|
||||
|
||||
# Copy the deploy key to a file if needed.
|
||||
#
|
||||
# @return [void]
|
||||
def write_deploy_key
|
||||
# Check if we have a local path or some actual content
|
||||
return if new_resource.deploy_key_is_local?
|
||||
file new_resource.deploy_key_path do
|
||||
owner new_resource.user
|
||||
group new_resource.group
|
||||
mode '600'
|
||||
content new_resource.deploy_key
|
||||
sensitive true
|
||||
end
|
||||
end
|
||||
|
||||
# Create the SSH wrapper script.
|
||||
#
|
||||
# @return [void]
|
||||
def write_ssh_wrapper
|
||||
# Write out the GIT_SSH script, it should already be enabled above
|
||||
file new_resource.ssh_wrapper_path do
|
||||
owner new_resource.user
|
||||
group new_resource.group
|
||||
mode '700'
|
||||
content %Q{#!/bin/sh\n/usr/bin/env ssh #{'-o "StrictHostKeyChecking=no" ' unless new_resource.strict_ssh}-i "#{new_resource.deploy_key_path}" $@\n}
|
||||
end
|
||||
end
|
||||
|
||||
# Patch back in the `#git` from the git provider. This otherwise conflicts
|
||||
# with the `#git` defined by the DSL, which gets included in such a way
|
||||
# that the DSL takes priority.
|
||||
def git(*args, &block)
|
||||
Chef::Provider::Git.instance_method(:git).bind(self).call(*args, &block)
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,25 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
|
||||
module PoiseApplicationGit
|
||||
# A string that won't be shown in Chef error output
|
||||
class SafeString < String
|
||||
def to_text
|
||||
'"suppressed sensitive value"'
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,20 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
|
||||
module PoiseApplicationGit
|
||||
VERSION = '1.1.0'
|
||||
end
|
19
cookbooks/application_git/libraries/default.rb
Normal file
19
cookbooks/application_git/libraries/default.rb
Normal file
@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright 2015-2016, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
raise 'Halite is not compatible with no_lazy_load false, please set no_lazy_load true in your Chef configuration file.' unless Chef::Config[:no_lazy_load]
|
||||
$LOAD_PATH << File.expand_path('../../files/halite_gem', __FILE__)
|
||||
require "poise_application_git/cheftie"
|
1
cookbooks/application_git/metadata.json
Normal file
1
cookbooks/application_git/metadata.json
Normal file
@ -0,0 +1 @@
|
||||
{"name":"application_git","version":"1.1.0","description":"A plugin for poise-application to deploy applications from git.","long_description":"# Application_Git Cookbook\n\n[](https://travis-ci.org/poise/application_git)\n[](https://rubygems.org/gems/poise-application-git)\n[](https://supermarket.chef.io/cookbooks/application_git)\n[](https://codecov.io/github/poise/application_git)\n[](https://gemnasium.com/poise/application_git)\n[](https://www.apache.org/licenses/LICENSE-2.0)\n\nA [Chef](https://www.chef.io/) cookbook to handle deploying code from git when\nusing the [application cookbook](https://github.com/poise/application).\n\n## Quick Start\n\nTo deploy from a private GitHub repository:\n\n```ruby\napplication '/srv/myapp' do\n git 'git@github.com:example/myapp.git' do\n deploy_key chef_vault_item('deploy_keys', 'myapp')['key']\n end\nend\n```\n\n## Requirements\n\nChef 12 or newer is required.\n\n## Resources\n\n### `application_git`\n\nThe `application_git` resource deploys code from git. It extends the core `git`\nresource to support deploy keys and disabling strict host key verification.\n\n```ruby\napplication '/srv/myapp' do\n git 'git@github.com:example/myapp.git'\nend\n```\n\n#### Actions\n\nAll actions work the same as the core `git` resource.\n\n* `:sync` – Clone and checkout the requested revision *(default)*\n* `:checkout` – Checkout the request revision. If the repository isn't already\n cloned, this action does nothing.\n* `:export` – Export the repository without the `.git` folder.\n\n#### Properties\n\nAll properties from the core `git` resource work the same way with the following\nadditions:\n\n* `deploy_key` – SSH key to use with git. Can be specified either as a path to\n key file already created or as a string value containing the key directly.\n* `strict_ssh` – Enable strict SSH host key checking. *(default: false)*\n\n### DSL Usage\n\nThe `application_git` resource can be used directly as a replacement for the\ncore `git` resource:\n\n```ruby\napplication_git '/srv/myapp' do\n repository 'git@github.com:example/myapp.git'\n deploy_key chef_vault_item('deploy_keys', 'myapp')['key']\nend\n```\n\nWithin the `application` resource, a simplified DSL is available. As with other\n`application` plugins, the default name of the resource if unspecified is the\napplication path. The following two examples are equivalent:\n\n```ruby\napplication '/srv/myapp' do\n git do\n repository 'git@github.com:example/myapp.git'\n end\nend\n\napplication '/srv/myapp' do\n git 'git@github.com:example/myapp.git'\nend\n```\n\n## Sponsors\n\nDevelopment sponsored by [Chef Software](https://www.chef.io/), [Symonds & Son](http://symondsandson.com/), and [Orion](https://www.orionlabs.co/).\n\nThe Poise test server infrastructure is sponsored by [Rackspace](https://rackspace.com/).\n\n## License\n\nCopyright 2015-2016, Noah Kantrowitz\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","maintainer":"Noah Kantrowitz","maintainer_email":"noah@coderanger.net","license":"Apache 2.0","platforms":{},"dependencies":{"git":">= 0.0.0","poise":"~> 2.0","application":"~> 5.0"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{}}
|
5
cookbooks/application_javascript/CHANGELOG.md
Normal file
5
cookbooks/application_javascript/CHANGELOG.md
Normal file
@ -0,0 +1,5 @@
|
||||
# Application_Javascript Changelog
|
||||
|
||||
## v1.0.0
|
||||
|
||||
Initial release!
|
132
cookbooks/application_javascript/README.md
Normal file
132
cookbooks/application_javascript/README.md
Normal file
@ -0,0 +1,132 @@
|
||||
# Application_Javascript Cookbook
|
||||
|
||||
[](https://travis-ci.org/poise/application_javascript)
|
||||
[](https://rubygems.org/gems/poise-application-javascript)
|
||||
[](https://supermarket.chef.io/cookbooks/application_javascript)
|
||||
[](https://codecov.io/github/poise/application_javascript)
|
||||
[](https://gemnasium.com/poise/application_javascript)
|
||||
[](https://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
A [Chef](https://www.chef.io/) cookbook to deploy server-side JavaScript
|
||||
applications using Node.js or io.js.
|
||||
|
||||
## Quick Start
|
||||
|
||||
To deploy an Express application from git:
|
||||
|
||||
```ruby
|
||||
application '/srv/myapp' do
|
||||
git 'https://github.com/example/myapp.git'
|
||||
npm_install
|
||||
npm_start
|
||||
end
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
Chef 12 or newer is required.
|
||||
|
||||
## Resources
|
||||
|
||||
### `application_javascript`
|
||||
|
||||
The `application_javascript` resource installs a JavaScript runtime for the
|
||||
deployment.
|
||||
|
||||
```ruby
|
||||
application '/srv/myapp' do
|
||||
javascript '3'
|
||||
end
|
||||
```
|
||||
|
||||
All actions and properties are the same as the [`javascript_runtime` resource](https://github.com/poise/poise-javascript#javascript_runtime).
|
||||
|
||||
### `application_javascript_service`
|
||||
|
||||
The `application_javascript_javascript_service` resource creates a service for a
|
||||
JavaScript command.
|
||||
|
||||
```ruby
|
||||
application '/srv/myapp' do
|
||||
javascript_service 'main.js'
|
||||
end
|
||||
```
|
||||
|
||||
#### Actions
|
||||
|
||||
* `:enable` – Create, enable and start the service. *(default)*
|
||||
* `:disable` – Stop, disable, and destroy the service.
|
||||
* `:start` – Start the service.
|
||||
* `:stop` – Stop the service.
|
||||
* `:restart` – Stop and then start the service.
|
||||
* `:reload` – Send the configured reload signal to the service.
|
||||
|
||||
#### Properties
|
||||
|
||||
* `command` – Command to run. *(name attribute)*
|
||||
* `path` – Base path for the application. *(default: application path)*
|
||||
* `service_name` – Name of the service to create. *(default: auto-detect)*
|
||||
# `user` – User to run the service as. *(default: application owner)*
|
||||
|
||||
### `application_node_package`
|
||||
|
||||
The `application_node_package` resource installs NPM packages for the deployment.
|
||||
|
||||
```ruby
|
||||
application '/srv/myapp' do
|
||||
node_package 'grunt-cli'
|
||||
end
|
||||
```
|
||||
|
||||
All actions and properties are the same as the [`node_package` resource](https://github.com/poise/poise-javascript#node_package),
|
||||
except that the `group` and `user` properties default to the application-level
|
||||
data if not specified.
|
||||
|
||||
### `application_npm_start`
|
||||
|
||||
The `application_npm_start` resource creates a service for a JavaScript
|
||||
application using `npm start`.
|
||||
|
||||
```ruby
|
||||
application '/srv/myapp' do
|
||||
npm_start
|
||||
end
|
||||
```
|
||||
|
||||
#### Actions
|
||||
|
||||
* `:enable` – Create, enable and start the service. *(default)*
|
||||
* `:disable` – Stop, disable, and destroy the service.
|
||||
* `:start` – Start the service.
|
||||
* `:stop` – Stop the service.
|
||||
* `:restart` – Stop and then start the service.
|
||||
* `:reload` – Send the configured reload signal to the service.
|
||||
|
||||
#### Properties
|
||||
|
||||
* `path` – Base path for the application. *(default: name attribute)*
|
||||
* `command` – NPM subcommand to run. *(default: start)*
|
||||
* `service_name` – Name of the service to create. *(default: auto-detect)*
|
||||
# `user` – User to run the service as. *(default: application owner)*
|
||||
|
||||
## Sponsors
|
||||
|
||||
Development sponsored by [Chef Software](https://www.chef.io/), [Symonds & Son](http://symondsandson.com/), and [Orion](https://www.orionlabs.co/).
|
||||
|
||||
The Poise test server infrastructure is sponsored by [Rackspace](https://rackspace.com/).
|
||||
|
||||
## License
|
||||
|
||||
Copyright 2015, Noah Kantrowitz
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
@ -0,0 +1,23 @@
|
||||
#
|
||||
# Copyright 2015, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
|
||||
module PoiseApplicationJavascript
|
||||
autoload :AppMixin, 'poise_application_javascript/app_mixin'
|
||||
autoload :Error, 'poise_application_javascript/error'
|
||||
autoload :Resources, 'poise_application_javascript/resources'
|
||||
autoload :VERSION, 'poise_application_javascript/version'
|
||||
end
|
@ -0,0 +1,67 @@
|
||||
#
|
||||
# Copyright 2015, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise/backports'
|
||||
require 'poise/utils'
|
||||
require 'poise_application/app_mixin'
|
||||
require 'poise_javascript/javascript_command_mixin'
|
||||
|
||||
|
||||
module PoiseApplicationJavascript
|
||||
# A helper mixin for Javascript application resources and providers.
|
||||
#
|
||||
# @since 4.0.0
|
||||
module AppMixin
|
||||
include Poise::Utils::ResourceProviderMixin
|
||||
|
||||
# A helper mixin for Javascript application resources.
|
||||
module Resource
|
||||
include PoiseApplication::AppMixin::Resource
|
||||
include PoiseJavascript::JavascriptCommandMixin::Resource
|
||||
|
||||
# @!attribute parent_javascript
|
||||
# Override the #parent_javascript from JavascriptCommandMixin to grok the
|
||||
# application level parent as a default value.
|
||||
# @return [PoiseJavascript::Resources::JavascriptRuntime::Resource, nil]
|
||||
parent_attribute(:javascript, type: :javascript_runtime, optional: true, default: lazy { app_state_javascript.equal?(self) ? nil : app_state_javascript })
|
||||
|
||||
# @attribute app_state_javascript
|
||||
# The application-level Javascript parent.
|
||||
# @return [PoiseJavascript::Resources::JavascriptRuntime::Resource, nil]
|
||||
def app_state_javascript(javascript=Poise::NOT_PASSED)
|
||||
unless javascript == Poise::NOT_PASSED
|
||||
app_state[:javascript] = javascript
|
||||
end
|
||||
app_state[:javascript]
|
||||
end
|
||||
|
||||
# A merged hash of environment variables for both the application state
|
||||
# and parent javascript.
|
||||
#
|
||||
# @return [Hash<String, String>]
|
||||
def app_state_environment_javascript
|
||||
env = app_state_environment
|
||||
env = env.merge(parent_javascript.javascript_environment) if parent_javascript
|
||||
env
|
||||
end
|
||||
end
|
||||
|
||||
# A helper mixin for Javascript application providers.
|
||||
module Provider
|
||||
include PoiseApplication::AppMixin::Provider
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,17 @@
|
||||
#
|
||||
# Copyright 2015, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_application_javascript/resources'
|
@ -0,0 +1,25 @@
|
||||
#
|
||||
# Copyright 2015, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_application/error'
|
||||
|
||||
module PoiseApplicationJavascript
|
||||
# Base exception class for poise-application-javascript errors.
|
||||
#
|
||||
# @since 1.0.0
|
||||
class Error < PoiseApplication::Error
|
||||
end
|
||||
end
|
@ -0,0 +1,22 @@
|
||||
#
|
||||
# Copyright 2015, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_application_javascript/resources/javascript'
|
||||
require 'poise_application_javascript/resources/javascript_execute'
|
||||
require 'poise_application_javascript/resources/javascript_service'
|
||||
require 'poise_application_javascript/resources/node_package'
|
||||
require 'poise_application_javascript/resources/npm_install'
|
||||
require 'poise_application_javascript/resources/npm_start'
|
@ -0,0 +1,64 @@
|
||||
#
|
||||
# Copyright 2015, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_javascript/resources/javascript_runtime'
|
||||
|
||||
require 'poise_application_javascript/app_mixin'
|
||||
|
||||
|
||||
module PoiseApplicationJavascript
|
||||
module Resources
|
||||
# (see Javascript::Resource)
|
||||
# @since 1.0.0
|
||||
module Javascript
|
||||
# An `application_javascript` resource to manage Javascript runtimes
|
||||
# inside an Application cookbook deployment.
|
||||
#
|
||||
# @provides application_javascript
|
||||
# @provides application_javascript_runtime
|
||||
# @action install
|
||||
# @action uninstall
|
||||
# @example
|
||||
# application '/app' do
|
||||
# javascript '3'
|
||||
# end
|
||||
class Resource < PoiseJavascript::Resources::JavascriptRuntime::Resource
|
||||
include PoiseApplicationJavascript::AppMixin
|
||||
provides(:application_javascript)
|
||||
# Need the double javascript for application resource rewriting.
|
||||
provides(:application_javascript_runtime)
|
||||
container_default(false)
|
||||
subclass_providers!
|
||||
|
||||
# We want to run the base class version of this, not the one from the
|
||||
# mixin. HULK SMASH.
|
||||
def npm_binary
|
||||
self.class.superclass.instance_method(:npm_binary).bind(self).call
|
||||
end
|
||||
|
||||
# Set this resource as the app_state's parent javascript.
|
||||
#
|
||||
# @api private
|
||||
def after_created
|
||||
super.tap do |val|
|
||||
app_state_javascript(self)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,88 @@
|
||||
#
|
||||
# Copyright 2015, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_javascript/resources/javascript_execute'
|
||||
|
||||
require 'poise_application_javascript/app_mixin'
|
||||
|
||||
|
||||
module PoiseApplicationJavascript
|
||||
module Resources
|
||||
# (see JavascriptExecute::Resource)
|
||||
# @since 1.0.0
|
||||
module JavascriptExecute
|
||||
# An `application_javascript_execute` resource to run Javascript commands inside an
|
||||
# Application cookbook deployment.
|
||||
#
|
||||
# @provides application_javascript_execute
|
||||
# @action run
|
||||
# @example
|
||||
# application '/srv/myapp' do
|
||||
# javascript_execute 'setup.py install'
|
||||
# end
|
||||
class Resource < PoiseJavascript::Resources::JavascriptExecute::Resource
|
||||
include PoiseApplicationJavascript::AppMixin
|
||||
provides(:application_javascript_execute)
|
||||
def initialize(*args)
|
||||
super
|
||||
# Clear some instance variables so my defaults work.
|
||||
remove_instance_variable(:@cwd)
|
||||
remove_instance_variable(:@group)
|
||||
remove_instance_variable(:@user)
|
||||
end
|
||||
|
||||
# #!attribute cwd
|
||||
# Override the default directory to be the app path if unspecified.
|
||||
# @return [String]
|
||||
attribute(:cwd, kind_of: [String, NilClass, FalseClass], default: lazy { parent && parent.path })
|
||||
|
||||
# #!attribute group
|
||||
# Override the default group to be the app group if unspecified.
|
||||
# @return [String, Integer]
|
||||
attribute(:group, kind_of: [String, Integer, NilClass, FalseClass], default: lazy { parent && parent.group })
|
||||
|
||||
# #!attribute user
|
||||
# Override the default user to be the app owner if unspecified.
|
||||
# @return [String, Integer]
|
||||
attribute(:user, kind_of: [String, Integer, NilClass, FalseClass], default: lazy { parent && parent.owner })
|
||||
end
|
||||
|
||||
# The default provider for `application_javascript_execute`.
|
||||
#
|
||||
# @see Resource
|
||||
# @provides application_javascript_execute
|
||||
class Provider < PoiseJavascript::Resources::JavascriptExecute::Provider
|
||||
provides(:application_javascript_execute)
|
||||
|
||||
private
|
||||
|
||||
# Override environment to add the application envivonrment instead.
|
||||
#
|
||||
# @return [Hash]
|
||||
def environment
|
||||
super.tap do |environment|
|
||||
# Don't use the app_state_environment_javascript because we already have
|
||||
# those values in place.
|
||||
environment.update(new_resource.app_state_environment)
|
||||
# Re-apply the resource environment for correct ordering.
|
||||
environment.update(new_resource.environment) if new_resource.environment
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,59 @@
|
||||
#
|
||||
# Copyright 2015, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'chef/provider'
|
||||
require 'chef/resource'
|
||||
require 'poise'
|
||||
|
||||
require 'poise_application_javascript/service_mixin'
|
||||
|
||||
|
||||
module PoiseApplicationJavascript
|
||||
module Resources
|
||||
# (see JavascriptService::Resource)
|
||||
# @since 1.0.0
|
||||
module JavascriptService
|
||||
class Resource < Chef::Resource
|
||||
include PoiseApplicationJavascript::ServiceMixin
|
||||
provides(:application_javascript_service)
|
||||
|
||||
# @!attribute command
|
||||
# Command to run.
|
||||
# @return [String]
|
||||
attribute(:command, kind_of: String, name_attribute: true)
|
||||
# @!attribute path
|
||||
# Override {PoiseApplicationJavascript::ServiceMixin#path} to make it
|
||||
# not the name_attribute.
|
||||
# @return [String]
|
||||
attribute(:path, kind_of: String, default: lazy { parent && parent.path })
|
||||
end
|
||||
|
||||
class Provider < Chef::Provider
|
||||
include PoiseApplicationJavascript::ServiceMixin
|
||||
provides(:application_javascript_service)
|
||||
|
||||
private
|
||||
|
||||
# (see PoiseApplication::ServiceMixin#service_options)
|
||||
def service_options(resource)
|
||||
super
|
||||
resource.javascript_command(new_resource.command)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Copyright 2015, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_javascript/resources/node_package'
|
||||
|
||||
require 'poise_application_javascript/app_mixin'
|
||||
|
||||
|
||||
module PoiseApplicationJavascript
|
||||
module Resources
|
||||
# (see NodePackage::Resource)
|
||||
# @since 1.0.0
|
||||
module NodePackage
|
||||
# An `application_node_package` resource to install NPM packages inside
|
||||
# an Application cookbook deployment.
|
||||
#
|
||||
# @provides application_node_package
|
||||
# @action install
|
||||
# @action upgrade
|
||||
# @action remove
|
||||
# @example
|
||||
# application '/app' do
|
||||
# node_package %w{grunt-cli gulp}
|
||||
# end
|
||||
class Resource < PoiseJavascript::Resources::NodePackage::Resource
|
||||
include PoiseApplicationJavascript::AppMixin
|
||||
provides(:application_node_package)
|
||||
subclass_providers!
|
||||
|
||||
def initialize(*args)
|
||||
super
|
||||
# For older Chef.
|
||||
@resource_name = :application_node_package
|
||||
end
|
||||
|
||||
# #!attribute group
|
||||
# Override the default group to be the app group if unspecified.
|
||||
# @return [String, Integer]
|
||||
attribute(:group, kind_of: [String, Integer, NilClass], default: lazy { parent && parent.group })
|
||||
|
||||
# #!attribute user
|
||||
# Override the default user to be the app owner if unspecified.
|
||||
# @return [String, Integer]
|
||||
attribute(:user, kind_of: [String, Integer, NilClass], default: lazy { parent && parent.owner })
|
||||
|
||||
# @todo This should handle relative paths against parent.path.
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,45 @@
|
||||
#
|
||||
# Copyright 2015, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_javascript/resources/npm_install'
|
||||
|
||||
require 'poise_application_javascript/app_mixin'
|
||||
|
||||
|
||||
module PoiseApplicationJavascript
|
||||
module Resources
|
||||
# (see NpmInstall::Resource)
|
||||
# @since 1.0.0
|
||||
module NpmInstall
|
||||
# An `application_npm_install` resource to install package
|
||||
# dependencies inside an Application cookbook deployment.
|
||||
#
|
||||
# @provides application_npm_install
|
||||
# @action install
|
||||
# @example
|
||||
# application '/app' do
|
||||
# npm_install
|
||||
# end
|
||||
class Resource < PoiseJavascript::Resources::NpmInstall::Resource
|
||||
include PoiseApplicationJavascript::AppMixin
|
||||
provides(:application_npm_install)
|
||||
subclass_providers!
|
||||
|
||||
# @todo This should handle relative paths against parent.path.
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,78 @@
|
||||
#
|
||||
# Copyright 2015, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'shellwords'
|
||||
|
||||
require 'chef/provider'
|
||||
require 'chef/resource'
|
||||
require 'poise'
|
||||
|
||||
require 'poise_application_javascript/service_mixin'
|
||||
|
||||
|
||||
module PoiseApplicationJavascript
|
||||
module Resources
|
||||
# (see NpmStart::Resource)
|
||||
# @since 1.0.0
|
||||
module NpmStart
|
||||
# An `application_npm_start` resource to create a service for a Javascript
|
||||
# application using `npm start`.
|
||||
#
|
||||
# @provides application_npm_start
|
||||
# @action enable
|
||||
# @action disable
|
||||
# @action start
|
||||
# @action stop
|
||||
# @action restart
|
||||
# @action reload
|
||||
# @example
|
||||
# application '/app' do
|
||||
# npm_start
|
||||
# end
|
||||
class Resource < Chef::Resource
|
||||
include PoiseApplicationJavascript::ServiceMixin
|
||||
provides(:application_npm_start)
|
||||
|
||||
# @!attribute command
|
||||
# NPM sub-command to run. Defaults to `start`.
|
||||
# @return [String, Array<String>]
|
||||
attribute(:command, kind_of: [String, Array], default: 'start')
|
||||
end
|
||||
|
||||
# The default provider for `application_npm_start`.
|
||||
#
|
||||
# @see Resource
|
||||
# @provides application_npm_start
|
||||
class Provider < Chef::Provider
|
||||
include PoiseApplicationJavascript::ServiceMixin
|
||||
provides(:application_npm_start)
|
||||
|
||||
private
|
||||
|
||||
# (see PoiseApplication::ServiceMixin#service_options)
|
||||
def service_options(resource)
|
||||
super
|
||||
npm_cmd = [new_resource.npm_binary] + Array(new_resource.command)
|
||||
resource.javascript_command(Shellwords.join(npm_cmd))
|
||||
# Make sure node is on $PATH because grrr.
|
||||
new_path = [::File.dirname(new_resource.javascript), (new_resource.app_state_environment_javascript['PATH'] || ENV['PATH']).to_s].join(::File::PATH_SEPARATOR)
|
||||
resource.environment['PATH'] = new_path
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,57 @@
|
||||
#
|
||||
# Copyright 2015, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise/utils'
|
||||
require 'poise_application/service_mixin'
|
||||
require 'poise_languages/utils'
|
||||
|
||||
require 'poise_application_javascript/app_mixin'
|
||||
|
||||
|
||||
module PoiseApplicationJavascript
|
||||
# A helper mixin for Javascript service resources and providers.
|
||||
#
|
||||
# @since 1.0.0
|
||||
module ServiceMixin
|
||||
include Poise::Utils::ResourceProviderMixin
|
||||
|
||||
# A helper mixin for Javascript service resources.
|
||||
module Resource
|
||||
include PoiseApplication::ServiceMixin::Resource
|
||||
include PoiseApplicationJavascript::AppMixin::Resource
|
||||
end
|
||||
|
||||
# A helper mixin for Javascript service providers.
|
||||
module Provider
|
||||
include PoiseApplication::ServiceMixin::Provider
|
||||
include PoiseApplicationJavascript::AppMixin::Provider
|
||||
|
||||
# Set up the service for running Javascript stuff.
|
||||
def service_options(resource)
|
||||
super
|
||||
# Closure scoping for #javascript_command below.
|
||||
self_ = self
|
||||
# Create a new singleton method that fills in `node` for you.
|
||||
resource.define_singleton_method(:javascript_command) do |val|
|
||||
resource.command("#{self_.new_resource.javascript} #{PoiseLanguages::Utils.absolute_command(val, path: self_.new_resource.app_state_environment_javascript['PATH'])}")
|
||||
end
|
||||
# Include env vars as needed.
|
||||
resource.environment.update(new_resource.parent_javascript.javascript_environment) if new_resource.parent_javascript
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright 2015, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
module PoiseApplicationJavascript
|
||||
VERSION = '1.0.0'
|
||||
end
|
19
cookbooks/application_javascript/libraries/default.rb
Normal file
19
cookbooks/application_javascript/libraries/default.rb
Normal file
@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright 2015, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
raise 'Halite is not compatible with no_lazy_load false, please set no_lazy_load true in your Chef configuration file.' unless Chef::Config[:no_lazy_load]
|
||||
$LOAD_PATH << File.expand_path('../../files/halite_gem', __FILE__)
|
||||
require "poise_application_javascript/cheftie"
|
1
cookbooks/application_javascript/metadata.json
Normal file
1
cookbooks/application_javascript/metadata.json
Normal file
File diff suppressed because one or more lines are too long
@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
@ -1,64 +0,0 @@
|
||||
## Description
|
||||
|
||||
This cookbook is designed to be able to describe and deploy Node.js web applications using Upstart.
|
||||
|
||||
Note that this cookbook provides the Node-specific bindings for the `application` cookbook; you will find general documentation in that cookbook.
|
||||
|
||||
## Requirements
|
||||
|
||||
Chef 0.10.0 or higher required (for Chef environment use).
|
||||
|
||||
Upstart 1.4 or higher for the use of `setuid` in the default Upstart configuration template.
|
||||
This requirement can be worked around by specifying a custom template.
|
||||
|
||||
The following Opscode cookbooks are dependencies:
|
||||
|
||||
* [application](https://github.com/opscode-cookbooks/application)
|
||||
* [nodejs](https://github.com/mdxp/nodejs-cookbook)
|
||||
|
||||
## Resources/Providers
|
||||
|
||||
The `nodejs` sub-resource LWRP deals with deploying Node.js applications using Upstart. It is not meant to be used by itself; make sure you are familiar with the `application` cookbook before proceeding.
|
||||
|
||||
### Attribute Parameters
|
||||
|
||||
- **npm**: If `true`, `npm` will be used to install the dependencies specified in `packages.json`. Defaults to `true`.
|
||||
- **template**: The name of the template that will be used to create the Upstart configuration file. If specified, it will be looked up in the application cookbook. Defaults to `nodejs.upstart.conf.erb` from this cookbook.
|
||||
- **entry_point**: The argument to pass to node. Defaults to `app.js`.
|
||||
|
||||
## Usage
|
||||
|
||||
Here is an example hello world application using [Express](http://expressjs.com):
|
||||
|
||||
```
|
||||
application "hello-world" do
|
||||
path "/srv/node-hello-world"
|
||||
owner "www-data"
|
||||
group "www-data"
|
||||
packages ["git"]
|
||||
|
||||
repository "git://github.com/visionmedia/express.git"
|
||||
|
||||
nodejs do
|
||||
entry_point "examples/hello-world"
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
## License and Author
|
||||
|
||||
Author:: Conrad Kramer (<conrad@kramerapps.com>)
|
||||
|
||||
Copyright 2013, Kramer Software Productions, LLC.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
@ -1,12 +0,0 @@
|
||||
name "application_nodejs"
|
||||
maintainer "Conrad Kramer"
|
||||
maintainer_email "conrad@kramerapps.com"
|
||||
license "Apache 2.0"
|
||||
description "Deploys and configures Node.js applications"
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version "2.0.1"
|
||||
|
||||
depends "nodejs"
|
||||
depends "application"
|
||||
|
||||
supports 'ubuntu', ">= 12.04"
|
@ -1,130 +0,0 @@
|
||||
#
|
||||
# Author:: Conrad Kramer <conrad@kramerapps.com>
|
||||
# Cookbook Name:: application_node
|
||||
# Resource:: node
|
||||
#
|
||||
# Copyright:: 2013, Kramer Software Productions, LLC. <conrad@kramerapps.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the 'License');
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an 'AS IS' BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include Chef::DSL::IncludeRecipe
|
||||
|
||||
action :before_compile do
|
||||
|
||||
r = new_resource
|
||||
|
||||
if new_resource.npm
|
||||
include_recipe 'nodejs::npm'
|
||||
end
|
||||
|
||||
unless new_resource.restart_command
|
||||
new_resource.restart_command do
|
||||
|
||||
service "#{r.application.name}_nodejs" do
|
||||
if platform?('ubuntu') && node[:platform_version].to_f >= 14.04
|
||||
provider Chef::Provider::Service::Systemd
|
||||
else
|
||||
provider Chef::Provider::Service::Upstart
|
||||
end
|
||||
supports :restart => true, :start => true, :stop => true
|
||||
action [:enable, :restart]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
new_resource.environment.update({
|
||||
'NODE_ENV' => r.environment_name
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
action :before_deploy do
|
||||
|
||||
new_resource.environment['NODE_ENV'] = new_resource.environment_name
|
||||
|
||||
r = new_resource
|
||||
|
||||
service "#{r.application.name}_nodejs" do
|
||||
if platform?('ubuntu') && node[:platform_version].to_f >= 14.04
|
||||
provider Chef::Provider::Service::Systemd
|
||||
else
|
||||
provider Chef::Provider::Service::Upstart
|
||||
end
|
||||
end
|
||||
|
||||
if platform?('ubuntu') && node[:platform_version].to_f >= 14.04
|
||||
execute "systemctl daemon-reload" do
|
||||
command "systemctl daemon-reload"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
template "#{r.application.name}_nodejs.systemd.service.erb" do
|
||||
path "/lib/systemd/system/#{r.application.name}_nodejs.service"
|
||||
source r.template ? r.template : 'nodejs.systemd.service.erb'
|
||||
cookbook r.template ? r.cookbook_name.to_s : 'application_nodejs'
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0644'
|
||||
variables(
|
||||
:user => r.owner,
|
||||
:group => r.group,
|
||||
:app_dir => r.release_path,
|
||||
:entry => r.entry_point,
|
||||
:environment => r.environment
|
||||
)
|
||||
notifies :run, "execute[systemctl daemon-reload]", :delayed
|
||||
notifies :restart, "service[#{r.application.name}_nodejs]", :delayed
|
||||
end
|
||||
else
|
||||
template "#{new_resource.application.name}.upstart.conf" do
|
||||
path "/etc/init/#{r.application.name}_nodejs.conf"
|
||||
source r.template ? r.template : 'nodejs.upstart.conf.erb'
|
||||
cookbook r.template ? r.cookbook_name.to_s : 'application_nodejs'
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0644'
|
||||
variables(
|
||||
:user => r.owner,
|
||||
:group => r.group,
|
||||
:app_dir => r.release_path,
|
||||
:entry => r.entry_point,
|
||||
:environment => r.environment
|
||||
)
|
||||
notifies :restart, "service[#{r.application.name}_nodejs]", :delayed
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :before_migrate do
|
||||
|
||||
if new_resource.npm
|
||||
execute 'npm install' do
|
||||
cwd new_resource.release_path
|
||||
user new_resource.owner
|
||||
group new_resource.group
|
||||
environment new_resource.environment.merge({ 'HOME' => new_resource.shared_path })
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
action :before_symlink do
|
||||
end
|
||||
|
||||
action :before_restart do
|
||||
end
|
||||
|
||||
action :after_restart do
|
||||
end
|
@ -1,25 +0,0 @@
|
||||
#
|
||||
# Author:: Conrad Kramer <conrad@kramerapps.com>
|
||||
# Cookbook Name:: application_node
|
||||
# Resource:: node
|
||||
#
|
||||
# Copyright:: 2013, Kramer Software Productions, LLC. <conrad@kramerapps.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include ApplicationCookbook::ResourceBase
|
||||
|
||||
attribute :npm, :kind_of => [NilClass, TrueClass, FalseClass], :default => true
|
||||
attribute :template, :kind_of => [String, NilClass], :default => nil
|
||||
attribute :entry_point, :kind_of => String, :default => 'app.js'
|
@ -1,4 +0,0 @@
|
||||
[Service]
|
||||
ExecStart=/usr/bin/env node <%= @entry %>
|
||||
User=<%= @user %>
|
||||
Group=<%= @group %>
|
@ -1,19 +0,0 @@
|
||||
#!upstart
|
||||
description "Node.js Application Server"
|
||||
|
||||
start on (local-filesystems and net-device-up IFACE!=lo)
|
||||
stop on [!12345]
|
||||
|
||||
console log
|
||||
|
||||
<% @environment.each do |key, value| -%>
|
||||
env <%= key %>="<%= value %>"
|
||||
<% end -%>
|
||||
<% unless @user.nil? -%>
|
||||
setuid <%= @user %>
|
||||
<% end -%>
|
||||
<% unless @group.nil? -%>
|
||||
setgid <%= @group %>
|
||||
<% end -%>
|
||||
chdir <%= @app_dir %>
|
||||
exec /usr/bin/env node <%= @entry %>
|
92
cookbooks/application_ruby/CHANGELOG.md
Normal file
92
cookbooks/application_ruby/CHANGELOG.md
Normal file
@ -0,0 +1,92 @@
|
||||
# Application_Ruby Changelog
|
||||
|
||||
## v4.1.0
|
||||
|
||||
* Add an `application_puma` resource to run a Puma application server.
|
||||
* Add support for `:initializer` style secrets for the `application_rails` resource.
|
||||
* Chef 13 support.
|
||||
|
||||
## v4.0.1
|
||||
|
||||
* Correct `gem_binary` results for `application_ruby`.
|
||||
|
||||
## v4.0.0
|
||||
|
||||
* Massive rewrite on top of newer Chef patterns. See the 4.0 README for details.
|
||||
|
||||
## v3.0.2
|
||||
|
||||
* No changes, bumping version to get bits in various places in sync.
|
||||
|
||||
## v3.0.0
|
||||
|
||||
* Major version bump. Breaking backwards compatibility with Chef 10.
|
||||
|
||||
## v2.2.0
|
||||
|
||||
* [COOK-3895](https://tickets.opscode.com/browse/COOK-3895) - application_ruby use_omnibus_ruby attr needs to default to false.
|
||||
* [COOK-3894](https://tickets.opscode.com/browse/COOK-3894) - application_ruby cookbook needs version bump to pick up application v4.0 cookbook.
|
||||
* [COOK-2079](https://tickets.opscode.com/browse/COOK-2079) - Attempting to touch restart.txt should not cause a chef-client run to fail.
|
||||
|
||||
## v2.1.4
|
||||
|
||||
* [COOK-3625](https://tickets.opscode.com/browse/COOK-3625) - Fix an issue where unicorn fails when node does not provide cpu count.
|
||||
|
||||
## v2.1.2
|
||||
|
||||
* [COOK-3616](https://tickets.opscode.com/browse/COOK-3616) - Simplify log symlinking for rails apps.
|
||||
|
||||
## v2.1.0
|
||||
|
||||
* [COOK-3367](https://tickets.opscode.com/browse/COOK-3367) - Support more of unicorn's configuration.
|
||||
* [COOK-3124](https://tickets.opscode.com/browse/COOK-3124) - Add `memcached_template` attribute to so alternative templates may be used.
|
||||
|
||||
## v2.0.0
|
||||
|
||||
### Bug
|
||||
|
||||
* [COOK-3306]: Multiple Memory Leaks in Application Cookbook.
|
||||
* [COOK-3219]: `application_ruby` cookbook bundle install in 1.9.3-based omnibus installs 1.9.x gems into ruby 2.0 apps.
|
||||
|
||||
## v1.1.4
|
||||
|
||||
* [COOK-2806]: Including `passenger_apache2::mod_rails` does not enable passenger.
|
||||
|
||||
## v1.1.2
|
||||
|
||||
* [COOK-2638]: cookbook attribute is not treated as a string when specifying `database_yml_template`.
|
||||
* [COOK-2525]: application_ruby: split runit template into multiple lines.
|
||||
|
||||
## v1.1.0
|
||||
|
||||
* [COOK-2362] - `application_ruby` unicorn uses `run_restart`.
|
||||
* [COOK-2363] - `application_ruby` unicorn should set `log_template_name` and `run_template_name`.
|
||||
|
||||
## v1.0.10
|
||||
|
||||
* [COOK-2260] - pin runit version.
|
||||
|
||||
## v1.0.8
|
||||
|
||||
* [COOK-2159] - cookbook attribute is not treated as a string.
|
||||
|
||||
## v1.0.6
|
||||
|
||||
* [COOK-1481] - unicorn provider in application_ruby cookbook should run its restart command as root.
|
||||
|
||||
## v1.0.4
|
||||
|
||||
* [COOK-1572] - allow specification of 'bundle' command via attribute.
|
||||
|
||||
## v1.0.2
|
||||
|
||||
* [COOK-1360] - fix typo in README.
|
||||
* [COOK-1374] - use runit attribute in unicorn run script.
|
||||
* [COOK-1408] - use user and group from parent resource for runit service.
|
||||
|
||||
## v1.0.0
|
||||
|
||||
* [COOK-1247] - Initial release - relates to COOK-634.
|
||||
* [COOK-1248] - special cases memcached.
|
||||
* [COOK-1258] - Precompile assets for Rails 3.
|
||||
* [COOK-1297] - Unicorn sub-resource should allow strings for 'port' attribute.
|
301
cookbooks/application_ruby/README.md
Normal file
301
cookbooks/application_ruby/README.md
Normal file
@ -0,0 +1,301 @@
|
||||
# Application_Ruby Cookbook
|
||||
|
||||
[](https://travis-ci.org/poise/application_ruby)
|
||||
[](https://rubygems.org/gems/poise-application-ruby)
|
||||
[](https://supermarket.chef.io/cookbooks/application_ruby)
|
||||
[](https://codecov.io/github/poise/application_ruby)
|
||||
[](https://gemnasium.com/poise/application_ruby)
|
||||
[](https://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
A [Chef](https://www.chef.io/) cookbook to deploy Ruby applications.
|
||||
|
||||
## Quick Start
|
||||
|
||||
To deploy a Rails application from git:
|
||||
|
||||
```ruby
|
||||
application '/srv/myapp' do
|
||||
git 'https://github.com/example/myapp.git'
|
||||
bundle_install do
|
||||
deployment true
|
||||
without %w{development test}
|
||||
end
|
||||
rails do
|
||||
database 'sqlite3:///db.sqlite3'
|
||||
secret_token 'd78fe08df56c9'
|
||||
migrate true
|
||||
end
|
||||
unicorn do
|
||||
port 8000
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
Chef 12.1 or newer is required.
|
||||
|
||||
## Resources
|
||||
|
||||
### `application_bundle_install`
|
||||
|
||||
The `application_bundle_install` resource installs gems using Bundler for a
|
||||
deployment.
|
||||
|
||||
```ruby
|
||||
application '/srv/myapp' do
|
||||
bundle_install do
|
||||
deployment true
|
||||
without %w{development test}
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
All actions and properties are the same as the [`bundle_install` resource](https://github.com/poise/poise-ruby#bundle_install).
|
||||
|
||||
### `application_puma`
|
||||
|
||||
The `application_puma` resource creates a service for `puma`.
|
||||
|
||||
```ruby
|
||||
application '/srv/myapp' do
|
||||
puma do
|
||||
port 8000
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
#### Actions
|
||||
|
||||
* `:enable` – Create, enable and start the service. *(default)*
|
||||
* `:disable` – Stop, disable, and destroy the service.
|
||||
* `:start` – Start the service.
|
||||
* `:stop` – Stop the service.
|
||||
* `:restart` – Stop and then start the service.
|
||||
* `:reload` – Send the configured reload signal to the service.
|
||||
|
||||
#### Properties
|
||||
|
||||
* `path` – Base path for the application. *(name attribute)*
|
||||
* `port` – Port to listen on. *(default: 80)*
|
||||
* `service_name` – Name of the service to create. *(default: auto-detect)*
|
||||
* `user` – User to run the service as. *(default: application owner)*
|
||||
|
||||
### `application_rackup`
|
||||
|
||||
The `application_rackup` resource creates a service for `rackup`.
|
||||
|
||||
```ruby
|
||||
application '/srv/myapp' do
|
||||
rackup do
|
||||
port 8000
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
#### Actions
|
||||
|
||||
* `:enable` – Create, enable and start the service. *(default)*
|
||||
* `:disable` – Stop, disable, and destroy the service.
|
||||
* `:start` – Start the service.
|
||||
* `:stop` – Stop the service.
|
||||
* `:restart` – Stop and then start the service.
|
||||
* `:reload` – Send the configured reload signal to the service.
|
||||
|
||||
#### Properties
|
||||
|
||||
* `path` – Base path for the application. *(name attribute)*
|
||||
* `port` – Port to listen on. *(default: 80)*
|
||||
* `service_name` – Name of the service to create. *(default: auto-detect)*
|
||||
# `user` – User to run the service as. *(default: application owner)*
|
||||
|
||||
### `application_rails`
|
||||
|
||||
The `application_rails` resource
|
||||
|
||||
```ruby
|
||||
application '/srv/myapp' do
|
||||
rails do
|
||||
database 'sqlite3:///db.sqlite3'
|
||||
secret_token 'd78fe08df56c9'
|
||||
migrate true
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
#### Actions
|
||||
|
||||
* `:deploy` – Create config files and run required deployments steps. *(default)*
|
||||
|
||||
#### Properties
|
||||
|
||||
* `path` – Base path for the application. *(name attribute)*
|
||||
* `app_module` – Top-level application module. Only needed for the :initializer
|
||||
style of secret token configuration. *(default: auto-detect)*
|
||||
* `database` – Database settings for Rails. See [the database section
|
||||
below](#database-parameters) for more information. *(option collector)*
|
||||
* `migrate` – Run database migrations. *(default: false)*
|
||||
* `precompile_assets` – Run `rake assets:precompile`. *(default: auto-detect)()
|
||||
* `rails_env` – Rails environment name. *(default: node.chef_environment)*
|
||||
* `secret_token` – Secret token for Rails session verification et al.
|
||||
* `secrets_mode` – Secrets configuration mode. Set to `:yaml` to generate a
|
||||
Rails 4.2 secrets.yml. Set to `:initializer` to update
|
||||
`config/initializers/secret_token.rb`. *(default: auto-detect)*
|
||||
|
||||
**NOTE:** At this time `secrets_mode :initializer` is not implemented.
|
||||
|
||||
#### Database Parameters
|
||||
|
||||
The database parameters can be set in three ways: URL, hash, and block.
|
||||
|
||||
If you have a single URL for the parameters, you can pass it directly to
|
||||
`database`:
|
||||
|
||||
```ruby
|
||||
rails do
|
||||
database 'mysql2://myuser@dbhost/myapp'
|
||||
end
|
||||
```
|
||||
|
||||
Passing a single URL will also set the `$DATABASE_URL` environment variable
|
||||
automatically for compatibility with Heroku-based applications.
|
||||
|
||||
As with other option collector resources, you can pass individual settings as
|
||||
either a hash or block:
|
||||
|
||||
```ruby
|
||||
rails do
|
||||
database do
|
||||
adapter 'mysql2'
|
||||
username 'myuser'
|
||||
host 'dbhost'
|
||||
database 'myapp'
|
||||
end
|
||||
end
|
||||
|
||||
rails do
|
||||
database({
|
||||
adapter: 'mysql2',
|
||||
username: 'myuser',
|
||||
host: 'dbhost',
|
||||
database: 'myapp',
|
||||
})
|
||||
end
|
||||
```
|
||||
|
||||
### `application_ruby`
|
||||
|
||||
The `application_ruby` resource installs a Ruby runtime for the deployment.
|
||||
|
||||
```ruby
|
||||
application '/srv/myapp' do
|
||||
ruby '2.2'
|
||||
end
|
||||
```
|
||||
|
||||
All actions and properties are the same as the [`ruby_runtime` resource](https://github.com/poise/poise-ruby#ruby_runtime).
|
||||
|
||||
### `application_ruby_gem`
|
||||
|
||||
The `application_ruby_gem` resource installs Ruby gems for the deployment.
|
||||
|
||||
```ruby
|
||||
application '/srv/myapp' do
|
||||
ruby_gem 'rake'
|
||||
end
|
||||
```
|
||||
|
||||
All actions and properties are the same as the [`ruby_gem` resource](https://github.com/poise/poise-ruby#ruby_gem).
|
||||
|
||||
### `application_ruby_execute`
|
||||
|
||||
The `application_ruby_execute` resource runs Ruby commands for the deployment.
|
||||
|
||||
```ruby
|
||||
application '/srv/myapp' do
|
||||
ruby_execute 'rake'
|
||||
end
|
||||
```
|
||||
|
||||
All actions and properties are the same as the [`ruby_execute` resource](https://github.com/poise/poise-ruby#ruby_execute),
|
||||
except that the `cwd`, `environment`, `group`, and `user` properties default to
|
||||
the application-level data if not specified.
|
||||
|
||||
### `application_thin`
|
||||
|
||||
The `application_thin` resource creates a service for `thin`.
|
||||
|
||||
```ruby
|
||||
application '/srv/myapp' do
|
||||
thin do
|
||||
port 8000
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
#### Actions
|
||||
|
||||
* `:enable` – Create, enable and start the service. *(default)*
|
||||
* `:disable` – Stop, disable, and destroy the service.
|
||||
* `:start` – Start the service.
|
||||
* `:stop` – Stop the service.
|
||||
* `:restart` – Stop and then start the service.
|
||||
* `:reload` – Send the configured reload signal to the service.
|
||||
|
||||
#### Properties
|
||||
|
||||
* `path` – Base path for the application. *(name attribute)*
|
||||
* `config_path` – Path to a Thin configuration file.
|
||||
* `port` – Port to listen on. *(default: 80)*
|
||||
* `service_name` – Name of the service to create. *(default: auto-detect)*
|
||||
* `user` – User to run the service as. *(default: application owner)*
|
||||
|
||||
### `application_unicorn`
|
||||
|
||||
The `application_unicorn` resource creates a service for `unicorn`.
|
||||
|
||||
```ruby
|
||||
application '/srv/myapp' do
|
||||
unicorn do
|
||||
port 8000
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
#### Actions
|
||||
|
||||
* `:enable` – Create, enable and start the service. *(default)*
|
||||
* `:disable` – Stop, disable, and destroy the service.
|
||||
* `:start` – Start the service.
|
||||
* `:stop` – Stop the service.
|
||||
* `:restart` – Stop and then start the service.
|
||||
* `:reload` – Send the configured reload signal to the service.
|
||||
|
||||
#### Properties
|
||||
|
||||
* `path` – Base path for the application. *(name attribute)*
|
||||
* `port` – Port to listen on. *(default: 80)*
|
||||
* `service_name` – Name of the service to create. *(default: auto-detect)*
|
||||
* `user` – User to run the service as. *(default: application owner)*
|
||||
|
||||
## Sponsors
|
||||
|
||||
Development sponsored by [Chef Software](https://www.chef.io/), [Symonds & Son](http://symondsandson.com/), and [Orion](https://www.orionlabs.co/).
|
||||
|
||||
The Poise test server infrastructure is sponsored by [Rackspace](https://rackspace.com/).
|
||||
|
||||
## License
|
||||
|
||||
Copyright 2015-2017, Noah Kantrowitz
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
@ -1,8 +1,5 @@
|
||||
#
|
||||
# Cookbook Name:: bluepill
|
||||
# Recipe:: rsyslog
|
||||
#
|
||||
# Copyright 2010-2015, Chef Software, Inc.
|
||||
# Copyright 2015-2017, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@ -17,12 +14,11 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe 'rsyslog::default'
|
||||
|
||||
template '/etc/rsyslog.d/bluepill.conf' do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0644'
|
||||
source 'bluepill_rsyslog.conf.erb'
|
||||
notifies :restart, "service[#{node['rsyslog']['service_name']}]"
|
||||
module PoiseApplicationRuby
|
||||
autoload :AppMixin, 'poise_application_ruby/app_mixin'
|
||||
autoload :Error, 'poise_application_ruby/error'
|
||||
autoload :Resources, 'poise_application_ruby/resources'
|
||||
autoload :ServiceMixin, 'poise_application_ruby/service_mixin'
|
||||
autoload :VERSION, 'poise_application_ruby/version'
|
||||
end
|
@ -0,0 +1,92 @@
|
||||
#
|
||||
# Copyright 2015-2017, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise/backports'
|
||||
require 'poise/utils'
|
||||
require 'poise_application/app_mixin'
|
||||
require 'poise_ruby/ruby_command_mixin'
|
||||
|
||||
|
||||
module PoiseApplicationRuby
|
||||
# A helper mixin for Ruby application resources and providers.
|
||||
#
|
||||
# @since 4.0.0
|
||||
module AppMixin
|
||||
include Poise::Utils::ResourceProviderMixin
|
||||
|
||||
# A helper mixin for Ruby application resources.
|
||||
module Resource
|
||||
include PoiseApplication::AppMixin::Resource
|
||||
include PoiseRuby::RubyCommandMixin::Resource
|
||||
|
||||
# @!attribute parent_ruby
|
||||
# Override the #parent_ruby from RubyCommandMixin to grok the
|
||||
# application level parent as a default value.
|
||||
# @return [PoiseRuby::Resources::RubyRuntime::Resource, nil]
|
||||
parent_attribute(:ruby, type: :ruby_runtime, optional: true, default: lazy { app_state_ruby.equal?(self) ? nil : app_state_ruby })
|
||||
|
||||
# @!attribute parent_bundle
|
||||
# Parent bundle install context.
|
||||
# @return [PoiseRuby::Resources::BundleInstall::Resource, nil]
|
||||
parent_attribute(:bundle, type: :ruby_runtime, optional: true, auto: false, default: lazy { app_state_bundle.equal?(self) ? nil : app_state_bundle })
|
||||
|
||||
# @attribute app_state_ruby
|
||||
# The application-level Ruby parent.
|
||||
# @return [PoiseRuby::Resources::RubyRuntime::Resource, nil]
|
||||
def app_state_ruby(ruby=Poise::NOT_PASSED)
|
||||
unless ruby == Poise::NOT_PASSED
|
||||
app_state[:ruby] = ruby
|
||||
end
|
||||
app_state[:ruby]
|
||||
end
|
||||
|
||||
# @attribute app_state_bundle
|
||||
# The application-level Bundle parent.
|
||||
# @return [PoiseRuby::Resources::BundleInstall::Resource, nil]
|
||||
def app_state_bundle(bundle=Poise::NOT_PASSED)
|
||||
unless bundle == Poise::NOT_PASSED
|
||||
app_state[:bundle] = bundle
|
||||
end
|
||||
app_state[:bundle]
|
||||
end
|
||||
|
||||
# A merged hash of environment variables for both the application state
|
||||
# and parent ruby.
|
||||
#
|
||||
# @return [Hash<String, String>]
|
||||
def app_state_environment_ruby
|
||||
env = app_state_environment
|
||||
env = env.merge(parent_ruby.ruby_environment) if parent_ruby
|
||||
env['BUNDLE_GEMFILE'] = parent_bundle.gemfile_path if parent_bundle
|
||||
env
|
||||
end
|
||||
|
||||
# Update ruby_from_parent to transfer {#parent_bundle} too.
|
||||
#
|
||||
# @param resource [Chef::Resource] Resource to inherit from.
|
||||
# @return [void]
|
||||
def ruby_from_parent(resource)
|
||||
super
|
||||
parent_bundle(resource.parent_bundle) if resource.parent_bundle
|
||||
end
|
||||
end
|
||||
|
||||
# A helper mixin for Ruby application providers.
|
||||
module Provider
|
||||
include PoiseApplication::AppMixin::Provider
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,17 @@
|
||||
#
|
||||
# Copyright 2015-2017, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_application_ruby/resources'
|
@ -0,0 +1,25 @@
|
||||
#
|
||||
# Copyright 2015-2017, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_application/error'
|
||||
|
||||
module PoiseApplicationRuby
|
||||
# Base exception class for poise-application-ruby errors.
|
||||
#
|
||||
# @since 4.0.0
|
||||
class Error < PoiseApplication::Error
|
||||
end
|
||||
end
|
@ -0,0 +1,25 @@
|
||||
#
|
||||
# Copyright 2015-2017, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_application_ruby/resources/bundle_install'
|
||||
require 'poise_application_ruby/resources/puma'
|
||||
require 'poise_application_ruby/resources/rackup'
|
||||
require 'poise_application_ruby/resources/rails'
|
||||
require 'poise_application_ruby/resources/ruby'
|
||||
require 'poise_application_ruby/resources/ruby_execute'
|
||||
require 'poise_application_ruby/resources/ruby_gem'
|
||||
require 'poise_application_ruby/resources/thin'
|
||||
require 'poise_application_ruby/resources/unicorn'
|
@ -0,0 +1,54 @@
|
||||
#
|
||||
# Copyright 2015-2017, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_ruby/resources/bundle_install'
|
||||
|
||||
require 'poise_application_ruby/app_mixin'
|
||||
|
||||
|
||||
module PoiseApplicationRuby
|
||||
module Resources
|
||||
# (see BundleInstall::Resource)
|
||||
# @since 4.0.0
|
||||
module BundleInstall
|
||||
# An `application_bundle_install` resource to install a
|
||||
# [Bundler](http://bundler.io/) Gemfile in a web application.
|
||||
#
|
||||
# @note
|
||||
# This resource is not idempotent itself, it will always run `bundle
|
||||
# install`.
|
||||
# @example
|
||||
# application '/srv/my_app' do
|
||||
# bundle_install
|
||||
# end
|
||||
class Resource < PoiseRuby::Resources::BundleInstall::Resource
|
||||
include PoiseApplicationRuby::AppMixin
|
||||
provides(:application_bundle_install)
|
||||
subclass_providers!
|
||||
|
||||
# Set this resource as the app_state's parent bundle.
|
||||
#
|
||||
# @api private
|
||||
def after_created
|
||||
super.tap do |val|
|
||||
app_state_bundle(self)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,86 @@
|
||||
#
|
||||
# Copyright 2015-2017, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'chef/provider'
|
||||
require 'chef/resource'
|
||||
|
||||
require 'poise_application_ruby/service_mixin'
|
||||
|
||||
module PoiseApplicationRuby
|
||||
module Resources
|
||||
# (see Puma::Resource)
|
||||
# @since 4.1.0
|
||||
module Puma
|
||||
# An `application_puma` resource to manage a puma web application
|
||||
# server.
|
||||
#
|
||||
# @since 4.1.0
|
||||
# @provides application_puma
|
||||
# @action enable
|
||||
# @action disable
|
||||
# @action start
|
||||
# @action stop
|
||||
# @action restart
|
||||
# @action reload
|
||||
# @example
|
||||
# application '/srv/myapp' do
|
||||
# git '...'
|
||||
# bundle_install
|
||||
# puma do
|
||||
# port 8080
|
||||
# end
|
||||
# end
|
||||
class Resource < Chef::Resource
|
||||
include PoiseApplicationRuby::ServiceMixin
|
||||
provides(:application_puma)
|
||||
|
||||
# @!attribute port
|
||||
# Port to bind to.
|
||||
attribute(:port, kind_of: [String, Integer], default: 80)
|
||||
end
|
||||
|
||||
# Provider for `application_puma`.
|
||||
#
|
||||
# @since 4.1.0
|
||||
# @see Resource
|
||||
# @provides application_puma
|
||||
class Provider < Chef::Provider
|
||||
include PoiseApplicationRuby::ServiceMixin
|
||||
provides(:application_puma)
|
||||
|
||||
private
|
||||
|
||||
# Find the path to the config.ru. If the resource path was to a
|
||||
# directory, apparent /config.ru.
|
||||
#
|
||||
# @return [String]
|
||||
def configru_path
|
||||
@configru_path ||= if ::File.directory?(new_resource.path)
|
||||
::File.join(new_resource.path, 'config.ru')
|
||||
else
|
||||
new_resource.path
|
||||
end
|
||||
end
|
||||
|
||||
# Set service resource options.
|
||||
def service_options(resource)
|
||||
super
|
||||
resource.ruby_command("puma --port #{new_resource.port} #{configru_path}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,70 @@
|
||||
#
|
||||
# Copyright 2015-2017, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'chef/provider'
|
||||
require 'chef/resource'
|
||||
|
||||
require 'poise_application_ruby/service_mixin'
|
||||
|
||||
|
||||
module PoiseApplicationRuby
|
||||
module Resources
|
||||
# (see Rackup::Resource)
|
||||
# @since 4.0.0
|
||||
module Rackup
|
||||
class Resource < Chef::Resource
|
||||
include PoiseApplicationRuby::ServiceMixin
|
||||
provides(:application_rackup)
|
||||
|
||||
# @!attribute port
|
||||
# TCP port to listen on. Defaults to 80.
|
||||
# @return [String, Integer]
|
||||
attribute(:port, kind_of: [String, Integer], default: 80)
|
||||
end
|
||||
|
||||
class Provider < Chef::Provider
|
||||
include PoiseApplicationRuby::ServiceMixin
|
||||
provides(:application_rackup)
|
||||
|
||||
private
|
||||
|
||||
# Find the path to the config.ru. If the resource path was to a
|
||||
# directory, apparent /config.ru.
|
||||
#
|
||||
# @return [String]
|
||||
def configru_path
|
||||
@configru_path ||= if ::File.directory?(new_resource.path)
|
||||
::File.join(new_resource.path, 'config.ru')
|
||||
else
|
||||
new_resource.path
|
||||
end
|
||||
end
|
||||
|
||||
# Set up service options for rackup.
|
||||
#
|
||||
# @param resource [PoiseService::Resource] Service resource.
|
||||
# @return [void]
|
||||
def service_options(resource)
|
||||
super
|
||||
resource.ruby_command("rackup --port #{new_resource.port}")
|
||||
resource.directory(::File.dirname(configru_path))
|
||||
# Older versions of rackup ignore all signals.
|
||||
resource.stop_signal('KILL')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,292 @@
|
||||
#
|
||||
# Copyright 2015-2017, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'chef/provider'
|
||||
require 'chef/resource'
|
||||
|
||||
require 'poise_application_ruby/app_mixin'
|
||||
require 'poise_application_ruby/error'
|
||||
|
||||
|
||||
module PoiseApplicationRuby
|
||||
module Resources
|
||||
# (see Rails::Resource)
|
||||
module Rails
|
||||
# An `application_rails` resource to configure Ruby on Rails applications.
|
||||
#
|
||||
# @since 4.0.0
|
||||
# @provides application_rails
|
||||
# @action deploy
|
||||
# @example
|
||||
# application '/srv/myapp' do
|
||||
# git '...'
|
||||
# bundle_install
|
||||
# rails do
|
||||
# database do
|
||||
# host node['rails_host']
|
||||
# end
|
||||
# end
|
||||
# unicorn do
|
||||
# port 8080
|
||||
# end
|
||||
# end
|
||||
class Resource < Chef::Resource
|
||||
include PoiseApplicationRuby::AppMixin
|
||||
provides(:application_rails)
|
||||
actions(:deploy)
|
||||
|
||||
# @!attribute app_module
|
||||
# Top-level application module. Only needed for the :initializer style
|
||||
# of secret token configuration, and generally auto-detected.
|
||||
# @return [String, false, nil]
|
||||
attribute(:app_module, kind_of: [String, FalseClass, NilClass], default: lazy { default_app_module })
|
||||
# @!attribute database
|
||||
# Option collector attribute for Rails database configuration.
|
||||
# @return [Hash]
|
||||
# @example Setting via block
|
||||
# database do
|
||||
# adapter 'postgresql'
|
||||
# database 'blog'
|
||||
# end
|
||||
# @example Setting via URL
|
||||
# database 'postgresql://localhost/blog'
|
||||
attribute(:database, option_collector: true, parser: :parse_database_url)
|
||||
# @!attribute database_config
|
||||
# Template content attribute for the contents of database.yml.
|
||||
# @todo Redo this doc to cover the actual attributes created.
|
||||
# @return [Poise::Helpers::TemplateContent]
|
||||
attribute(:database_config, template: true, default_source: 'database.yml.erb', default_options: lazy { default_database_options })
|
||||
# @!attribute migrate
|
||||
# Run database migrations. This is a bad idea for real apps. Please
|
||||
# do not use it.
|
||||
# @return [Boolean]
|
||||
attribute(:migrate, equal_to: [true, false], default: false)
|
||||
# @!attribute precompile_assets
|
||||
# Set to true to run rake assets:precompile. By default will try to
|
||||
# auto-detect if Sprockets is in use by looking at config/initializers.
|
||||
# @see #default_precompile_assets
|
||||
# @return [Boolean]
|
||||
attribute(:precompile_assets, equal_to: [true, false], default: lazy { default_precompile_assets })
|
||||
# @!attribute rails_env
|
||||
# Rails environment name. Defaults to the Chef environment name or
|
||||
# `production` if none is set.
|
||||
# @see #default_rails_env
|
||||
# @return [String]
|
||||
attribute(:rails_env, kind_of: String, default: lazy { default_rails_env })
|
||||
# @!attribute secret_token
|
||||
# Secret token for Rails session verification and other purposes. On
|
||||
# Rails 4.2 this will be used for secret_key_base. If not set, no
|
||||
# secrets configuration is written.
|
||||
# @return [String, false, nil]
|
||||
attribute(:secret_token, kind_of: [String, FalseClass, NilClass])
|
||||
# @!attribute secrets_config
|
||||
# Template content attribute for the contents of secrets.yml. Only
|
||||
# used when secrets_mode is :yaml.
|
||||
# @todo Redo this doc to cover the actual attributes created.
|
||||
# @return [Poise::Helpers::TemplateContent]
|
||||
attribute(:secrets_config, template: true, default_source: 'secrets.yml.erb', default_options: lazy { default_secrets_options })
|
||||
# @!attribute secrets_initializer
|
||||
# Template content attribute for the contents of secret_token.rb. Only
|
||||
# used when secrets_mode is :initializer.
|
||||
# @todo Redo this doc to cover the actual attributes created.
|
||||
# @return [Poise::Helpers::TemplateContent]
|
||||
attribute(:secrets_initializer, template: true, default_source: 'secret_token.rb.erb', default_options: lazy { default_secrets_options })
|
||||
# @!attribute secrets_mode
|
||||
# Secrets configuration mode. Set to `:yaml` to generate a Rails 4.2
|
||||
# secrets.yml. Set to `:initializer` to update
|
||||
# `config/initializers/secret_token.rb`. If unspecified this is
|
||||
# auto-detected based on what files exist.
|
||||
# @return [Symbol]
|
||||
attribute(:secrets_mode, equal_to: [:yaml, :initializer], default: lazy { default_secrets_mode })
|
||||
|
||||
private
|
||||
|
||||
# Check if we should run the precompile by default. Looks for the
|
||||
# assets initializer because that is not present with --skip-sprockets.
|
||||
#
|
||||
# @return [Boolean]
|
||||
def default_precompile_assets
|
||||
::File.exists?(::File.join(path, 'config', 'initializers', 'assets.rb'))
|
||||
end
|
||||
|
||||
# Check the default environment name.
|
||||
#
|
||||
# @return [String]
|
||||
def default_rails_env
|
||||
node.chef_environment == '_default' ? 'production' : node.chef_environment
|
||||
end
|
||||
|
||||
# Format a single URL for the database.yml
|
||||
#
|
||||
# @return [Hash]
|
||||
def parse_database_url(url)
|
||||
{'url' => url}
|
||||
end
|
||||
|
||||
# Default template variables for the database.yml.
|
||||
#
|
||||
# @return [Hash<Symbol, Object>]
|
||||
def default_database_options
|
||||
db_config = {'encoding' => 'utf8', 'reconnect' => true, 'pool' => 5}.merge(database)
|
||||
{
|
||||
config: {
|
||||
rails_env => db_config
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
# Check which secrets configuration mode is in use based on files.
|
||||
#
|
||||
# @return [Symbol]
|
||||
def default_secrets_mode
|
||||
::File.exists?(::File.join(path, 'config', 'initializers', 'secret_token.rb')) ? :initializer : :yaml
|
||||
end
|
||||
|
||||
# Default template variables for the secrets.yml and secret_token.rb.
|
||||
#
|
||||
# @return [Hash<Symbol, Object>]
|
||||
def default_secrets_options
|
||||
{
|
||||
yaml_config: {
|
||||
rails_env => {
|
||||
'secret_key_base' => secret_token,
|
||||
}
|
||||
},
|
||||
secret_token: secret_token,
|
||||
app_module: if secrets_mode == :initializer
|
||||
raise Error.new("Unable to extract app module for #{self}, please set app_module property") if !app_module || app_module.empty?
|
||||
app_module
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
# Default application module name.
|
||||
#
|
||||
# @return [String]
|
||||
def default_app_module
|
||||
IO.read(::File.join(path, 'config', 'initializers', 'secret_token.rb'))[/(\w+)::Application\.config\.secret_token/, 1]
|
||||
end
|
||||
end
|
||||
|
||||
# Provider for `application_rails`.
|
||||
#
|
||||
# @since 4.0.0
|
||||
# @see Resource
|
||||
# @provides application_rails
|
||||
class Provider < Chef::Provider
|
||||
include PoiseApplicationRuby::AppMixin
|
||||
provides(:application_rails)
|
||||
|
||||
# `deploy` action for `application_rails`. Ensure all configuration
|
||||
# files are created and other deploy tasks resolved.
|
||||
#
|
||||
# @return [void]
|
||||
def action_deploy
|
||||
set_state
|
||||
notifying_block do
|
||||
write_database_yml unless new_resource.database.empty?
|
||||
write_secrets_config if new_resource.secret_token
|
||||
precompile_assets if new_resource.precompile_assets
|
||||
run_migrations if new_resource.migrate
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Set app_state variables for future services et al.
|
||||
def set_state
|
||||
new_resource.app_state_environment[:RAILS_ENV] = new_resource.rails_env
|
||||
new_resource.app_state_environment[:DATABASE_URL] = new_resource.database['url'] if new_resource.database['url']
|
||||
end
|
||||
|
||||
# Create a database.yml config file.
|
||||
def write_database_yml
|
||||
file ::File.join(new_resource.path, 'config', 'database.yml') do
|
||||
user new_resource.parent.owner
|
||||
group new_resource.parent.group
|
||||
mode '640'
|
||||
content new_resource.database_config_content
|
||||
end
|
||||
end
|
||||
|
||||
# Dispatch to the correct config writer based on the mode.
|
||||
def write_secrets_config
|
||||
case new_resource.secrets_mode
|
||||
when :yaml
|
||||
write_secrets_yml
|
||||
when :initializer
|
||||
write_secrets_initializer
|
||||
else
|
||||
raise Error.new("Unknown secrets mode #{new_resource.secrets_mode.inspect}")
|
||||
end
|
||||
end
|
||||
|
||||
# Write a Rails 4.2-style secrets.yml.
|
||||
def write_secrets_yml
|
||||
file ::File.join(new_resource.path, 'config', 'secrets.yml') do
|
||||
user new_resource.parent.owner
|
||||
group new_resource.parent.group
|
||||
mode '640'
|
||||
content new_resource.secrets_config_content
|
||||
sensitive true
|
||||
end
|
||||
end
|
||||
|
||||
# In-place update a config/initializers/secret_token.rb file.
|
||||
def write_secrets_initializer
|
||||
file ::File.join(new_resource.path, 'config', 'initializers', 'secret_token.rb') do
|
||||
user new_resource.parent.owner
|
||||
group new_resource.parent.group
|
||||
mode '640'
|
||||
content new_resource.secrets_initializer_content
|
||||
sensitive true
|
||||
end
|
||||
end
|
||||
|
||||
# Precompile assets using the rake task.
|
||||
def precompile_assets
|
||||
# Currently this will always run so the resource will always update :-/
|
||||
# Better fix would be to shell_out! and parse the output?
|
||||
ruby_execute 'rake assets:precompile' do
|
||||
command %w{rake assets:precompile}
|
||||
user new_resource.parent.owner
|
||||
group new_resource.parent.group
|
||||
cwd new_resource.parent.path
|
||||
environment new_resource.app_state_environment
|
||||
ruby_from_parent new_resource
|
||||
parent_bundle new_resource.parent_bundle if new_resource.parent_bundle
|
||||
end
|
||||
end
|
||||
|
||||
# Run database migrations using the rake task.
|
||||
def run_migrations
|
||||
# Currently this will always run so the resource will always update :-/
|
||||
# Better fix would be to shell_out! and parse the output?
|
||||
ruby_execute 'rake db:migrate' do
|
||||
command %w{rake db:migrate}
|
||||
user new_resource.parent.owner
|
||||
group new_resource.parent.group
|
||||
cwd new_resource.parent.path
|
||||
environment new_resource.app_state_environment
|
||||
ruby_from_parent new_resource
|
||||
parent_bundle new_resource.parent_bundle if new_resource.parent_bundle
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Copyright 2015-2017, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_ruby/resources/ruby_runtime'
|
||||
|
||||
require 'poise_application_ruby/app_mixin'
|
||||
|
||||
|
||||
module PoiseApplicationRuby
|
||||
module Resources
|
||||
# (see Ruby::Resource)
|
||||
# @since 4.0.0
|
||||
module Ruby
|
||||
# An `application_ruby` resource to manage Ruby runtimes
|
||||
# inside an Application cookbook deployment.
|
||||
#
|
||||
# @provides application_ruby
|
||||
# @provides application_ruby_runtime
|
||||
# @action install
|
||||
# @action uninstall
|
||||
# @example
|
||||
# application '/app' do
|
||||
# ruby '2'
|
||||
# end
|
||||
class Resource < PoiseRuby::Resources::RubyRuntime::Resource
|
||||
include PoiseApplicationRuby::AppMixin
|
||||
provides(:application_ruby)
|
||||
provides(:application_ruby_runtime)
|
||||
container_default(false)
|
||||
subclass_providers!
|
||||
|
||||
# Rebind the parent class #gem_binary instead of the one from
|
||||
# RubyCommandMixin (by way of AppMixin)
|
||||
def gem_binary(*args, &block)
|
||||
self.class.superclass.instance_method(:gem_binary).bind(self).call(*args, &block)
|
||||
end
|
||||
|
||||
# Set this resource as the app_state's parent ruby.
|
||||
#
|
||||
# @api private
|
||||
def after_created
|
||||
super.tap do |val|
|
||||
app_state_ruby(self)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,89 @@
|
||||
#
|
||||
# Copyright 2015-2017, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_ruby/resources/ruby_execute'
|
||||
|
||||
require 'poise_application_ruby/app_mixin'
|
||||
|
||||
|
||||
module PoiseApplicationRuby
|
||||
module Resources
|
||||
# (see RubyExecute::Resource)
|
||||
# @since 4.0.0
|
||||
module RubyExecute
|
||||
# An `application_ruby_execute` resource to run Ruby commands inside an
|
||||
# Application cookbook deployment.
|
||||
#
|
||||
# @provides application_ruby_execute
|
||||
# @action run
|
||||
# @example
|
||||
# application '/srv/myapp' do
|
||||
# ruby_execute 'rake build'
|
||||
# end
|
||||
class Resource < PoiseRuby::Resources::RubyExecute::Resource
|
||||
include PoiseApplicationRuby::AppMixin
|
||||
provides(:application_ruby_execute)
|
||||
|
||||
def initialize(*args)
|
||||
super
|
||||
# Clear some instance variables so my defaults work.
|
||||
remove_instance_variable(:@cwd)
|
||||
remove_instance_variable(:@group)
|
||||
remove_instance_variable(:@user)
|
||||
end
|
||||
|
||||
# #!attribute cwd
|
||||
# Override the default directory to be the app path if unspecified.
|
||||
# @return [String]
|
||||
attribute(:cwd, kind_of: [String, NilClass, FalseClass], default: lazy { parent && parent.path })
|
||||
|
||||
# #!attribute group
|
||||
# Override the default group to be the app group if unspecified.
|
||||
# @return [String, Integer]
|
||||
attribute(:group, kind_of: [String, Integer, NilClass, FalseClass], default: lazy { parent && parent.group })
|
||||
|
||||
# #!attribute user
|
||||
# Override the default user to be the app owner if unspecified.
|
||||
# @return [String, Integer]
|
||||
attribute(:user, kind_of: [String, Integer, NilClass, FalseClass], default: lazy { parent && parent.owner })
|
||||
end
|
||||
|
||||
# The default provider for `application_ruby_execute`.
|
||||
#
|
||||
# @see Resource
|
||||
# @provides application_ruby_execute
|
||||
class Provider < PoiseRuby::Resources::RubyExecute::Provider
|
||||
provides(:application_ruby_execute)
|
||||
|
||||
private
|
||||
|
||||
# Override environment to add the application envivonrment instead.
|
||||
#
|
||||
# @return [Hash]
|
||||
def environment
|
||||
super.tap do |environment|
|
||||
# Don't use the app_state_environment_ruby because we already have
|
||||
# those values in place.
|
||||
environment.update(new_resource.app_state_environment)
|
||||
# Re-apply the resource environment for correct ordering.
|
||||
environment.update(new_resource.environment) if new_resource.environment
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,46 @@
|
||||
#
|
||||
# Copyright 2015-2017, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise_ruby/resources/ruby_gem'
|
||||
|
||||
require 'poise_application_ruby/app_mixin'
|
||||
|
||||
|
||||
module PoiseApplicationRuby
|
||||
module Resources
|
||||
# (see RubyGem::Resource)
|
||||
# @since 4.0.0
|
||||
module RubyGem
|
||||
# An `application_ruby_gem` resource to install Ruby gems inside an
|
||||
# Application cookbook deployment.
|
||||
#
|
||||
# @provides application_ruby_gem
|
||||
# @action install
|
||||
# @action upgrade
|
||||
# @action remove
|
||||
# @example
|
||||
# application '/srv/myapp' do
|
||||
# ruby_gem 'rack'
|
||||
# end
|
||||
class Resource < PoiseRuby::Resources::RubyGem::Resource
|
||||
include PoiseApplicationRuby::AppMixin
|
||||
provides(:application_ruby_gem)
|
||||
subclass_providers!
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,64 @@
|
||||
#
|
||||
# Copyright 2015-2017, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'chef/provider'
|
||||
require 'chef/resource'
|
||||
|
||||
require 'poise_application_ruby/service_mixin'
|
||||
|
||||
|
||||
module PoiseApplicationRuby
|
||||
module Resources
|
||||
# (see Thin::Resource)
|
||||
# @since 4.0.0
|
||||
module Thin
|
||||
class Resource < Chef::Resource
|
||||
include PoiseApplicationRuby::ServiceMixin
|
||||
provides(:application_thin)
|
||||
|
||||
attribute(:port, kind_of: [String, Integer], default: 80)
|
||||
attribute(:config_path, kind_of: String)
|
||||
end
|
||||
|
||||
class Provider < Chef::Provider
|
||||
include PoiseApplicationRuby::ServiceMixin
|
||||
provides(:application_thin)
|
||||
|
||||
private
|
||||
|
||||
# Find the path to the config.ru. If the resource path was to a
|
||||
# directory, apparent /config.ru.
|
||||
#
|
||||
# @return [String]
|
||||
def configru_path
|
||||
@configru_path ||= if ::File.directory?(new_resource.path)
|
||||
::File.join(new_resource.path, 'config.ru')
|
||||
else
|
||||
new_resource.path
|
||||
end
|
||||
end
|
||||
|
||||
# (see PoiseApplication::ServiceMixin#service_options)
|
||||
def service_options(resource)
|
||||
super
|
||||
cmd = "thin --rackup #{configru_path} --port #{new_resource.port}"
|
||||
cmd << " --config #{::File.expand_path(new_resource.config_path, new_resource.path)}" if new_resource.config_path
|
||||
resource.ruby_command(cmd)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,87 @@
|
||||
#
|
||||
# Copyright 2015-2017, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'chef/provider'
|
||||
require 'chef/resource'
|
||||
|
||||
require 'poise_application_ruby/service_mixin'
|
||||
|
||||
|
||||
module PoiseApplicationRuby
|
||||
module Resources
|
||||
# (see Unicorn::Resource)
|
||||
# @since 4.0.0
|
||||
module Unicorn
|
||||
# An `application_unicorn` resource to manage a unicorn web application
|
||||
# server.
|
||||
#
|
||||
# @since 4.0.0
|
||||
# @provides application_unicorn
|
||||
# @action enable
|
||||
# @action disable
|
||||
# @action start
|
||||
# @action stop
|
||||
# @action restart
|
||||
# @action reload
|
||||
# @example
|
||||
# application '/srv/myapp' do
|
||||
# git '...'
|
||||
# bundle_install
|
||||
# unicorn do
|
||||
# port 8080
|
||||
# end
|
||||
# end
|
||||
class Resource < Chef::Resource
|
||||
include PoiseApplicationRuby::ServiceMixin
|
||||
provides(:application_unicorn)
|
||||
|
||||
# @!attribute port
|
||||
# Port to bind to.
|
||||
attribute(:port, kind_of: [String, Integer], default: 80)
|
||||
end
|
||||
|
||||
# Provider for `application_unicorn`.
|
||||
#
|
||||
# @since 4.0.0
|
||||
# @see Resource
|
||||
# @provides application_unicorn
|
||||
class Provider < Chef::Provider
|
||||
include PoiseApplicationRuby::ServiceMixin
|
||||
provides(:application_unicorn)
|
||||
|
||||
private
|
||||
|
||||
# Find the path to the config.ru. If the resource path was to a
|
||||
# directory, apparent /config.ru.
|
||||
#
|
||||
# @return [String]
|
||||
def configru_path
|
||||
@configru_path ||= if ::File.directory?(new_resource.path)
|
||||
::File.join(new_resource.path, 'config.ru')
|
||||
else
|
||||
new_resource.path
|
||||
end
|
||||
end
|
||||
|
||||
# Set service resource options.
|
||||
def service_options(resource)
|
||||
super
|
||||
resource.ruby_command("unicorn --port #{new_resource.port} #{configru_path}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,74 @@
|
||||
#
|
||||
# Copyright 2015-2017, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'poise/utils'
|
||||
require 'poise_application/service_mixin'
|
||||
require 'poise_languages/utils'
|
||||
require 'poise_ruby/bundler_mixin'
|
||||
|
||||
require 'poise_application_ruby/app_mixin'
|
||||
|
||||
|
||||
module PoiseApplicationRuby
|
||||
# A helper mixin for Ruby service resources and providers.
|
||||
#
|
||||
# @since 4.0.0
|
||||
module ServiceMixin
|
||||
include Poise::Utils::ResourceProviderMixin
|
||||
|
||||
# A helper mixin for Ruby service resources.
|
||||
module Resource
|
||||
include PoiseApplication::ServiceMixin::Resource
|
||||
include PoiseApplicationRuby::AppMixin::Resource
|
||||
end
|
||||
|
||||
# A helper mixin for Ruby service providers.
|
||||
module Provider
|
||||
include PoiseApplication::ServiceMixin::Provider
|
||||
include PoiseApplicationRuby::AppMixin::Provider
|
||||
include PoiseRuby::RubyCommandMixin::Provider
|
||||
include PoiseRuby::BundlerMixin
|
||||
|
||||
# Set up the service for running Ruby stuff.
|
||||
def service_options(resource)
|
||||
super
|
||||
# Closure scoping for #ruby_command below.
|
||||
self_ = self
|
||||
# Create a new singleton method that fills in Python for you.
|
||||
resource.define_singleton_method(:ruby_command) do |val|
|
||||
path = self_.new_resource.app_state_environment_ruby['PATH'] || ENV['PATH']
|
||||
cmd = if self_.new_resource.parent_bundle
|
||||
bundle_exec_command(val, path: path)
|
||||
else
|
||||
# Insert the gem executable directory at the front of the path.
|
||||
gem_environment = self_.send(:ruby_shell_out!, self_.new_resource.gem_binary, 'environment')
|
||||
matches = gem_environment.stdout.scan(/EXECUTABLE DIRECTORY: (.*)$/).first
|
||||
if matches
|
||||
Chef::Log.debug("[#{new_resource}] Prepending gem executable directory #{matches.first} to existing $PATH (#{path})")
|
||||
path = "#{matches.first}:#{path}"
|
||||
end
|
||||
"#{self_.new_resource.ruby} #{PoiseLanguages::Utils.absolute_command(val, path: path)}"
|
||||
end
|
||||
resource.command(cmd)
|
||||
end
|
||||
# Include env vars as needed.
|
||||
resource.environment.update(new_resource.parent_ruby.ruby_environment) if new_resource.parent_ruby
|
||||
resource.environment['BUNDLE_GEMFILE'] = new_resource.parent_bundle.gemfile_path if new_resource.parent_bundle
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright 2015-2017, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
module PoiseApplicationRuby
|
||||
VERSION = '4.1.0'
|
||||
end
|
19
cookbooks/application_ruby/libraries/default.rb
Normal file
19
cookbooks/application_ruby/libraries/default.rb
Normal file
@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright 2015-2017, Noah Kantrowitz
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
raise 'Halite is not compatible with no_lazy_load false, please set no_lazy_load true in your Chef configuration file.' unless Chef::Config[:no_lazy_load]
|
||||
$LOAD_PATH << File.expand_path('../../files/halite_gem', __FILE__)
|
||||
require "poise_application_ruby/cheftie"
|
1
cookbooks/application_ruby/metadata.json
Normal file
1
cookbooks/application_ruby/metadata.json
Normal file
File diff suppressed because one or more lines are too long
3
cookbooks/application_ruby/templates/database.yml.erb
Normal file
3
cookbooks/application_ruby/templates/database.yml.erb
Normal file
@ -0,0 +1,3 @@
|
||||
# Generated by Chef for <%= @new_resource.to_s %>
|
||||
|
||||
<%= @config.to_yaml %>
|
3
cookbooks/application_ruby/templates/secret_token.rb.erb
Normal file
3
cookbooks/application_ruby/templates/secret_token.rb.erb
Normal file
@ -0,0 +1,3 @@
|
||||
# Generated by Chef for <%= @new_resource.to_s %>
|
||||
|
||||
<%= @app_module %>::Application.config.secret_token = <%= @secret_token.inspect %>
|
3
cookbooks/application_ruby/templates/secrets.yml.erb
Normal file
3
cookbooks/application_ruby/templates/secrets.yml.erb
Normal file
@ -0,0 +1,3 @@
|
||||
# Generated by Chef for <%= @new_resource.to_s %>
|
||||
|
||||
<%= @yaml_config.to_yaml %>
|
1
cookbooks/ark/.foodcritic
Normal file
1
cookbooks/ark/.foodcritic
Normal file
@ -0,0 +1 @@
|
||||
~FC016
|
@ -2,6 +2,11 @@
|
||||
|
||||
This file is used to list changes made in each version of the ark cookbook.
|
||||
|
||||
## 3.0.0 (2017-04-05)
|
||||
- Rewrite of resource to custom resources.
|
||||
- Remove EOL platforms from testing.
|
||||
- Update zlib URL
|
||||
-
|
||||
## 2.2.1 (2016-12-16)
|
||||
- Use Ohai root_group attribute to avoid trying to set the group to root on BSD/macOS.
|
||||
- Add missing accessor for owner property
|
||||
|
@ -16,7 +16,7 @@ ark 'pig' do
|
||||
end
|
||||
```
|
||||
|
||||
The provider will:
|
||||
The `ark` resource will:
|
||||
|
||||
- fetch it to to `/var/cache/chef/`
|
||||
- unpack it to the default path (`/usr/local/pig-0.8.0`)
|
||||
@ -44,7 +44,7 @@ Should work on common Unix/Linux systems with typical userland utilities like ta
|
||||
|
||||
### Chef
|
||||
|
||||
- Chef 12.1+
|
||||
- Chef 12.5+
|
||||
|
||||
### Cookbooks
|
||||
|
||||
@ -66,7 +66,7 @@ Customize the attributes to suit site specific conventions and defaults.
|
||||
|
||||
## Resources
|
||||
|
||||
- `ark` - does the extract/build/configure dance
|
||||
- `ark` - does the extract/build/configure
|
||||
|
||||
### Actions
|
||||
|
||||
@ -281,7 +281,7 @@ You can also supply the file extension in case the file extension can not be det
|
||||
- Copyright: 2011, Philip (flip) Kromer - Infochimps, Inc
|
||||
- Copyright: 2012, Bryan W. Berry
|
||||
- Copyright: 2012, Denis Barishev
|
||||
- Copyright: 2013-2016, Chef Software, Inc
|
||||
- Copyright: 2013-2017, Chef Software, Inc
|
||||
- Copyright: 2014, Bloomberg L.P.
|
||||
|
||||
```
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Cookbook Name:: ark
|
||||
# Cookbook:: ark
|
||||
# Attributes:: default
|
||||
#
|
||||
#
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,503 +0,0 @@
|
||||
#
|
||||
# Cookbook Name:: ark
|
||||
# Provider:: Ark
|
||||
#
|
||||
# Author:: Bryan W. Berry <bryan.berry@gmail.com>
|
||||
# Author:: Sean OMeara <someara@chef.io
|
||||
# Author:: John Bellone <jbellone@bloomberg.net>
|
||||
# Copyright 2012, Bryan W. Berry
|
||||
# Copyright 2013-2016, Chef Software, Inc.
|
||||
# Copyright 2014, Bloomberg L.P.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
use_inline_resources
|
||||
include ::Ark::ProviderHelpers
|
||||
|
||||
#################
|
||||
# action :install
|
||||
#################
|
||||
action :install do
|
||||
show_deprecations
|
||||
set_paths
|
||||
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
remote_file new_resource.release_file do
|
||||
Chef::Log.debug('DEBUG: new_resource.release_file')
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
backup new_resource.backup
|
||||
end
|
||||
|
||||
# unpack based on file extension
|
||||
execute "unpack #{new_resource.release_file}" do
|
||||
command unpack_command
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# usually on windows there is no central directory with executables where the applications are linked
|
||||
unless node['platform_family'] == 'windows'
|
||||
# symlink binaries
|
||||
new_resource.has_binaries.each do |bin|
|
||||
link ::File.join(new_resource.prefix_bin, ::File.basename(bin)) do
|
||||
to ::File.join(new_resource.path, bin)
|
||||
end
|
||||
end
|
||||
|
||||
# action_link_paths
|
||||
link new_resource.home_dir do
|
||||
to new_resource.path
|
||||
end
|
||||
|
||||
# Add to path for interactive bash sessions
|
||||
template "/etc/profile.d/#{new_resource.name}.sh" do
|
||||
cookbook 'ark'
|
||||
source 'add_to_path.sh.erb'
|
||||
owner 'root'
|
||||
group node['root_group']
|
||||
mode '0755'
|
||||
cookbook 'ark'
|
||||
variables(directory: "#{new_resource.path}/bin")
|
||||
only_if { new_resource.append_env_path }
|
||||
end
|
||||
end
|
||||
|
||||
# Add to path for the current chef-client converge.
|
||||
bin_path = ::File.join(new_resource.path, 'bin')
|
||||
ruby_block "adding '#{bin_path}' to chef-client ENV['PATH']" do
|
||||
block do
|
||||
ENV['PATH'] = bin_path + ':' + ENV['PATH']
|
||||
end
|
||||
only_if do
|
||||
new_resource.append_env_path && ENV['PATH'].scan(bin_path).empty?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
##############
|
||||
# action :put
|
||||
##############
|
||||
action :put do
|
||||
show_deprecations
|
||||
set_put_paths
|
||||
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# download
|
||||
remote_file new_resource.release_file do
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
backup new_resource.backup
|
||||
end
|
||||
|
||||
# unpack based on file extension
|
||||
execute "unpack #{new_resource.release_file}" do
|
||||
command unpack_command
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
###########################
|
||||
# action :dump
|
||||
###########################
|
||||
action :dump do
|
||||
show_deprecations
|
||||
set_dump_paths
|
||||
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# download
|
||||
remote_file new_resource.release_file do
|
||||
Chef::Log.debug("DEBUG: new_resource.release_file #{new_resource.release_file}")
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# unpack based on file extension
|
||||
execute "unpack #{new_resource.release_file}" do
|
||||
command dump_command
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
###########################
|
||||
# action :unzip
|
||||
###########################
|
||||
action :unzip do
|
||||
show_deprecations
|
||||
set_dump_paths
|
||||
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# download
|
||||
remote_file new_resource.release_file do
|
||||
Chef::Log.debug("DEBUG: new_resource.release_file #{new_resource.release_file}")
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# unpack based on file extension
|
||||
execute "unpack #{new_resource.release_file}" do
|
||||
command unzip_command
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
#####################
|
||||
# action :cherry_pick
|
||||
#####################
|
||||
action :cherry_pick do
|
||||
show_deprecations
|
||||
set_dump_paths
|
||||
Chef::Log.debug("DEBUG: new_resource.creates #{new_resource.creates}")
|
||||
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[cherry_pick #{new_resource.creates} from #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# download
|
||||
remote_file new_resource.release_file do
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[cherry_pick #{new_resource.creates} from #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
execute "cherry_pick #{new_resource.creates} from #{new_resource.release_file}" do
|
||||
command cherry_pick_command
|
||||
creates "#{new_resource.path}/#{new_resource.creates}"
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
###########################
|
||||
# action :install_with_make
|
||||
###########################
|
||||
action :install_with_make do
|
||||
show_deprecations
|
||||
set_paths
|
||||
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
remote_file new_resource.release_file do
|
||||
Chef::Log.debug('DEBUG: new_resource.release_file')
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# unpack based on file extension
|
||||
execute "unpack #{new_resource.release_file}" do
|
||||
command unpack_command
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
notifies :run, "execute[autogen #{new_resource.path}]"
|
||||
notifies :run, "execute[configure #{new_resource.path}]"
|
||||
notifies :run, "execute[make #{new_resource.path}]"
|
||||
notifies :run, "execute[make install #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute "autogen #{new_resource.path}" do
|
||||
command './autogen.sh'
|
||||
only_if { ::File.exist? "#{new_resource.path}/autogen.sh" }
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
action :nothing
|
||||
ignore_failure true
|
||||
end
|
||||
|
||||
execute "configure #{new_resource.path}" do
|
||||
command "./configure #{new_resource.autoconf_opts.join(' ')}"
|
||||
only_if { ::File.exist? "#{new_resource.path}/configure" }
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute "make #{new_resource.path}" do
|
||||
command "make #{new_resource.make_opts.join(' ')}"
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute "make install #{new_resource.path}" do
|
||||
command "make install #{new_resource.make_opts.join(' ')}"
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
action :setup_py_build do
|
||||
show_deprecations
|
||||
set_paths
|
||||
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
remote_file new_resource.release_file do
|
||||
Chef::Log.debug('DEBUG: new_resource.release_file')
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# unpack based on file extension
|
||||
execute "unpack #{new_resource.release_file}" do
|
||||
command unpack_command
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
notifies :run, "execute[python setup.py build #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute "python setup.py build #{new_resource.path}" do
|
||||
command "python setup.py build #{new_resource.make_opts.join(' ')}"
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
action :setup_py_install do
|
||||
show_deprecations
|
||||
set_paths
|
||||
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
remote_file new_resource.release_file do
|
||||
Chef::Log.debug('DEBUG: new_resource.release_file')
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# unpack based on file extension
|
||||
execute "unpack #{new_resource.release_file}" do
|
||||
command unpack_command
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
notifies :run, "execute[python setup.py install #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute "python setup.py install #{new_resource.path}" do
|
||||
command "python setup.py install #{new_resource.make_opts.join(' ')}"
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
action :setup_py do
|
||||
show_deprecations
|
||||
set_paths
|
||||
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
remote_file new_resource.release_file do
|
||||
Chef::Log.debug('DEBUG: new_resource.release_file')
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# unpack based on file extension
|
||||
execute "unpack #{new_resource.release_file}" do
|
||||
command unpack_command
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
notifies :run, "execute[python setup.py #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute "python setup.py #{new_resource.path}" do
|
||||
command "python setup.py #{new_resource.make_opts.join(' ')}"
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
action :configure do
|
||||
show_deprecations
|
||||
set_paths
|
||||
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
remote_file new_resource.release_file do
|
||||
Chef::Log.debug('DEBUG: new_resource.release_file')
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# unpack based on file extension
|
||||
execute "unpack #{new_resource.release_file}" do
|
||||
command unpack_command
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
notifies :run, "execute[autogen #{new_resource.path}]"
|
||||
notifies :run, "execute[configure #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute "autogen #{new_resource.path}" do
|
||||
command './autogen.sh'
|
||||
only_if { ::File.exist? "#{new_resource.path}/autogen.sh" }
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
action :nothing
|
||||
ignore_failure true
|
||||
end
|
||||
|
||||
execute "configure #{new_resource.path}" do
|
||||
command "./configure #{new_resource.autoconf_opts.join(' ')}"
|
||||
only_if { ::File.exist? "#{new_resource.path}/configure" }
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
action :nothing
|
||||
end
|
||||
end
|
@ -1,9 +1,9 @@
|
||||
#
|
||||
# Cookbook Name:: ark
|
||||
# Cookbook:: ark
|
||||
# Recipe:: default
|
||||
#
|
||||
# Author:: Bryan W. Berry <bryan.berry@gmail.com>
|
||||
# Copyright 2012, Bryan W. Berry
|
||||
# Copyright:: 2012-2017, Bryan W. Berry
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -1,9 +1,10 @@
|
||||
#
|
||||
# Cookbook Name:: ark
|
||||
# Cookbook:: ark
|
||||
# Resource:: Ark
|
||||
#
|
||||
# Author:: Bryan W. Berry <bryan.berry@gmail.com>
|
||||
# Copyright 2012, Bryan W. Berry
|
||||
# Copyright:: 2012-2017, Bryan W. Berry
|
||||
# Copyright:: 2016-2017, Chef Software Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@ -18,53 +19,510 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
actions(
|
||||
:cherry_pick,
|
||||
:configure,
|
||||
:dump,
|
||||
:install,
|
||||
:install_with_make,
|
||||
:put,
|
||||
:setup_py,
|
||||
:setup_py_build,
|
||||
:setup_py_install,
|
||||
:unzip
|
||||
)
|
||||
property :owner, String
|
||||
property :group, [String, Integer], default: 0
|
||||
property :url, String, required: true
|
||||
property :path, String
|
||||
property :full_path, String
|
||||
property :append_env_path, [true, false], default: false
|
||||
property :checksum, regex: /^[a-zA-Z0-9]{64}$/, default: nil
|
||||
property :has_binaries, Array, default: []
|
||||
property :creates, String
|
||||
property :release_file, String, default: ''
|
||||
property :strip_leading_dir, [true, false, NilClass]
|
||||
property :strip_components, Integer, default: 1
|
||||
property :mode, [Integer, String], default: 0755
|
||||
property :prefix_root, String
|
||||
property :prefix_home, String
|
||||
property :prefix_bin, String
|
||||
property :version, String
|
||||
property :home_dir, String
|
||||
property :win_install_dir, String
|
||||
property :environment, Hash, default: {}
|
||||
property :autoconf_opts, Array, default: []
|
||||
property :make_opts, Array, default: []
|
||||
property :home_dir, String
|
||||
property :autoconf_opts, Array, default: []
|
||||
property :extension, String
|
||||
property :backup, [FalseClass, Integer], default: 5
|
||||
|
||||
default_action :install
|
||||
#################
|
||||
# action :install
|
||||
#################
|
||||
action :install do
|
||||
show_deprecations
|
||||
set_paths
|
||||
|
||||
attr_accessor :extension,
|
||||
:home_dir,
|
||||
:owner,
|
||||
:path,
|
||||
:prefix_bin,
|
||||
:prefix_root,
|
||||
:release_file,
|
||||
:version
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
attribute :owner, kind_of: String, default: nil
|
||||
attribute :group, kind_of: [String, Integer], default: 0
|
||||
attribute :url, kind_of: String, required: true
|
||||
attribute :path, kind_of: String, default: nil
|
||||
attribute :full_path, kind_of: String, default: nil
|
||||
attribute :append_env_path, kind_of: [TrueClass, FalseClass], default: false
|
||||
attribute :checksum, regex: /^[a-zA-Z0-9]{64}$/, default: nil
|
||||
attribute :has_binaries, kind_of: Array, default: []
|
||||
attribute :creates, kind_of: String, default: nil
|
||||
attribute :release_file, kind_of: String, default: ''
|
||||
attribute :strip_leading_dir, kind_of: [TrueClass, FalseClass, NilClass]
|
||||
attribute :strip_components, kind_of: Integer, default: 1
|
||||
attribute :mode, kind_of: Integer, default: 0755
|
||||
attribute :prefix_root, kind_of: String, default: nil
|
||||
attribute :prefix_home, kind_of: String, default: nil
|
||||
attribute :prefix_bin, kind_of: String, default: nil
|
||||
attribute :version, kind_of: String, default: nil
|
||||
attribute :home_dir, kind_of: String, default: nil
|
||||
attribute :win_install_dir, kind_of: String, default: nil
|
||||
attribute :environment, kind_of: Hash, default: {}
|
||||
attribute :autoconf_opts, kind_of: Array, default: []
|
||||
attribute :make_opts, kind_of: Array, default: []
|
||||
attribute :home_dir, kind_of: String, default: nil
|
||||
attribute :autoconf_opts, kind_of: Array, default: []
|
||||
attribute :extension, kind_of: String
|
||||
attribute :backup, kind_of: [FalseClass, Integer], default: 5
|
||||
remote_file new_resource.release_file do
|
||||
Chef::Log.debug('DEBUG: new_resource.release_file')
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
backup new_resource.backup
|
||||
end
|
||||
|
||||
# unpack based on file extension
|
||||
execute "unpack #{new_resource.release_file}" do
|
||||
command unpack_command
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# usually on windows there is no central directory with executables where the applications are linked
|
||||
unless node['platform_family'] == 'windows'
|
||||
# symlink binaries
|
||||
new_resource.has_binaries.each do |bin|
|
||||
link ::File.join(new_resource.prefix_bin, ::File.basename(bin)) do
|
||||
to ::File.join(new_resource.path, bin)
|
||||
end
|
||||
end
|
||||
|
||||
# action_link_paths
|
||||
link new_resource.home_dir do
|
||||
to new_resource.path
|
||||
end
|
||||
|
||||
# Add to path for interactive bash sessions
|
||||
template "/etc/profile.d/#{new_resource.name}.sh" do
|
||||
cookbook 'ark'
|
||||
source 'add_to_path.sh.erb'
|
||||
owner 'root'
|
||||
group node['root_group']
|
||||
mode '0755'
|
||||
cookbook 'ark'
|
||||
variables(directory: "#{new_resource.path}/bin")
|
||||
only_if { new_resource.append_env_path }
|
||||
end
|
||||
end
|
||||
|
||||
# Add to path for the current chef-client converge.
|
||||
bin_path = ::File.join(new_resource.path, 'bin')
|
||||
ruby_block "adding '#{bin_path}' to chef-client ENV['PATH']" do
|
||||
block do
|
||||
ENV['PATH'] = bin_path + ':' + ENV['PATH']
|
||||
end
|
||||
only_if do
|
||||
new_resource.append_env_path && ENV['PATH'].scan(bin_path).empty?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
##############
|
||||
# action :put
|
||||
##############
|
||||
action :put do
|
||||
show_deprecations
|
||||
set_put_paths
|
||||
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# download
|
||||
remote_file new_resource.release_file do
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
backup new_resource.backup
|
||||
end
|
||||
|
||||
# unpack based on file extension
|
||||
execute "unpack #{new_resource.release_file}" do
|
||||
command unpack_command
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
###########################
|
||||
# action :dump
|
||||
###########################
|
||||
action :dump do
|
||||
show_deprecations
|
||||
set_dump_paths
|
||||
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# download
|
||||
remote_file new_resource.release_file do
|
||||
Chef::Log.debug("DEBUG: new_resource.release_file #{new_resource.release_file}")
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# unpack based on file extension
|
||||
execute "unpack #{new_resource.release_file}" do
|
||||
command dump_command
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
###########################
|
||||
# action :unzip
|
||||
###########################
|
||||
action :unzip do
|
||||
show_deprecations
|
||||
set_dump_paths
|
||||
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# download
|
||||
remote_file new_resource.release_file do
|
||||
Chef::Log.debug("DEBUG: new_resource.release_file #{new_resource.release_file}")
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# unpack based on file extension
|
||||
execute "unpack #{new_resource.release_file}" do
|
||||
command unzip_command
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
#####################
|
||||
# action :cherry_pick
|
||||
#####################
|
||||
action :cherry_pick do
|
||||
show_deprecations
|
||||
set_dump_paths
|
||||
Chef::Log.debug("DEBUG: new_resource.creates #{new_resource.creates}")
|
||||
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[cherry_pick #{new_resource.creates} from #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# download
|
||||
remote_file new_resource.release_file do
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[cherry_pick #{new_resource.creates} from #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
execute "cherry_pick #{new_resource.creates} from #{new_resource.release_file}" do
|
||||
command cherry_pick_command
|
||||
creates "#{new_resource.path}/#{new_resource.creates}"
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
###########################
|
||||
# action :install_with_make
|
||||
###########################
|
||||
action :install_with_make do
|
||||
show_deprecations
|
||||
set_paths
|
||||
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
remote_file new_resource.release_file do
|
||||
Chef::Log.debug('DEBUG: new_resource.release_file')
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# unpack based on file extension
|
||||
execute "unpack #{new_resource.release_file}" do
|
||||
command unpack_command
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
notifies :run, "execute[autogen #{new_resource.path}]"
|
||||
notifies :run, "execute[configure #{new_resource.path}]"
|
||||
notifies :run, "execute[make #{new_resource.path}]"
|
||||
notifies :run, "execute[make install #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute "autogen #{new_resource.path}" do
|
||||
command './autogen.sh'
|
||||
only_if { ::File.exist? "#{new_resource.path}/autogen.sh" }
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
action :nothing
|
||||
ignore_failure true
|
||||
end
|
||||
|
||||
execute "configure #{new_resource.path}" do
|
||||
command "./configure #{new_resource.autoconf_opts.join(' ')}"
|
||||
only_if { ::File.exist? "#{new_resource.path}/configure" }
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute "make #{new_resource.path}" do
|
||||
command "make #{new_resource.make_opts.join(' ')}"
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute "make install #{new_resource.path}" do
|
||||
command "make install #{new_resource.make_opts.join(' ')}"
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
action :setup_py_build do
|
||||
show_deprecations
|
||||
set_paths
|
||||
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
remote_file new_resource.release_file do
|
||||
Chef::Log.debug('DEBUG: new_resource.release_file')
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# unpack based on file extension
|
||||
execute "unpack #{new_resource.release_file}" do
|
||||
command unpack_command
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
notifies :run, "execute[python setup.py build #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute "python setup.py build #{new_resource.path}" do
|
||||
command "python setup.py build #{new_resource.make_opts.join(' ')}"
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
action :setup_py_install do
|
||||
show_deprecations
|
||||
set_paths
|
||||
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
remote_file new_resource.release_file do
|
||||
Chef::Log.debug('DEBUG: new_resource.release_file')
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# unpack based on file extension
|
||||
execute "unpack #{new_resource.release_file}" do
|
||||
command unpack_command
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
notifies :run, "execute[python setup.py install #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute "python setup.py install #{new_resource.path}" do
|
||||
command "python setup.py install #{new_resource.make_opts.join(' ')}"
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
action :setup_py do
|
||||
show_deprecations
|
||||
set_paths
|
||||
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
remote_file new_resource.release_file do
|
||||
Chef::Log.debug('DEBUG: new_resource.release_file')
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# unpack based on file extension
|
||||
execute "unpack #{new_resource.release_file}" do
|
||||
command unpack_command
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
notifies :run, "execute[python setup.py #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute "python setup.py #{new_resource.path}" do
|
||||
command "python setup.py #{new_resource.make_opts.join(' ')}"
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
action :configure do
|
||||
show_deprecations
|
||||
set_paths
|
||||
|
||||
directory new_resource.path do
|
||||
recursive true
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
remote_file new_resource.release_file do
|
||||
Chef::Log.debug('DEBUG: new_resource.release_file')
|
||||
source new_resource.url
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
action :create
|
||||
notifies :run, "execute[unpack #{new_resource.release_file}]"
|
||||
end
|
||||
|
||||
# unpack based on file extension
|
||||
execute "unpack #{new_resource.release_file}" do
|
||||
command unpack_command
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
notifies :run, "execute[set owner on #{new_resource.path}]"
|
||||
notifies :run, "execute[autogen #{new_resource.path}]"
|
||||
notifies :run, "execute[configure #{new_resource.path}]"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# set_owner
|
||||
execute "set owner on #{new_resource.path}" do
|
||||
command owner_command
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute "autogen #{new_resource.path}" do
|
||||
command './autogen.sh'
|
||||
only_if { ::File.exist? "#{new_resource.path}/autogen.sh" }
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
action :nothing
|
||||
ignore_failure true
|
||||
end
|
||||
|
||||
execute "configure #{new_resource.path}" do
|
||||
command "./configure #{new_resource.autoconf_opts.join(' ')}"
|
||||
only_if { ::File.exist? "#{new_resource.path}/configure" }
|
||||
cwd new_resource.path
|
||||
environment new_resource.environment
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
action_class.class_eval do
|
||||
include ::Ark::ProviderHelpers
|
||||
end
|
||||
|
@ -1 +0,0 @@
|
||||
~FC059
|
@ -1,87 +0,0 @@
|
||||
# bluepill Cookbook CHANGELOG
|
||||
This file is used to list changes made in each version of the bluepill cookbook.
|
||||
|
||||
## 2.4.3 (04-18-2016)
|
||||
- Added ChefSpec custom matchers and examples
|
||||
|
||||
## 2.4.2 (02-19-2016)
|
||||
- Loosened the dependecy on rsyslog so the latest cookbook can be used
|
||||
- Updated testing dependencies and configurations
|
||||
|
||||
WARNING: It was noted after the release of 2.4.2 that the loosened dependency on rsyslog increased the minimum required Chef release to 12.0 for this cookbook. Chef 11 users will need to use 2.4.1.
|
||||
|
||||
## 2.4.1 (11-10-2015)
|
||||
- Require rsyslog ~> 2.0.0 to preserve Chef 11 compatibility
|
||||
- Fix rsyslog restarting on RHEL
|
||||
- Use platform_family when setting platform specific node attributes and fix bad syntax. This should improve RHEL support
|
||||
|
||||
## v2.4.0 (09-17-2015)
|
||||
- Updated the LSB Required-Start and Required-Stop comments of the LSB init script template to be valid
|
||||
- Added name to the bluepill_test cookbook metadata for Chef 12
|
||||
- If a defaults file on RHEL or Debian based systems exist for the service source that within the init scripts. Example if /etc/default/bar exists on debian for the bar service then source that
|
||||
- Added .kitchen.yml file with vagrant based testing for local testing and moved the cloud based kitchen to .kitchen.cloud.yml
|
||||
- Add Travis CI config
|
||||
- Added rubocop config
|
||||
- Updated Berksfile to 3.X format and removed yum cookbook that wasn't used
|
||||
- Updated contributing.md and added testing.md documentation
|
||||
- Updated development and testing dependencies in the Gemfile
|
||||
- Added maintainers.md and .toml and added Rake task for generating the MD file
|
||||
- Opscode -> Chef Software everywhere
|
||||
- Added Travis and cookbook version badges to the readme
|
||||
- Add rake file to easy testing
|
||||
- Resolved all Rubocop warnings
|
||||
- Added a chefignore file and added additional files to the gitignore
|
||||
- Added source_url and issues_url metadata for Supermarket
|
||||
|
||||
## v2.3.2
|
||||
- Never actually released
|
||||
|
||||
## v2.3.1
|
||||
### New Feature
|
||||
- **[COOK-3705](https://tickets.chef.io/browse/COOK-3705)** - Add init.d script with LSB style
|
||||
|
||||
## v2.3.0
|
||||
### Improvement
|
||||
- **[COOK-3503](https://tickets.chef.io/browse/COOK-3503)** - Add why-run support
|
||||
|
||||
## v2.2.2
|
||||
- [COOK-2507] - stringify language attributes
|
||||
|
||||
## v2.2.0
|
||||
- [COOK-547] - Add `load` action to provider to reload services when template changes.
|
||||
|
||||
## v2.1.0
|
||||
- [COOK-1295] - The bluepill cookbook does not create the default log file
|
||||
- [COOK-1840] - Enable bluepill to log to rsyslog
|
||||
|
||||
## v2.0.0
|
||||
This version uses platform_family attribute (in the provider), making the cookbook incompatible with older versions of Chef/Ohai, hence the major version bump.
|
||||
- [COOK-1644] - Bluepill cookbook fails on Redhat due to missing default or redhat template directory.
|
||||
- [COOK-1920] - init script should have a template file named after platform_family instead of using file specificity
|
||||
|
||||
## v1.1.2
|
||||
- [COOK-1730] - Add ability to specify which version of bluepill to install
|
||||
|
||||
## v1.1.0
|
||||
- [COOK-1592] - use mixlib-shellout instead of execute, add test-kitchen
|
||||
|
||||
## v1.0.6
|
||||
- [COOK-1304] - support amazon linux
|
||||
- [COOK-1427] - resolve foodcritic warnings
|
||||
|
||||
## v1.0.4
|
||||
- [COOK-1106] - fix chkconfig loader for CentOS 5
|
||||
- [COOK-1107] - use integer for GID instead of string
|
||||
|
||||
## v1.0.2
|
||||
- [COOK-1043] - Bluepill cookbook fails on OS X because it tries to use root group
|
||||
|
||||
## v1.0.0
|
||||
- [COOK-943] - add init script for freebsd
|
||||
|
||||
## v0.3.0
|
||||
- [COOK-867] - enable bluepill service on RHEL family
|
||||
- [COOK-550] - add freebsd support
|
||||
|
||||
## v0.2.2
|
||||
- Fixes COOK-524, COOK-632
|
@ -1,111 +0,0 @@
|
||||
# bluepill Cookbook
|
||||
[](https://travis-ci.org/chef-cookbooks/bluepill) [](https://supermarket.chef.io/cookbooks/bluepill)
|
||||
|
||||
Installs bluepill Ruby Gem and configures it to manage services. Also includes a LWRP.
|
||||
|
||||
## Requirements
|
||||
### Platforms
|
||||
Bluepill is a pure Ruby service management tool/library, so this cookbook should work on any system. The attributes do set up paths based on FHS locations, see below.
|
||||
|
||||
### Chef
|
||||
- Chef 12+
|
||||
|
||||
### Cookbooks
|
||||
- none
|
||||
|
||||
## Attributes
|
||||
Default locations for bluepill are in "FHS compliant" locations.
|
||||
- `node["bluepill"]["bin"]` - Path to bluepill program, default is 'bluepill' in the RubyGems binary directory.
|
||||
- `node["bluepill"]["logfile"]` - Location of the bluepill log file, default "/var/log/bluepill.log".
|
||||
- `node["bluepill"]["conf_dir"]` - Location of service config files (pills), default "/etc/bluepill".
|
||||
- `node["bluepill"]["pid_dir"]` - Location of pidfiles, default "/var/run/bluepill"
|
||||
- `node["bluepill"]["state_dir"]` - Location of state directory, default "/var/lib/bluepill"
|
||||
- `node["bluepill"]["init_dir"]` - Location of init script directory, default selected by platform.
|
||||
- `node["bluepill"]["version"]` - Version of bluepill to install, default is latest.
|
||||
- `node["bluepill"]["use_rsyslog"]` - Enable configuration and use of rsyslog for bluepill.
|
||||
|
||||
# Custom Resources
|
||||
This cookbook contains an LWRP, `bluepill_service`. This can be used with the normal Chef service resource, by using the `provider` parameter, or by specifying the `bluepill_service` shortcut. These two resources are equivalent.
|
||||
|
||||
```ruby
|
||||
service 'my_app' do
|
||||
provider bluepill_service
|
||||
action [:enable, :load, :start]
|
||||
end
|
||||
|
||||
bluepill_service 'my_app' do
|
||||
action [:enable, :load, :start]
|
||||
end
|
||||
```
|
||||
|
||||
The load action should probably always be specified, to ensure that if bluepill isn't running already it gets started. The
|
||||
|
||||
The recipe using the service must contain a template resource for the pill and it must be named `my_app.pill.erb`, where `my_app` is the service name passed to the bluepill service resource.
|
||||
|
||||
## Usage
|
||||
Be sure to include the bluepill recipe in the run list to ensure that the gem and bluepill-related directories are created. This will also make the cookbook available on the system and other cookbooks won't need to explicitly depend on it in the metadata.
|
||||
|
||||
If the default directory locations in the attributes/default.rb aren't what you want, change them by setting them either in the attributes file itself, or create attributes in a role applied to any systems that will use bluepill.
|
||||
|
||||
Example pill template resource and .erb file:
|
||||
|
||||
```ruby
|
||||
template '/etc/bluepill/my_app.pill' do
|
||||
source 'my_app.pill.erb'
|
||||
end
|
||||
|
||||
Bluepill.application('my_app') do |app|
|
||||
app.process('my_app') do |process|
|
||||
process.pid_file = '/var/run/my_app.pid'
|
||||
process.start_command = '/usr/bin/my_app'
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
See bluepill's documentation for more information on creating pill templates.
|
||||
|
||||
## Testing
|
||||
This cookbook has the following [ChefSpec custom matchers](https://github.com/sethvargo/chefspec#packaging-custom-matchers) defined:
|
||||
|
||||
- enable_bluepill_service
|
||||
- load_bluepill_service
|
||||
- reload_bluepill_service
|
||||
- start_bluepill_service
|
||||
- disable_bluepill_service
|
||||
- stop_bluepill_service
|
||||
- restart_bluepill_service
|
||||
|
||||
### ChefSpec Examples:
|
||||
|
||||
```
|
||||
it 'enables my_app bluepill service' do
|
||||
chef_run.converge('my_app::default', described_recipe)
|
||||
expect(chef_run).to enable_bluepill_service('my_app')
|
||||
end
|
||||
|
||||
it 'reloads my_app bluepill service when pill file changes' do
|
||||
chef_run.converge('my_app::default', described_recipe)
|
||||
expect(chef_run).to create_template('/etc/bluepill/my_app.pill')
|
||||
my_app_pill = chef_run.template('/etc/bluepill/my_app.pill')
|
||||
expect(my_app_pill).to notify('bluepill_service[my_app]').to(:reload).delayed
|
||||
end
|
||||
```
|
||||
|
||||
## License & Authors
|
||||
**Author:** Cookbook Engineering Team ([cookbooks@chef.io](mailto:cookbooks@chef.io))
|
||||
|
||||
**Copyright:** 2010-2015, Chef Software, Inc.
|
||||
|
||||
```
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
```
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user