capistrano-itamae 0.1.0.beta1 → 0.1.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf6fbab9e49b9fb90b2c2c0eb5a2521c6e19a0da
4
- data.tar.gz: a51af34ca69deba9931b3e6be6b0f7953d46394f
3
+ metadata.gz: 4135186881d5a879ab199b38961b1295c813f871
4
+ data.tar.gz: 895980b2cbc53f5e1b17897bee7521336780fbef
5
5
  SHA512:
6
- metadata.gz: f3db99953ddc9df4283a2fd872b785af67230cdba567275c87b79d1db62c59d1be60bf99781c0b375ddb29bf11c4b506a27679fd24cc46a407ba00922bc92765
7
- data.tar.gz: f7c58eaff036239f6a2bb595af54401c16cbf4081cc4be1e96eb60f2946aad59cd684653f4d16732d8d96579807f022dadfdaa3570aba350a8a5de16da748ed1
6
+ metadata.gz: 6f020cea4f4535a124f5125fa846e8f2cdc04a6b3073451899aa1eaec9b0df5d767f02828c1b9a32142c1bb387fe96915ca6ac5e2287c215bdb2a978be9b4143
7
+ data.tar.gz: 5a1826650db3b06aea15b3ced1850799c0e4c6133099a5e8e8e283dc9f0073db8b84f600b879b19dab93d0bd8f47cf9ad3cffc6e1ac0e2484aac3349ec2eac7c
data/.gitignore CHANGED
@@ -7,3 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ spec/integration/.vagrant/
11
+ spec/integration/log/
data/Gemfile CHANGED
@@ -2,3 +2,11 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in capistrano-itamae.gemspec
4
4
  gemspec
5
+
6
+ group :development do
7
+ gem 'vagrant', github: 'ryotarai/vagrant', branch: 'latest-bundler'
8
+ end
9
+
10
+ group :plugins do
11
+ gem 'vagrant-digitalocean'
12
+ end
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Capistrano::Itamae
2
2
 
