itamae-plugin-recipe-omori_gohan 0.0.1.beta1 → 0.0.1.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: 8ce5f92859b8a7548cb4a33b98247ee6b07a18a9
4
- data.tar.gz: be18f990967c54ca88f34901f287430c299a7e2e
3
+ metadata.gz: f09fd001565552928cb17c6dce462e91f4fd1df4
4
+ data.tar.gz: 35a44136ad2b6fbf3f584817fa997952bceabe79
5
5
  SHA512:
6
- metadata.gz: a8747ea83ce907a0facc50185ccabf49f2ebb46cf42a2f9806607da98602989d329ed6a9a4e07c73c9b4ad45f3118eeaf079d377406e6786564629cc9d51439c
7
- data.tar.gz: a452dc4361b6c44042a9f9fdb1c8796101877b7efc01328ef7fa0a61e1ca3180038e76d053856d025e69060521592a504fa96cb515c6183de48f59170c00a805
6
+ metadata.gz: 27a0dd71120d9989d51583c3c08fba3fa62e434769307b7017ee3cc80e6c4972fcfb3a36699a288244b333289554753f8bad7482ff810413414a0b81b425a573
7
+ data.tar.gz: 5edc073062f72b0d8332d3e3d93aa26d61cf79422d61337ed9b0b2f648f2e62a0f9f2ff319737240452b81ea43e259870d58570e05cea5f7cfe096bb391dba6d
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ .vagrant/
data/.paraduct.yml ADDED
@@ -0,0 +1,9 @@
1
+ script: |-
2
+ ./ci/build.sh ${HOST}
3
+ after_script: |-
4
+ vagrant destroy -f $HOST
5
+ variables:
6
+ HOST:
7
+ - debian8
8
+ - centos70
9
+ max_threads: 4
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --require spec_helper
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # Itamae::Plugin::Recipe::OmoriGohan
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/itamae/plugin/recipe/omori_gohan`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ itamae tiny recipes
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ [![Gem Version](https://badge.fury.io/rb/itamae-plugin-recipe-omori_gohan.svg)](https://badge.fury.io/rb/itamae-plugin-recipe-omori_gohan)
6
+ [![Dependency Status](https://gemnasium.com/sue445/itamae-plugin-recipe-omori_gohan.svg)](https://gemnasium.com/sue445/itamae-plugin-recipe-omori_gohan)
7
+
8
+ [![wercker status](https://app.wercker.com/status/766847e4b2c442049f1d0c71ecee6de1/m/master "wercker status")](https://app.wercker.com/project/bykey/766847e4b2c442049f1d0c71ecee6de1)
6
9
 
7
10
  ## Installation
8
11
 
@@ -41,12 +44,35 @@ end
41
44
  * `version` : version (optional)
42
45
  * `src_dir` : directory for package download (default is `/usr/local/src`)
43
46
 
47
+ ### Download and install rpm file
48
+ ```ruby
49
+ download_and_install_rpm "vagrant" do
50
+ url "https://releases.hashicorp.com/vagrant/#{node[:vagrant][:version]}/vagrant_#{node[:vagrant][:version]}_x86_64.rpm"
51
+ version node[:vagrant][:version]
52
+ src_dir "/usr/local/src"
53
+ end
54
+ ```
55
+
56
+ * `name` : package name (**requirement**)
57
+ * `url` : package url (**requirement**)
58
+ * `version` : version (optional)
59
+ * `src_dir` : directory for package download (default is `/usr/local/src`)
60
+
44
61
  ## Development
45
62
 
46
63
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
47
64
 
48
65
  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).
49
66
 
67
+ ## Testing
68
+ requirements [Vagrant](https://www.vagrantup.com/)
69
+
70
+ ```sh
71
+ vagrant up centos70
72
+ bundle exec rake itamae:centos70
73
+ bundle exec rake spec:centos70
74
+ ```
75
+
50
76
  ## Contributing
51
77
 
52
78
  Bug reports and pull requests are welcome on GitHub at https://github.com/sue445/itamae-plugin-recipe-omori_gohan.
data/Rakefile CHANGED
@@ -1 +1,29 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ task :spec => "spec:all"
5
+
6
+ HOSTS = %w(centos70 debian8)
7
+
8
+ namespace :spec do
9
+ task :all => HOSTS
10
+
11
+ HOSTS.each do |host|
12
+ RSpec::Core::RakeTask.new(host.to_sym) do |t|
13
+ puts "Running tests to #{host} ..."
14
+ ENV["TARGET_HOST"] = host
15
+ t.pattern = "spec/*_spec.rb"
16
+ end
17
+ end
18
+ end
19
+
20
+ namespace :itamae do
21
+ task :all => HOSTS
22
+
23
+ HOSTS.each do |host|
24
+ desc "Running itamae to #{host}"
25
+ task host do
26
+ sh "bundle exec itamae ssh --host=#{host} --vagrant --node-yaml=recipes/node.yml recipes/install.rb"
27
+ end
28
+ end
29
+ end
data/Vagrantfile ADDED
@@ -0,0 +1,105 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # All Vagrant configuration is done below. The "2" in Vagrant.configure
5
+ # configures the configuration version (we support older styles for
6
+ # backwards compatibility). Please don't change it unless you know what
7
+ # you're doing.
8
+ Vagrant.configure(2) do |config|
9
+ config.vm.provider :digital_ocean do |provider, override|
10
+ override.vm.box = "digital_ocean"
11
+ override.vm.box_url = "https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box"
12
+ provider.token = ENV["DIGITALOCEAN_ACCESS_TOKEN"]
13
+ provider.region = "nyc3"
14
+ provider.size = "512MB"
15
+
16
+ if ENV["WERCKER"] == "true"
17
+ provider.ssh_key_name = "wercker-#{ENV['WERCKER_GIT_REPOSITORY']}"
18
+ override.ssh.private_key_path = "~/.ssh/id_rsa.vagrant"
19
+ else
20
+ provider.ssh_key_name = "local"
21
+ override.ssh.private_key_path = "~/.ssh/id_rsa"
22
+ end
23
+ end
24
+
25
+ config.vm.define :centos70 do |c|
26
+ c.vm.box = "centos/7"
27
+ c.vm.provider :digital_ocean do |provider, override|
28
+ provider.image = "centos-7-0-x64"
29
+ end
30
+ c.vm.hostname = 'itamae-centos70'
31
+ c.vm.hostname += "-#{ENV['WERCKER_BUILD_ID']}" if ENV['WERCKER_BUILD_ID']
32
+ end
33
+
34
+ config.vm.define :debian8 do |c|
35
+ c.vm.box = "debian/jessie64"
36
+ c.vm.provider :digital_ocean do |provider, override|
37
+ provider.image = "debian-8-x64"
38
+ end
39
+ c.vm.hostname = 'itamae-debian8'
40
+ c.vm.hostname += "-#{ENV['WERCKER_BUILD_ID']}" if ENV['WERCKER_BUILD_ID']
41
+ end
42
+
43
+ # The most common configuration options are documented and commented below.
44
+ # For a complete reference, please see the online documentation at
45
+ # https://docs.vagrantup.com.
46
+
47
+ # Every Vagrant development environment requires a box. You can search for
48
+ # boxes at https://atlas.hashicorp.com/search.
49
+ # config.vm.box = "base"
50
+
51
+ # Disable automatic box update checking. If you disable this, then
52
+ # boxes will only be checked for updates when the user runs
53
+ # `vagrant box outdated`. This is not recommended.
54
+ # config.vm.box_check_update = false
55
+
56
+ # Create a forwarded port mapping which allows access to a specific port
57
+ # within the machine from a port on the host machine. In the example below,
58
+ # accessing "localhost:8080" will access port 80 on the guest machine.
59
+ # config.vm.network "forwarded_port", guest: 80, host: 8080
60
+
61
+ # Create a private network, which allows host-only access to the machine
62
+ # using a specific IP.
63
+ # config.vm.network "private_network", ip: "192.168.33.10"
64
+
65
+ # Create a public network, which generally matched to bridged network.
66
+ # Bridged networks make the machine appear as another physical device on
67
+ # your network.
68
+ # config.vm.network "public_network"
69
+
70
+ # Share an additional folder to the guest VM. The first argument is
71
+ # the path on the host to the actual folder. The second argument is
72
+ # the path on the guest to mount the folder. And the optional third
73
+ # argument is a set of non-required options.
74
+ # config.vm.synced_folder "../data", "/vagrant_data"
75
+
76
+ # Provider-specific configuration so you can fine-tune various
77
+ # backing providers for Vagrant. These expose provider-specific options.
78
+ # Example for VirtualBox:
79
+ #
80
+ # config.vm.provider "virtualbox" do |vb|
81
+ # # Display the VirtualBox GUI when booting the machine
82
+ # vb.gui = true
83
+ #
84
+ # # Customize the amount of memory on the VM:
85
+ # vb.memory = "1024"
86
+ # end
87
+ #
88
+ # View the documentation for the provider you are using for more
89
+ # information on available options.
90
+
91
+ # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
92
+ # such as FTP and Heroku are also available. See the documentation at
93
+ # https://docs.vagrantup.com/v2/push/atlas.html for more information.
94
+ # config.push.define "atlas" do |push|
95
+ # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
96
+ # end
97
+
98
+ # Enable provisioning with a shell script. Additional provisioners such as
99
+ # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
100
+ # documentation for more information about their specific syntax and use.
101
+ # config.vm.provision "shell", inline: <<-SHELL
102
+ # sudo apt-get update
103
+ # sudo apt-get install -y apache2
104
+ # SHELL
105
+ end
data/ci/build.sh ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash -xe
2
+
3
+ readonly HOST=$1
4
+
5
+ vagrant up $HOST --provider=digital_ocean
6
+ bundle exec rake itamae:$HOST
7
+ bundle exec rake spec:$HOST
@@ -0,0 +1,22 @@
1
+ # via. https://github.com/itamae-kitchen/itamae/blob/v1.9.3/ci/destroy_old_droplets.rb
2
+ require 'net/https'
3
+ require 'json'
4
+ require 'time'
5
+
6
+ http = Net::HTTP.new("api.digitalocean.com", 443)
7
+ http.use_ssl = true
8
+
9
+ res = http.start do
10
+ http.get("/v2/droplets", "Authorization" => "Bearer #{ENV['DIGITALOCEAN_ACCESS_TOKEN']}")
11
+ end
12
+
13
+ droplets = JSON.parse(res.body)['droplets']
14
+ droplets.each do |droplet|
15
+ next unless /^itamae-/ =~ droplet['name']
16
+ if Time.now - Time.parse(droplet['created_at']) >= 60 * 60
17
+ puts "destroying #{droplet}..."
18
+ res = http.start do
19
+ http.delete("/v2/droplets/#{droplet['id']}", "Authorization" => "Bearer #{ENV['DIGITALOCEAN_ACCESS_TOKEN']}")
20
+ end
21
+ end
22
+ end
@@ -22,5 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency "itamae"
23
23
 
24
24
  spec.add_development_dependency "bundler"
25
+ spec.add_development_dependency "paraduct", "~> 1.0.0"
25
26
  spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "serverspec"
26
28
  end
@@ -1 +1,2 @@
1
1
  include_recipe "./definitions/download_and_install_deb"
2
+ include_recipe "./definitions/download_and_install_rpm"
@@ -0,0 +1,25 @@
1
+ # Download and install rpm file
2
+ define :download_and_install_rpm, version: nil, url: nil, src_dir: "/usr/local/src" do
3
+ raise "name is requirement" unless params[:name]
4
+ raise "url is requirement" unless params[:url]
5
+
6
+ basename = File.basename(params[:url])
7
+
8
+ src_dir = params[:src_dir]
9
+
10
+ check_command = "yum list installed | grep '#{params[:name]}'"
11
+ check_command << " | grep '#{params[:version]}'" if params[:version]
12
+
13
+ package "wget"
14
+
15
+ [
16
+ "wget #{params[:url]} -O #{basename}",
17
+ "rpm -i #{basename}"
18
+ ].each do |command|
19
+ execute command do
20
+ not_if check_command
21
+
22
+ cwd src_dir
23
+ end
24
+ end
25
+ end
@@ -2,7 +2,7 @@ module Itamae
2
2
  module Plugin
3
3
  module Recipe
4
4
  module OmoriGohan
5
- VERSION = "0.0.1.beta1"
5
+ VERSION = "0.0.1.beta2"
6
6
  end
7
7
  end
8
8
  end
data/recipes/centos.rb ADDED
@@ -0,0 +1,5 @@
1
+ download_and_install_rpm "vagrant" do
2
+ url "https://releases.hashicorp.com/vagrant/#{node[:vagrant][:version]}/vagrant_#{node[:vagrant][:version]}_x86_64.rpm"
3
+ version node[:vagrant][:version]
4
+ src_dir "/usr/local/src"
5
+ end
data/recipes/debian.rb ADDED
@@ -0,0 +1,5 @@
1
+ download_and_install_deb "vagrant" do
2
+ url "https://releases.hashicorp.com/vagrant/#{node[:vagrant][:version]}/vagrant_#{node[:vagrant][:version]}_x86_64.deb"
3
+ version node[:vagrant][:version]
4
+ src_dir "/usr/local/src"
5
+ end
@@ -0,0 +1,8 @@
1
+ include_recipe "omori_gohan"
2
+
3
+ case node[:platform]
4
+ when "debian"
5
+ include_recipe "./debian"
6
+ when "redhat"
7
+ include_recipe "./centos"
8
+ end
data/recipes/node.yml ADDED
@@ -0,0 +1,2 @@
1
+ vagrant:
2
+ version: "1.8.1"
data/wercker.yml ADDED
@@ -0,0 +1,74 @@
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: sue445/rvm-vagrant-digitalocean@1.0.0
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
+ # - mongodb
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
+ - rvm-use:
25
+ version: 2.3.0
26
+
27
+ - script:
28
+ name: install bundler
29
+ code: gem install bundler -v 1.10.6 --no-document
30
+
31
+ - bundle-install:
32
+ jobs: 4
33
+
34
+ - script:
35
+ name: echo ruby information
36
+ code: |
37
+ echo "ruby version $(ruby --version) running"
38
+ echo "from location $(which ruby)"
39
+ echo -p "gem list: $(gem list)"
40
+
41
+ - script:
42
+ name: create .ssh directory
43
+ code: mkdir -m 700 -p $HOME/.ssh
44
+
45
+ - create-file:
46
+ name: put private key
47
+ filename: $HOME/.ssh/id_rsa.vagrant
48
+ overwrite: true
49
+ hide-from-log: true
50
+ content: $DIGITALOCEAN_KEY_PRIVATE
51
+
52
+ - create-file:
53
+ name: put public key
54
+ filename: $HOME/.ssh/id_rsa.vagrant.pub
55
+ overwrite: true
56
+ hide-from-log: true
57
+ content: $DIGITALOCEAN_KEY_PUBLIC
58
+
59
+ - script:
60
+ name: chmod 600 id_rsa
61
+ code: chmod 600 $HOME/.ssh/id_rsa.vagrant
62
+
63
+ - script:
64
+ name: paraduct test
65
+ code: bundle exec paraduct test
66
+
67
+ after-steps:
68
+ - script:
69
+ name: shutdown old vms
70
+ code: bundle exec ruby ci/destroy_old_droplets.rb
71
+
72
+ - wantedly/pretty-slack-notify:
73
+ webhook_url: $SLACK_WEBHOOK_URL
74
+ username: wercker_build
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itamae-plugin-recipe-omori_gohan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.beta1
4
+ version: 0.0.1.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-02-09 00:00:00.000000000 Z
11
+ date: 2016-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: itamae
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: paraduct
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +66,20 @@ dependencies:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
68
  version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: serverspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  description: itamae tiny recipes
56
84
  email:
57
85
  - sue445@sue445.net
@@ -60,18 +88,28 @@ extensions: []
60
88
  extra_rdoc_files: []
61
89
  files:
62
90
  - ".gitignore"
63
- - ".travis.yml"
91
+ - ".paraduct.yml"
92
+ - ".rspec"
64
93
  - Gemfile
65
94
  - LICENSE.txt
66
95
  - README.md
67
96
  - Rakefile
97
+ - Vagrantfile
68
98
  - bin/console
69
99
  - bin/setup
100
+ - ci/build.sh
101
+ - ci/destroy_old_droplets.rb
70
102
  - itamae-plugin-recipe-omori_gohan.gemspec
71
103
  - lib/itamae/plugin/recipe/omori_gohan.rb
72
104
  - lib/itamae/plugin/recipe/omori_gohan/default.rb
73
105
  - lib/itamae/plugin/recipe/omori_gohan/definitions/download_and_install_deb.rb
106
+ - lib/itamae/plugin/recipe/omori_gohan/definitions/download_and_install_rpm.rb
74
107
  - lib/itamae/plugin/recipe/omori_gohan/version.rb
108
+ - recipes/centos.rb
109
+ - recipes/debian.rb
110
+ - recipes/install.rb
111
+ - recipes/node.yml
112
+ - wercker.yml
75
113
  homepage: https://github.com/sue445/itamae-plugin-recipe-omori_gohan
76
114
  licenses:
77
115
  - MIT
data/.travis.yml DELETED
@@ -1,4 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.3.0
4
- before_install: gem install bundler -v 1.10.6