Skip to content

Commit

Permalink
DEV-267 | cleanup, add docker-compose and autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
hoatle committed Nov 24, 2016
1 parent a88e4b5 commit c86b662
Show file tree
Hide file tree
Showing 31 changed files with 1,027 additions and 44 deletions.
6 changes: 4 additions & 2 deletions Berksfile
@@ -1,4 +1,6 @@
source "https://supermarket.chef.io"

cookbook 'magic_shell', '~> 1.0.0'
cookbook 'docker', '~> 2.11.0'
cookbook 'vim', '~> 2.0'
cookbook 'magic_shell', '~> 1.0'
cookbook 'docker', '~> 2.11'
cookbook 'docker_compose', '~> 0.1'
4 changes: 4 additions & 0 deletions Berksfile.lock
@@ -1,9 +1,13 @@
DEPENDENCIES
docker (~> 2.11.0)
docker_compose (~> 0.1)
magic_shell (= 1.0.0)
vim (~> 2.0)

GRAPH
compat_resource (12.16.2)
docker (2.11.0)
compat_resource (>= 12.14.7)
docker_compose (0.1.1)
magic_shell (1.0.0)
vim (2.0.2)
12 changes: 6 additions & 6 deletions Gemfile
Expand Up @@ -2,12 +2,12 @@ source 'http://rubygems.org'

ruby '2.2.6'

gem 'rake', '~> 11.3.0'
gem 'rake', '~> 11.3'

group:development do
gem 'chef', '~> 12.16.0'
gem 'chefspec', '~> 5.3.0'
gem 'foodcritic', '~> 8.1.0'
gem 'knife-spork', '~> 1.6.2'
gem 'berkshelf', '~> 5.2.0'
gem 'chef', '~> 12.16'
gem 'chefspec', '~> 5.3'
gem 'foodcritic', '~> 8.1'
gem 'knife-spork', '~> 1.6'
gem 'berkshelf', '~> 5.2'
end
12 changes: 6 additions & 6 deletions Gemfile.lock
Expand Up @@ -243,12 +243,12 @@ PLATFORMS
ruby

DEPENDENCIES
berkshelf (~> 5.2.0)
chef (~> 12.16.0)
chefspec (~> 5.3.0)
foodcritic (~> 8.1.0)
knife-spork (~> 1.6.2)
rake (~> 11.3.0)
berkshelf (~> 5.2)
chef (~> 12.16)
chefspec (~> 5.3)
foodcritic (~> 8.1)
knife-spork (~> 1.6)
rake (~> 11.3)

RUBY VERSION
ruby 2.2.6p396
Expand Down
17 changes: 8 additions & 9 deletions Vagrantfile
Expand Up @@ -200,18 +200,17 @@ Vagrant.configure("2") do |config|

if item['supports'].nil? or item['supports'].include?(host_os_type)
config.vm.synced_folder item['host'], item['guest'], options

# Configure the window for gatling to coalesce writes.
if Vagrant.has_plugin?("vagrant-gatling-rsync")
config.gatling.latency = 1.0
config.gatling.time_format = "%H:%M:%S"
# Automatically sync when machines with rsync folders come up.
# config.gatling.rsync_on_startup = false
end

end
end

# Configure the window for gatling to coalesce writes.
if Vagrant.has_plugin?('vagrant-gatling-rsync')
config.gatling.latency = 1.0
config.gatling.time_format = "%H:%M:%S"
# Automatically sync when machines with rsync folders come up.
config.gatling.rsync_on_startup = data_hash['rsync']['auto']
end

# ssh configuration
config.ssh.forward_agent = data_hash['vm_forward_agent']

Expand Down
4 changes: 2 additions & 2 deletions main-cookbooks/teracy-dev/metadata.rb
Expand Up @@ -8,11 +8,11 @@
issues_url 'https://github.com/teracyhq/issues'
source_url 'https://github.com/teracyhq/issues'

%w{ magic_shell docker }.each do |dep|
%w{ magic_shell docker docker_compose }.each do |dep|
depends dep
end