3
- Run itamae in capistrano task
3
+ Run [itamae](https://github.com/itamae-kitchen/itamae) in capistrano task
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/capistrano-itamae.svg)](https://badge.fury.io/rb/capistrano-itamae)
6
+
7
+ [![wercker status](https://app.wercker.com/status/a2f734cda581d3d221e10b1ede83bb71/m/master "wercker status")](https://app.wercker.com/project/bykey/a2f734cda581d3d221e10b1ede83bb71)
4
8
 
5
9
  ## Installation
6
10
 
@@ -31,18 +35,33 @@ require "capistrano/itamae"
31
35
  config/deploy.rb
32
36
 
33
37
  ```ruby
38
+ set :itamae_cookbooks_path, "cookbooks"
39
+
40
+ set :itamae_ssh_default_options, ["--node-yaml=node.yml"]
41
+
34
42
  desc "Run itamae"
35
43
  task :itamae do
36
44
  on roles(:all) do
37
- itamae_ssh "/path/to/recipe.rb"
45
+ # Run itamae ssh --node-yaml=node.yml cookbooks/recipe.rb
46
+ itamae_ssh "recipe.rb"
47
+
48
+ # Run itamae ssh --node-yaml=node.yml cookbooks/recipe1.rb cookbooks/recipe2.rb
49
+ itamae_ssh ["recipe1.rb", "recipe2.rb"]
50
+
51
+ # Run itamae ssh --node-yaml=node.yml cookbooks/recipe.rb --dry-run
52
+ itamae_ssh "recipe.rb", "--dry-run"
38
53
  end
39
54
  end
40
55
  end
41
56
  ```
42
57
 
58
+ see [Capistrano::Itamae::DSL#itamae_ssh](lib/capistrano/itamae/dsl.rb)
59
+
43
60
  ## Variables
44
- * `itamae_path` : path to itamae executable file (default: `bundle exec itamae`)
45
- * `itamae_default_options` : (default: `[]`)
61
+ * `itamae_cookbooks_path` : path to cookbooks dir (default: "cookbooks")
62
+ * `itamae_bin_name` : itamae executable name (default: `itamae`)
63
+ * `itamae_ssh_default_options` : `itamae ssh` default options (default: `[]`)
64
+ * If `options` is not passed, use this
46
65
 
47
66
  ## Development
48
67
 
@@ -50,6 +69,13 @@ After checking out the repo, run `bin/setup` to install dependencies. You can al
50
69
 
51
70
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
52
71
 
72
+ ## Integration test
73
+ ```sh
74
+ cd spec/integration
75
+ bundle exec vagrant up
76
+ bundle exec rake spec
77
+ ```
78
+
53
79
  ## Contributing
54
80
 
55
81
  Bug reports and pull requests are welcome on GitHub at https://github.com/sue445/capistrano-itamae.
data/Rakefile CHANGED
@@ -1,2 +1 @@
1
1
  require "bundler/gem_tasks"
2
- task :default => :spec
@@ -19,9 +19,10 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
+ spec.add_dependency "bundler"
22
23
  spec.add_dependency "capistrano", ">= 3"
23
24
  spec.add_dependency "itamae"
24
25
 
25
- spec.add_development_dependency "bundler", "~> 1.12"
26
26
  spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "serverspec"
27
28
  end
@@ -1,45 +1,54 @@
1
1
  module Capistrano
2
2
  module Itamae
3
3
  module DSL
4
- def itamae_ssh(recipes, *options)
5
- recipes = Array(recipes) unless recipes.is_a?(Array)
6
-
7
- itamae_options = itamae_default_options if options.empty?
4
+ require "bundler"
5
+
6
+ # Run `itamae ssh`
7
+ # @param recipe_files [String, Array<String>]
8
+ # @param options [Array] itamae ssh options (default is itamae_ssh_default_options)
9
+ def itamae_ssh(recipe_files, *options)
10
+ recipe_files = Array(recipe_files) unless recipe_files.is_a?(Array)
11
+ recipe_paths = recipe_files.map { |file| itamae_cookbooks_path.join(file) }
12
+
13
+ itamae_options =
14
+ if options.empty?
15
+ itamae_ssh_default_options
16
+ else
17
+ options
18
+ end
8
19
 
9
- command = []
10
- command << itamae_path
11
- command << "ssh"
12
- command += recipes
13
- command += itamae_options unless itamae_options.empty?
14
- command += ssh_options
20
+ # NOTE: store server (`host` is changed to localhost in `run_locally`)
21
+ server = host
15
22
 
16
23
  run_locally do
17
24
  Bundler.with_clean_env do
18
- execute command.join(" ")
25
+ execute *generate_itamae_ssh_command(server, recipe_paths, itamae_options)
19
26
  end
20
27
  end
21
28
  end
22
29
 
23
30
  private
24
31
 
25
- def itamae_path
26
- fetch(:itamae_path, "bundle exec itamae")
27
- end
32
+ def generate_itamae_ssh_command(server, recipe_paths, itamae_options)
33
+ command = [:bundle, :exec, itamae_bin_name, :ssh]
34
+
35
+ command += recipe_paths
36
+ command += itamae_options unless itamae_options.empty?
37
+ command += ssh_options(server)
28
38
 
29
- def itamae_default_options
30
- fetch(:itamae_default_options, [])
39
+ command
31
40
  end
32
41
 
33
- def ssh_options
42
+ def ssh_options(server)
34
43
  ssh_options = fetch(:ssh_options, {}).dup
35
- ssh_options.merge!(host.ssh_options) if host.ssh_options
36
- ssh_options[:user] ||= host.user
37
- ssh_options[:port] ||= host.port
38
- ssh_options[:keys] ||= host.keys
44
+ ssh_options.merge!(server.ssh_options) if server.ssh_options
45
+ ssh_options[:user] ||= server.user
46
+ ssh_options[:port] ||= server.port
47
+ ssh_options[:keys] ||= server.keys
39
48
  ssh_options[:key] ||= ssh_options[:keys].first if ssh_options[:keys] && !ssh_options[:keys].empty?
40
49
 
41
50
  options = []
42
- options << "--host #{host.hostname}"
51
+ options << "--host #{server.hostname}"
43
52
  options << "--user #{ssh_options[:user]}" if ssh_options[:user]
44
53
  options << "--port #{ssh_options[:port]}" if ssh_options[:port]
45
54
  options << "--key #{ssh_options[:key]}" if ssh_options[:key]
@@ -0,0 +1,19 @@
1
+ module Capistrano
2
+ module Itamae
3
+ module Variables
4
+ def itamae_cookbooks_path
5
+ Pathname.new(fetch(:itamae_cookbooks_path, "cookbooks"))
6
+ end
7
+
8
+ def itamae_bin_name
9
+ fetch(:itamae_bin_name, "itamae")
10
+ end
11
+
12
+ def itamae_ssh_default_options
13
+ fetch(:itamae_ssh_default_options, [])
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ include Capistrano::Itamae::Variables
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Itamae
3
- VERSION = "0.1.0.beta1"
3
+ VERSION = "0.1.0.beta2"
4
4
  end
5
5
  end
@@ -1,6 +1,7 @@
1
1
  require "capistrano/itamae/version"
2
2
  require "capistrano"
3
3
  require "capistrano/itamae/dsl"
4
+ require "capistrano/itamae/variables"
4
5
 
5
6
  module Capistrano
6
7
  module Itamae
data/wercker.yml ADDED
@@ -0,0 +1,88 @@
1
+ # This references the default Ruby container from
2
+ # the Docker Hub.
3
+ # https://registry.hub.docker.com/_/ruby/
4
+ # If you want to use a specific version you would use a tag:
5
+ # ruby:2.2.2
6
+ box: drecom/centos-ruby:2.3.1
7
+ # You can also use services such as databases. Read more on our dev center:
8
+ # http://devcenter.wercker.com/docs/services/index.html
9
+ # services:
10
+ # - postgres
11
+ # http://devcenter.wercker.com/docs/services/postgresql.html
12
+
13
+ # - mongo
14
+ # http://devcenter.wercker.com/docs/services/mongodb.html
15
+
16
+ # This is the build pipeline. Pipelines are the core of wercker
17
+ # Read more about pipelines on our dev center
18
+ # http://devcenter.wercker.com/docs/pipelines/index.html
19
+ build:
20
+ # Steps make up the actions in your pipeline
21
+ # Read more about steps on our dev center:
22
+ # http://devcenter.wercker.com/docs/steps/index.html
23
+ steps:
24
+ - script:
25
+ name: Set variables
26
+ code: |
27
+ # Quiet vagrant not_in_installer message
28
+ # ref
29
+ # * https://github.com/mitchellh/vagrant/blob/v1.8.4/templates/locales/en.yml#L339-L345
30
+ # * https://github.com/mitchellh/vagrant/blob/v1.8.4/bin/vagrant#L167-L170
31
+ # * https://github.com/mitchellh/vagrant/blob/v1.8.4/lib/vagrant/shared_helpers.rb#L48-L53
32
+ export VAGRANT_I_KNOW_WHAT_IM_DOING_PLEASE_BE_QUIET=true
33
+
34
+ - bundle-install:
35
+ jobs: 4
36
+
37
+ - script:
38
+ name: create .ssh directory
39
+ code: mkdir -m 700 -p $HOME/.ssh
40
+
41
+ - create-file:
42
+ name: put private key
43
+ filename: $HOME/.ssh/id_rsa.vagrant
44
+ overwrite: true
45
+ hide-from-log: true
46
+ content: $DIGITALOCEAN_KEY_PRIVATE
47
+
48
+ - create-file:
49
+ name: put public key
50
+ filename: $HOME/.ssh/id_rsa.vagrant.pub
51
+ overwrite: true
52
+ hide-from-log: true
53
+ content: $DIGITALOCEAN_KEY_PUBLIC
54
+
55
+ - script:
56
+ name: chmod 600 id_rsa
57
+ code: chmod 600 $HOME/.ssh/id_rsa.vagrant
58
+
59
+ - script:
60
+ name: start vm
61
+ code: bundle exec vagrant up default --provider=digital_ocean
62
+ cwd: spec/integration
63
+
64
+ - script:
65
+ name: vagrant ssh-config
66
+ code: bundle exec vagrant ssh-config
67
+ cwd: spec/integration
68
+
69
+ - script:
70
+ name: run integration test
71
+ code: bundle exec rake spec
72
+ cwd: spec/integration
73
+
74
+ after-steps:
75
+ - script:
76
+ name: Set variables
77
+ code: |
78
+ # NOTE: override .ruby-version in pretty-slack-notify
79
+ export RBENV_VERSION=2.3.1
80
+
81
+ - script:
82
+ name: shutdown all vms
83
+ code: bundle exec vagrant destroy -f
84
+ cwd: spec/integration
85
+
86
+ - wantedly/pretty-slack-notify:
87
+ webhook_url: $SLACK_WEBHOOK_URL
88
+ username: wercker_build
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-itamae
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.beta1
4
+ version: 0.1.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - sue445
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-13 00:00:00.000000000 Z
11
+ date: 2016-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: capistrano
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -39,33 +53,33 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: bundler
56
+ name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '1.12'
61
+ version: '10.0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '1.12'
68
+ version: '10.0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: rake
70
+ name: serverspec
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - "~>"
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
- version: '10.0'
75
+ version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - "~>"
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: '10.0'
82
+ version: '0'
69
83
  description: Run itamae in capistrano task
70
84
  email:
71
85
  - sue445@sue445.net
@@ -84,7 +98,9 @@ files:
84
98
  - lib/capistrano-itamae.rb
85
99
  - lib/capistrano/itamae.rb
86
100
  - lib/capistrano/itamae/dsl.rb
101
+ - lib/capistrano/itamae/variables.rb
87
102
  - lib/capistrano/itamae/version.rb
103
+ - wercker.yml
88
104
  homepage: https://github.com/sue445/capistrano-itamae
89
105
  licenses:
90
106
  - MIT