itamae 1.0.0.beta2 → 1.0.0.beta3

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: 240aa7e6557872fd35c36c24692c8a0e3f714809
4
- data.tar.gz: 516ef413cfc3a830f63fb83b9d1207fff66a5f00
3
+ metadata.gz: 475a40243822c6fc6e435ba1876f210574f6ea46
4
+ data.tar.gz: 0b708944f87933422ad4ba8895c82911a7b8bc9c
5
5
  SHA512:
6
- metadata.gz: 769d71f69c3452ebfbfae501b1278a1931ca5306ce00f2c88a681586e1da78ecc83f723b0f04616c4216c2901158dde1f5e98fb62c8f52e5c299699eb99abc8b
7
- data.tar.gz: 16cde3481cf61c3d8aa60adaa3e630e293f36263674dea4dda08cde2e83cc54bf048746501fc0de098dbc6b7ec84ee45dda63da65653195dbd6414392b9dc46c
6
+ metadata.gz: d0c73c84729f8846f6a4f824012cdea2c0214accdb5460f2096845c974625602aa5be91fdc8b2b170f174d97d80fbaf60c8719827e6e64e373b918e29b585bd9
7
+ data.tar.gz: 0a16cc69999536d1ec3b6e2674926f6faa40fd5e28146a628d3247451faad2c216c07f7eb84f7568b3c8c33a00499c7d51ee4aaa953d7071cc2e440a4fcf3d67
data/README.md CHANGED
@@ -42,6 +42,18 @@ I, [2013-12-24T14:05:51.339119 #7156] INFO -- : <<< Succeeded.
42
42
  $ itamae ssh -j example/node.json -h 192.168.10.10 -p 22 -u user -i /path/to/private_key example/recipe.rb
43
43
  ```
44
44
 
45
+ ## Recipes
46
+
47
+ You can write recipes like Chef's one.
48
+
49
+ ```ruby
50
+ package "dstat" do
51
+ action :install
52
+ end
53
+ ```
54
+
55
+ Further example is here: [spec/integration/recipes/default.rb](spec/integration/recipes/default.rb)
56
+
45
57
  ## Run tests
46
58
 
47
59
  Requirements: Vagrant
@@ -7,6 +7,7 @@ require 'itamae/resource/directory'
7
7
  require 'itamae/resource/template'
8
8
  require 'itamae/resource/execute'
9
9
  require 'itamae/resource/mail_alias'
10
+ require 'itamae/resource/service'
10
11
 
11
12
  module Itamae
12
13
  module Resource
@@ -0,0 +1,36 @@
1
+ require 'itamae'
2
+
3
+ module Itamae
4
+ module Resource
5
+ class Service < Base
6
+ define_attribute :action, default: :nothing
7
+ define_attribute :name, type: String, default_name: true
8
+
9
+ def start_action
10
+ run_init_script("start")
11
+ end
12
+
13
+ def stop_action
14
+ run_init_script("stop")
15
+ end
16
+
17
+ def restart_action
18
+ run_init_script("restart")
19
+ end
20
+
21
+ def reload_action
22
+ run_init_script("reload")
23
+ end
24
+
25
+ private
26
+ def run_init_script(command)
27
+ run_command("#{shell_escape(init_script_path)} #{command}")
28
+ end
29
+
30
+ def init_script_path
31
+ "/etc/init.d/#{name}"
32
+ end
33
+ end
34
+ end
35
+ end
36
+
@@ -1,3 +1,3 @@
1
1
  module Itamae
2
- VERSION = "1.0.0.beta2"
2
+ VERSION = "1.0.0.beta3"
3
3
  end
@@ -53,3 +53,17 @@ describe file('/tmp/subscribes') do
53
53
  its(:content) { should eq("2431") }
54
54
  end
55
55
 
56
+ describe file('/tmp/cron_stopped') do
57
+ it { should be_file }
58
+ its(:content) do
59
+ expect(subject.content.lines.size).to eq 0
60
+ end
61
+ end
62
+
63
+ describe file('/tmp/cron_running') do
64
+ it { should be_file }
65
+ its(:content) do
66
+ expect(subject.content.lines.size).to eq 1
67
+ end
68
+ end
69
+
@@ -72,4 +72,19 @@ file "/tmp/never_exist2" do
72
72
  not_if "exit 0"
73
73
  end
74
74
 
75
+ ######
76
+
77
+ service "cron" do
78
+ action :stop
79
+ end
80
+
81
+ execute "ps axu | grep cron | grep -v grep > /tmp/cron_stopped; true"
82
+
83
+ service "cron" do
84
+ action :start
85
+ end
86
+
87
+ execute "ps axu | grep cron | grep -v grep > /tmp/cron_running; true"
88
+
89
+ ######
75
90
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itamae
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta2
4
+ version: 1.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Arai
@@ -166,9 +166,6 @@ files:
166
166
  - README.md
167
167
  - Rakefile
168
168
  - bin/itamae
169
- - example/foo
170
- - example/node.json
171
- - example/recipe.rb
172
169
  - itamae.gemspec
173
170
  - lib/itamae.rb
174
171
  - lib/itamae/cli.rb
@@ -183,6 +180,7 @@ files:
183
180
  - lib/itamae/resource/mail_alias.rb
184
181
  - lib/itamae/resource/package.rb
185
182
  - lib/itamae/resource/remote_file.rb
183
+ - lib/itamae/resource/service.rb
186
184
  - lib/itamae/resource/template.rb
187
185
  - lib/itamae/resource_collection.rb
188
186
  - lib/itamae/runner.rb
data/example/foo DELETED
@@ -1 +0,0 @@
1
- Hello
data/example/node.json DELETED
@@ -1 +0,0 @@
1
- {"file_source": "foo"}
data/example/recipe.rb DELETED
@@ -1,15 +0,0 @@
1
- package "git" do
2
- action :install
3
- end
4
-
5
- remote_file '/home/vagrant/foo' do
6
- source node['file_source']
7
- end
8
-
9
- directory '/tmp/itamae' do
10
- action :create
11
- mode '0777'
12
- owner 'vagrant'
13
- group 'vagrant'
14
- end
15
-