recipe 'teracy::alias', "Installs useful alias for teracy's project development."
recipe 'teracy-dev::directories', 'Manage directories.'
recipe 'teracy-dev::env', 'Configures environment variables.'
recipe 'teracy-dev::docker', 'Installs Docker.'
recipe 'teracy-dev::docker', 'Installs Docker, docker_compose'
6 changes: 3 additions & 3 deletions main-cookbooks/teracy-dev/recipes/alias.rb
Expand Up @@ -31,10 +31,10 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
node['teracy-dev']['alias'].each do |ali|
action = :create
action = ali['action'].to_sym unless ali['action'].nil? or ali['action'].strip().empty?
act = :create
act = ali['action'].to_sym unless ali['action'].nil? or ali['action'].strip().empty?
magic_shell_alias ali['name'] do
command ali['command']
action action
action act
end
end
10 changes: 5 additions & 5 deletions main-cookbooks/teracy-dev/recipes/directories.rb
Expand Up @@ -33,13 +33,13 @@

node['teracy-dev']['directories'].each do |dir|
mode = 0775
action = :create
mode = dir['mode'] unless dir['mode'].nil? or dir['mode'].strip().empty?
action = dir['action'].to_sym unless dir['action'].nil? or dir['action'].strip().empty?
act = :create
mod = dir['mode'] unless dir['mode'].nil? or dir['mode'].strip().empty?
act = dir['action'].to_sym unless dir['action'].nil? or dir['action'].strip().empty?
directory dir['path'] do
owner dir['owner']
group dir['group']
mode mode
action action
mode mod
action act
end
end
45 changes: 38 additions & 7 deletions main-cookbooks/teracy-dev/recipes/docker.rb
Expand Up @@ -31,13 +31,44 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

docker_installation 'default' do
repo 'main'
action :create
docker_conf = node['teracy-dev']['docker']

def get_docker_compose_autocomplete_url
release = node['docker_compose']['release']
"https://raw.githubusercontent.com/docker/compose/#{release}/contrib/completion/bash/docker-compose"
end

group 'docker' do
action :modify
members 'vagrant'
append true
if docker_conf['enabled'] == true

installation_conf = docker_conf['installation']

act = :create
if installation_conf['action'] == 'delete'
act = :delete
end

docker_installation 'default' do
repo installation_conf['repo']
action act
end
group 'docker' do
action :modify
members installation_conf['members']
append true
end

if node['teracy-dev']['docker_compose']['enabled'] == true
include_recipe 'docker_compose::installation'

# install docker-compose auto complete
autocomplete_url = get_docker_compose_autocomplete_url

execute 'install docker-compose autocomplete' do
action :run
command "curl -L #{autocomplete_url} > /etc/bash_completion.d/docker-compose"
user 'root'
group 'docker'
end
end
end

6 changes: 3 additions & 3 deletions main-cookbooks/teracy-dev/recipes/env.rb
Expand Up @@ -32,10 +32,10 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
node['teracy-dev']['env'].each do |env|
action = :add
action = env['action'].to_sym unless env['action'].nil? or env['action'].strip().empty?
act = :add
act = env['action'].to_sym unless env['action'].nil? or env['action'].strip().empty?
magic_shell_environment env['key'] do
value env['value']
action action
action act
end
end
17 changes: 16 additions & 1 deletion vagrant_config.json
Expand Up @@ -66,6 +66,10 @@
//"cpus":1,
"description":"teracy-dev #{Time.now.getutc.to_i}"
},
"rsync": {
// auto rsync watch when up/ reload done
"auto": false
},
"chef": {
"enabled":true
},
Expand Down Expand Up @@ -108,7 +112,18 @@
"action": "add" // one of add, remove. Default: add.
// See more: https://github.com/customink-webops/magic_shell/blob/master/resources/environment.rb
}
]
],
"docker": {
"enabled": true,
"installation": {
"repo": "main", // one of main, test, experimental
"members": ["vagrant"],
"action": "create" // one of create, delete. Default: create
}
},
"docker_compose": {
"enabled": true
}
}
}
//,
Expand Down
14 changes: 14 additions & 0 deletions vendor-cookbooks/docker_compose/HISTORY.md
@@ -0,0 +1,14 @@
# Release History

## vNEXT

## v0.1.1

* Added support for docker-compose's --remove-orphans parameter.
* The cookbook is now compatible with CentOS.
* Improved cookbook documentation.

## v0.1.0

* Initial release.

0 comments on commit c86b662

Please sign in to comment.