itamae-plugin-recipe-etcd 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/README.md +66 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/itamae-plugin-recipe-etcd.gemspec +24 -0
- data/lib/itamae/plugin/recipe/etcd.rb +11 -0
- data/lib/itamae/plugin/recipe/etcd/attributes.rb +35 -0
- data/lib/itamae/plugin/recipe/etcd/default.rb +44 -0
- data/lib/itamae/plugin/recipe/etcd/disable.rb +5 -0
- data/lib/itamae/plugin/recipe/etcd/enable.rb +5 -0
- data/lib/itamae/plugin/recipe/etcd/etc/profile.d/etcdctl.sh.erb +1 -0
- data/lib/itamae/plugin/recipe/etcd/etcd.service.erb +52 -0
- data/lib/itamae/plugin/recipe/etcd/templates/etc/profile.d/etcdctl.sh.erb +1 -0
- data/lib/itamae/plugin/recipe/etcd/templates/etcd.service.erb +51 -0
- data/lib/itamae/plugin/recipe/etcd/version.rb +9 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b2670bf96dd7e801e64de04f5acf43a89bbcefd0
|
4
|
+
data.tar.gz: 9461e7a373ac154ef2f72c798f67a7b398420846
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8f8077dd5ebd47846a543819015a86f6cb132ea77e35e0863ad968cd993930165977ca92ad6cc6ba57ee3707683979a37d7b2d72167077c2d626bc0beb5254f6
|
7
|
+
data.tar.gz: c0484f04d25f9b9fd312915350f5f229f7adb51d9b7164d8b111d4983883e3ffb2662fbe8df9e4de319efda43c759fc5b129e426121571da685f7046bb89db13
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Itamae::Plugin::Recipe::Etcd
|
2
|
+
|
3
|
+
Itamae recipe plugin for etcd v2.x.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'itamae-plugin-recipe-etcd'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install itamae-plugin-recipe-etcd
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Install
|
24
|
+
|
25
|
+
```
|
26
|
+
include_recipe "etcd::install"
|
27
|
+
|
28
|
+
include_recipe "etcd::enable"
|
29
|
+
include_recipe "etcd::disable"
|
30
|
+
```
|
31
|
+
|
32
|
+
### Usage
|
33
|
+
|
34
|
+
node.yml example
|
35
|
+
|
36
|
+
```
|
37
|
+
etcd:
|
38
|
+
listen_client_urls: http://localhost:2379
|
39
|
+
listen_peer_urls: http://localhost:2380
|
40
|
+
advertise_client_urls: http://localhost:2379
|
41
|
+
initial_advertise_peer_urls: http://localhost:2380
|
42
|
+
etcdctl:
|
43
|
+
peers: http://localhost:2379
|
44
|
+
|
45
|
+
```
|
46
|
+
|
47
|
+
see other attributes => [attribtues.rb](https://github.com/yss44/itamae-plugin-recipe-etcd/blob/master/lib/itamae/plugin/recipe/etcd/attributes.rb)
|
48
|
+
|
49
|
+
## Todo
|
50
|
+
|
51
|
+
write specs.
|
52
|
+
|
53
|
+
|
54
|
+
## Development
|
55
|
+
|
56
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
57
|
+
|
58
|
+
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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
1. Fork it ( https://github.com/[my-github-username]/itamae-plugin-recipe-etcd/fork )
|
63
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
64
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
65
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
66
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "itamae/plugin/recipe/etcd"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'itamae/plugin/recipe/etcd/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "itamae-plugin-recipe-etcd"
|
8
|
+
spec.version = Itamae::Plugin::Recipe::Etcd::VERSION
|
9
|
+
spec.authors = ["yss44"]
|
10
|
+
spec.email = ["nya060@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{itamae plugin for etcd 2.x}
|
13
|
+
spec.description = %q{itamae plugin for etcd 2.x}
|
14
|
+
spec.homepage = "https://github.com/yss44/itamae-plugin-recipe-etcd"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
node['etcd'] ||= {}
|
2
|
+
|
3
|
+
# modify as you want but require 2.0.0 >=
|
4
|
+
node['etcd']['version'] ||= '2.0.9'
|
5
|
+
|
6
|
+
node['etcd']['binary_baseurl'] ||= "https://github.com/coreos/etcd/releases/download"
|
7
|
+
node['etcd']['binary_url'] ||= "#{node['etcd']['binary_baseurl']}/v#{node['etcd']['version']}/etcd-v#{node['etcd']['version']}-linux-amd64.tar.gz"
|
8
|
+
node['etcd']['install_dir'] ||= '/usr/local/bin'
|
9
|
+
node['etcd']['data_dir'] ||= '/var/lib/etcd'
|
10
|
+
node['etcd']['systemd_dir'] ||= '/etc/systemd/system'
|
11
|
+
|
12
|
+
# etcd server name
|
13
|
+
node['etcd']['name'] ||= "%H"
|
14
|
+
|
15
|
+
# where itself listens.
|
16
|
+
node['etcd']['listen_client_urls'] ||= 'http://localhost:2379,http://localhost:4001'
|
17
|
+
node['etcd']['listen_peer_urls'] ||= 'http://localhost:2380,http://localhost:7001'
|
18
|
+
# notify other etcd cluster where itself listen.
|
19
|
+
node['etcd']['advertise_client_urls'] ||= 'http://localhost:2379,http://localhost:4001'
|
20
|
+
node['etcd']['initial_advertise_peer_urls'] ||= 'http://localhost:2379,http://localhost:4001'
|
21
|
+
|
22
|
+
node['etcd']['discovery'] ||= node['etcd']['discovery']
|
23
|
+
|
24
|
+
# config for secure etcd cluster if needed
|
25
|
+
node['etcd']['ca_file'] ||= nil
|
26
|
+
node['etcd']['cert_file'] ||= nil
|
27
|
+
node['etcd']['key_file'] ||= nil
|
28
|
+
node['etcd']['peer_ca_file'] ||= nil
|
29
|
+
node['etcd']['peer_cert_file'] ||= nil
|
30
|
+
node['etcd']['peer_key_file'] ||= nil
|
31
|
+
|
32
|
+
|
33
|
+
node['etcdctl'] ||= {}
|
34
|
+
|
35
|
+
node['etcdctl']['peers'] ||= "http://127.0.0.1:2379"
|
@@ -0,0 +1,44 @@
|
|
1
|
+
include_recipe './attributes.rb'
|
2
|
+
|
3
|
+
# create user
|
4
|
+
user "etcd" do
|
5
|
+
action :create
|
6
|
+
end
|
7
|
+
execute "disable user shell" do
|
8
|
+
command "usermod -s /sbin/nologin etcd"
|
9
|
+
end
|
10
|
+
|
11
|
+
# create dirs
|
12
|
+
directory node['etcd']['data_dir'] do
|
13
|
+
action :create
|
14
|
+
owner "etcd"
|
15
|
+
end
|
16
|
+
|
17
|
+
# file
|
18
|
+
template "#{node['etcd']['systemd_dir']}/etcd.service" do
|
19
|
+
source File.expand_path(File.dirname(__FILE__)) + '/templates/etcd.service.erb'
|
20
|
+
variables node['etcd']
|
21
|
+
mode "755"
|
22
|
+
owner "root"
|
23
|
+
end
|
24
|
+
|
25
|
+
template "/etc/profile.d/etcdctl.sh" do
|
26
|
+
variables node['etcdctl']
|
27
|
+
owner 'root'
|
28
|
+
mode '755'
|
29
|
+
end
|
30
|
+
|
31
|
+
execute "install etcd" do
|
32
|
+
|
33
|
+
command <<-EOH
|
34
|
+
cd /tmp
|
35
|
+
curl -L #{node['etcd']['binary_url']} -o etcd-v#{node['etcd']['version']}-linux-amd64.tar.gz
|
36
|
+
tar xzvf etcd-v#{node['etcd']['version']}-linux-amd64.tar.gz
|
37
|
+
cd etcd-v#{node['etcd']['version']}-linux-amd64
|
38
|
+
mv etcd #{node['etcd']['install_dir']}/etcd
|
39
|
+
mv etcdctl #{node['etcd']['install_dir']}/etcdctl
|
40
|
+
rm -rf etcd-v#{node['etcd']['version']}-linux-amd64
|
41
|
+
EOH
|
42
|
+
not_if "test -e #{node['etcd']['install_dir']}/etcd && #{node['etcd']['install_dir']}/etcd --version | grep -q '#{node['etcd']['version']}' "
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
export ETCDCTL_PEERS=<%= @peers %>
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# /usr/lib64/systemd/system/etcd.service
|
2
|
+
[Unit]
|
3
|
+
Description=etcd <%= node['etcd']['version'] %>
|
4
|
+
|
5
|
+
[Service]
|
6
|
+
|
7
|
+
User=etcd
|
8
|
+
|
9
|
+
Environment="ETCD_DATA_DIR=<%= node['etcd']['data_dir'] %>"
|
10
|
+
Environment="ETCD_NAME=<%= node['etcd']['name'] %>"
|
11
|
+
|
12
|
+
Environment="ETCD_LISTEN_CLIENT_URLS=<%= node['etcd']['listen_client_urls'] %>"
|
13
|
+
Environment="ETCD_LISTEN_PEER_URLS=<%= node['etcd']['listen_peer_urls'] %>"
|
14
|
+
Environment="ETCD_ADVERTISE_CLIENT_URLS=<%= node['etcd']['advertise_client_urls'] %>"
|
15
|
+
Environment="ETCD_INITIAL_ADVERTISE_PEER_URLS=<%= node['etcd']['initial_advertise_peer_urls'] %>"
|
16
|
+
|
17
|
+
<% if node['etcd']['discovery'] %>
|
18
|
+
Environment="ETCD_DISCOVERY=<%= node['etcd']['discovery'] %>"
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
|
22
|
+
<% if node['etcd']['ca_file'] %>
|
23
|
+
Environment="ETCD_CA_FILE=<%= node['etcd']['ca_file'] %>"
|
24
|
+
<% end %>
|
25
|
+
<% if node['etcd']['cert_file'] %>
|
26
|
+
Environment="ETCD_CERT_FILE=<%= node['etcd']['cert_file'] %>"
|
27
|
+
<% end %>
|
28
|
+
<% if node['etcd']['key_file'] %>
|
29
|
+
Environment="ETCD_KEY_FILE=<%= node['etcd']['key_file'] %>"
|
30
|
+
<% end %>
|
31
|
+
<% if node['etcd']['peer_ca_file'] %>
|
32
|
+
Environment="ETCD_PEER_CA_FILE=<%= node['etcd']['peer_ca_file'] %>"
|
33
|
+
<% end %>
|
34
|
+
<% if node['etcd']['peer_cert_file'] %>
|
35
|
+
Environment="ETCD_PEER_CERT_FILE=<%= node['etcd']['peer_cert_file'] %>"
|
36
|
+
<% end %>
|
37
|
+
<% if node['etcd']['peer_key_file'] %>
|
38
|
+
Environment="ETCD_PEER_KEY_FILE=<%= node['etcd']['peer_key_file'] %>"
|
39
|
+
<% end %>
|
40
|
+
|
41
|
+
|
42
|
+
ExecStart=<%= node['etcd']['install_dir'] %>/etcd
|
43
|
+
|
44
|
+
Restart=always
|
45
|
+
RestartSec=10s
|
46
|
+
|
47
|
+
LimitNOFILE=40000
|
48
|
+
|
49
|
+
|
50
|
+
[Install]
|
51
|
+
|
52
|
+
WantedBy=multi-user.target
|
@@ -0,0 +1 @@
|
|
1
|
+
export ETCDCTL_PEERS=<%= @peers %>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# /usr/lib64/systemd/system/etcd.service
|
2
|
+
[Unit]
|
3
|
+
Description=etcd <%= node['etcd']['version'] %>
|
4
|
+
|
5
|
+
[Service]
|
6
|
+
|
7
|
+
User=etcd
|
8
|
+
|
9
|
+
Environment="ETCD_DATA_DIR=<%= node['etcd']['data_dir'] %>"
|
10
|
+
Environment="ETCD_NAME=<%= node['etcd']['name'] %>"
|
11
|
+
|
12
|
+
Environment="ETCD_LISTEN_CLIENT_URLS=<%= node['etcd']['listen_client_urls'] %>"
|
13
|
+
Environment="ETCD_LISTEN_PEER_URLS=<%= node['etcd']['listen_peer_urls'] %>"
|
14
|
+
Environment="ETCD_ADVERTISE_CLIENT_URLS=<%= node['etcd']['advertise_client_urls'] %>"
|
15
|
+
Environment="ETCD_INITIAL_ADVERTISE_PEER_URLS=<%= node['etcd']['initial_advertise_peer_urls'] %>"
|
16
|
+
|
17
|
+
<% if node['etcd']['discovery'] %>
|
18
|
+
Environment="ETCD_DISCOVERY=<%= node['etcd']['discovery'] %>"
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<% if node['etcd']['ca_file'] %>
|
22
|
+
Environment="ETCD_CA_FILE=<%= node['etcd']['ca_file'] %>"
|
23
|
+
<% end %>
|
24
|
+
<% if node['etcd']['cert_file'] %>
|
25
|
+
Environment="ETCD_CERT_FILE=<%= node['etcd']['cert_file'] %>"
|
26
|
+
<% end %>
|
27
|
+
<% if node['etcd']['key_file'] %>
|
28
|
+
Environment="ETCD_KEY_FILE=<%= node['etcd']['key_file'] %>"
|
29
|
+
<% end %>
|
30
|
+
<% if node['etcd']['peer_ca_file'] %>
|
31
|
+
Environment="ETCD_PEER_CA_FILE=<%= node['etcd']['peer_ca_file'] %>"
|
32
|
+
<% end %>
|
33
|
+
<% if node['etcd']['peer_cert_file'] %>
|
34
|
+
Environment="ETCD_PEER_CERT_FILE=<%= node['etcd']['peer_cert_file'] %>"
|
35
|
+
<% end %>
|
36
|
+
<% if node['etcd']['peer_key_file'] %>
|
37
|
+
Environment="ETCD_PEER_KEY_FILE=<%= node['etcd']['peer_key_file'] %>"
|
38
|
+
<% end %>
|
39
|
+
|
40
|
+
|
41
|
+
ExecStart=<%= node['etcd']['install_dir'] %>/etcd
|
42
|
+
|
43
|
+
Restart=always
|
44
|
+
RestartSec=10s
|
45
|
+
|
46
|
+
LimitNOFILE=40000
|
47
|
+
|
48
|
+
|
49
|
+
[Install]
|
50
|
+
|
51
|
+
WantedBy=multi-user.target
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: itamae-plugin-recipe-etcd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- yss44
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-11 00:00:00.000000000 Z
|
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: '1.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: itamae plugin for etcd 2.x
|
42
|
+
email:
|
43
|
+
- nya060@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rspec"
|
50
|
+
- ".travis.yml"
|
51
|
+
- Gemfile
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/console
|
55
|
+
- bin/setup
|
56
|
+
- itamae-plugin-recipe-etcd.gemspec
|
57
|
+
- lib/itamae/plugin/recipe/etcd.rb
|
58
|
+
- lib/itamae/plugin/recipe/etcd/attributes.rb
|
59
|
+
- lib/itamae/plugin/recipe/etcd/default.rb
|
60
|
+
- lib/itamae/plugin/recipe/etcd/disable.rb
|
61
|
+
- lib/itamae/plugin/recipe/etcd/enable.rb
|
62
|
+
- lib/itamae/plugin/recipe/etcd/etc/profile.d/etcdctl.sh.erb
|
63
|
+
- lib/itamae/plugin/recipe/etcd/etcd.service.erb
|
64
|
+
- lib/itamae/plugin/recipe/etcd/templates/etc/profile.d/etcdctl.sh.erb
|
65
|
+
- lib/itamae/plugin/recipe/etcd/templates/etcd.service.erb
|
66
|
+
- lib/itamae/plugin/recipe/etcd/version.rb
|
67
|
+
homepage: https://github.com/yss44/itamae-plugin-recipe-etcd
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.2.2
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: itamae plugin for etcd 2.x
|
91
|
+
test_files: []
|
92
|
+
has_rdoc:
|