itamae-plugin-recipe-consul 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: cf6668ddb6110c3d51b955f3826e1b6a06d35929
4
- data.tar.gz: dca2477ed81f92ad162395dddae1c8268edc12dd
3
+ metadata.gz: 35dff917fe52d426622f41c69854e171cee51e7b
4
+ data.tar.gz: 146d79c36514f64ffbf195a7f2ac21d9c48d3cc6
5
5
  SHA512:
6
- metadata.gz: 8c786cfcc1dc058983904442e8ec23e64597b2305b8fb9877206c1b31ebee98d881ba9073c4bdd689b57a62f3eacf8b67e4d9876d5bdfef3d0e352fbc175ba56
7
- data.tar.gz: 7803b99b34b2e1dc54d7c1911b4b7a312dab0efe1432ed3d6fb75c2fc8051f6e60c85ff3725cf396546a113da97fb4a54249678ca79bc40191d8c4683d10a9f3
6
+ metadata.gz: fed4298985a184b34fa70600a9e3f20edb526316c8008ac05632a6a04d788441b4d68dd9d77aec3d71c3d45f9e72615b540b4a139d5438d198e5907569fc0fb4
7
+ data.tar.gz: 326ca4a203a0896efe4726ae80aa4b5aff4a08574bc1e9bb1b1b81ec60a78acc4db14bc04d08df17fe6eff7953c80d4b235a8c7af4020737f4193775890e5876
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  Itamae plugin to install [Consul](https://www.consul.io/) with init scripts
4
4
 
5
+ [![Gem Version](https://badge.fury.io/rb/itamae-plugin-recipe-consul.svg)](https://badge.fury.io/rb/itamae-plugin-recipe-consul)
5
6
  [![Dependency Status](https://gemnasium.com/badges/github.com/sue445/itamae-plugin-recipe-consul.svg)](https://gemnasium.com/github.com/sue445/itamae-plugin-recipe-consul)
6
7
 
7
8
  [![wercker status](https://app.wercker.com/status/1d28d36364b4f79161fc248c6c934072/m/master "wercker status")](https://app.wercker.com/project/bykey/1d28d36364b4f79161fc248c6c934072)
@@ -78,7 +79,7 @@ bundle exec rake itamae:centos70
78
79
  bundle exec rake spec:centos70
79
80
  ```
80
81
 
81
- see [Vagrantfile](Vagrantfile) and [Rakefile](Rakefile)
82
+ Avairable hosts are defined in [Vagrantfile](Vagrantfile) and [Rakefile](Rakefile)
82
83
 
83
84
  ## Contributing
84
85
 
@@ -89,3 +90,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/sue445
89
90
 
90
91
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
91
92
 
93
+ ## Special thanks
94
+ systemd unit file and init.d script
95
+
96
+ http://qiita.com/yunano/items/7ef5fa5670721de55627
data/Rakefile CHANGED
@@ -9,10 +9,11 @@ namespace :spec do
9
9
  task :all => HOSTS
10
10
 
11
11
  HOSTS.each do |host|
12
+ desc "Run serverspec to #{host}"
12
13
  RSpec::Core::RakeTask.new(host.to_sym) do |t|
13
14
  puts "Running tests to #{host} ..."
14
15
  ENV["TARGET_HOST"] = host
15
- t.pattern = "spec/*_spec.rb"
16
+ t.pattern = "spec/**/*_spec.rb"
16
17
  end
17
18
  end
18
19
  end
@@ -21,7 +22,7 @@ namespace :itamae do
21
22
  task :all => HOSTS
22
23
 
23
24
  HOSTS.each do |host|
24
- desc "Running itamae to #{host}"
25
+ desc "Run itamae to #{host}"
25
26
  task host do
26
27
  sh "bundle exec itamae ssh --host=#{host} --vagrant --node-yaml=recipes/node.yml recipes/install.rb"
27
28
  end
@@ -1,19 +1,3 @@
1
- node.validate! do
2
- {
3
- consul: {
4
- version: string,
5
- },
6
- }
7
- end
8
-
9
- node.reverse_merge!(
10
- consul: {
11
- src_dir: "/usr/local/src",
12
- bin_dir: "/usr/local/bin",
13
- data_dir: "/tmp/consul",
14
- gomaxprocs: 2,
15
- },
16
- )
17
-
18
- include_recipe "./download"
1
+ include_recipe "./setup"
2
+ include_recipe "./install"
19
3
  include_recipe "./service"
@@ -1,3 +1,4 @@
1
+ # Download and install consul executable file
1
2
  package "unzip"
2
3
 
3
4
  zip_name = "consul_#{node[:consul][:version]}_linux_amd64.zip"
@@ -0,0 +1,9 @@
1
+ if node[:platform_version].to_i >= 7
2
+ set_consul_systemd_unit "/etc/sysconfig/consul"
3
+ else
4
+ set_consul_initd_script "/etc/sysconfig/consul"
5
+ end
6
+
7
+ service "consul" do
8
+ action [:enable, :start]
9
+ end
@@ -0,0 +1,7 @@
1
+ if node[:platform_version].to_i >= 8
2
+ set_consul_systemd_unit "/etc/default/consul"
3
+
4
+ service "consul" do
5
+ action [:enable, :start]
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ # Setup init.d script or systemd unit
2
+ include_recipe "./definitions"
3
+
4
+ directory "/etc/consul.d"
5
+
6
+ case node[:platform]
7
+ when "debian"
8
+ include_recipe "./debian"
9
+
10
+ when "redhat"
11
+ include_recipe "./centos"
12
+ end
@@ -0,0 +1,49 @@
1
+ environment_content =
2
+ <<-EOS
3
+ GOMAXPROCS=#{node[:consul][:gomaxprocs]}
4
+ OPTIONS="#{node[:consul][:options]}"
5
+ EOS
6
+
7
+ # Set systemd unit file
8
+ define :set_consul_systemd_unit do
9
+ environment_file = params[:name]
10
+
11
+ file environment_file do
12
+ content environment_content
13
+ end
14
+
15
+ template "/etc/systemd/system/consul.service" do
16
+ variables(
17
+ environment_file: environment_file,
18
+ bin_path: "#{node[:consul][:bin_dir]}/consul",
19
+ data_dir: node[:consul][:data_dir],
20
+ )
21
+
22
+ notifies :run, "execute[systemctl daemon-reload]"
23
+ notifies :restart, "service[consul]"
24
+ end
25
+
26
+ execute "systemctl daemon-reload" do
27
+ action :nothing
28
+ end
29
+ end
30
+
31
+ # Set init.d script
32
+ define :set_consul_initd_script do
33
+ environment_file = params[:name]
34
+
35
+ file environment_file do
36
+ content environment_content
37
+ end
38
+
39
+ template "/etc/init.d/consul" do
40
+ mode "755"
41
+ variables(
42
+ environment_file: environment_file,
43
+ bin_path: "#{node[:consul][:bin_dir]}/consul",
44
+ data_dir: node[:consul][:data_dir],
45
+ )
46
+
47
+ notifies :restart, "service[consul]"
48
+ end
49
+ end
@@ -0,0 +1,18 @@
1
+ # Check required node values
2
+ node.validate! do
3
+ {
4
+ consul: {
5
+ version: string,
6
+ },
7
+ }
8
+ end
9
+
10
+ # Set default node values
11
+ node.reverse_merge!(
12
+ consul: {
13
+ src_dir: "/usr/local/src",
14
+ bin_dir: "/usr/local/bin",
15
+ data_dir: "/tmp/consul",
16
+ gomaxprocs: 2,
17
+ },
18
+ )
@@ -2,7 +2,7 @@ module Itamae
2
2
  module Plugin
3
3
  module Recipe
4
4
  module Consul
5
- VERSION = "0.1.0.beta1"
5
+ VERSION = "0.1.0.beta2"
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itamae-plugin-recipe-consul
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-05-03 00:00:00.000000000 Z
11
+ date: 2016-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: itamae
@@ -101,12 +101,14 @@ files:
101
101
  - itamae-plugin-recipe-consul.gemspec
102
102
  - lib/itamae/plugin/recipe/consul.rb
103
103
  - lib/itamae/plugin/recipe/consul/default.rb
104
- - lib/itamae/plugin/recipe/consul/download.rb
105
- - lib/itamae/plugin/recipe/consul/service.rb
106
- - lib/itamae/plugin/recipe/consul/templates/etc/default/consul.erb
107
- - lib/itamae/plugin/recipe/consul/templates/etc/init.d/consul.erb
108
- - lib/itamae/plugin/recipe/consul/templates/etc/sysconfig/consul.erb
109
- - lib/itamae/plugin/recipe/consul/templates/etc/systemd/system/consul.service.erb
104
+ - lib/itamae/plugin/recipe/consul/install.rb
105
+ - lib/itamae/plugin/recipe/consul/service/centos.rb
106
+ - lib/itamae/plugin/recipe/consul/service/debian.rb
107
+ - lib/itamae/plugin/recipe/consul/service/default.rb
108
+ - lib/itamae/plugin/recipe/consul/service/definitions.rb
109
+ - lib/itamae/plugin/recipe/consul/service/templates/etc/init.d/consul.erb
110
+ - lib/itamae/plugin/recipe/consul/service/templates/etc/systemd/system/consul.service.erb
111
+ - lib/itamae/plugin/recipe/consul/setup.rb
110
112
  - lib/itamae/plugin/recipe/consul/version.rb
111
113
  - recipes/install.rb
112
114
  - recipes/node.yml
@@ -1,78 +0,0 @@
1
- # ref. http://qiita.com/yunano/items/7ef5fa5670721de55627
2
- directory "/etc/consul.d"
3
-
4
- # Set systemd script
5
- define :consul_systemd_script do
6
- environment_file = params[:name]
7
-
8
- template "/etc/systemd/system/consul.service" do
9
- variables(
10
- environment_file: environment_file,
11
- bin_path: "#{node[:consul][:bin_dir]}/consul",
12
- data_dir: node[:consul][:data_dir],
13
- )
14
-
15
- notifies :run, "execute[systemctl daemon-reload]"
16
- notifies :restart, "service[consul]"
17
- end
18
-
19
- execute "systemctl daemon-reload" do
20
- action :nothing
21
- end
22
- end
23
-
24
- # Set init.d script
25
- define :consul_initd_script do
26
- environment_file = params[:name]
27
-
28
- template "/etc/init.d/consul" do
29
- mode "755"
30
- variables(
31
- environment_file: environment_file,
32
- bin_path: "#{node[:consul][:bin_dir]}/consul",
33
- data_dir: node[:consul][:data_dir],
34
- )
35
-
36
- notifies :restart, "service[consul]"
37
- end
38
- end
39
-
40
- case node[:platform]
41
- when "debian"
42
- environment_file = "/etc/default/consul"
43
-
44
- template environment_file do
45
- variables(
46
- gomaxprocs: node[:consul][:gomaxprocs],
47
- options: node[:consul][:options],
48
- )
49
- end
50
-
51
- if node[:platform_version].to_i >= 8
52
- consul_systemd_script environment_file
53
-
54
- service "consul" do
55
- action [:enable, :start]
56
- end
57
- end
58
-
59
- when "redhat"
60
- environment_file = "/etc/sysconfig/consul"
61
-
62
- template environment_file do
63
- variables(
64
- gomaxprocs: node[:consul][:gomaxprocs],
65
- options: node[:consul][:options],
66
- )
67
- end
68
-
69
- if node[:platform_version].to_i >= 7
70
- consul_systemd_script environment_file
71
- else
72
- consul_initd_script environment_file
73
- end
74
-
75
- service "consul" do
76
- action [:enable, :start]
77
- end
78
- end
@@ -1,2 +0,0 @@
1
- GOMAXPROCS=<%= @gomaxprocs %>
2
- OPTIONS="<%= @options %>"
@@ -1,2 +0,0 @@
1
- GOMAXPROCS=<%= @gomaxprocs %>
2
- OPTIONS="<%= @options %>"