itamae 1.0.0.beta23 → 1.0.0.beta24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/itamae/logger.rb +2 -0
- data/lib/itamae/recipe.rb +4 -0
- data/lib/itamae/resource.rb +1 -0
- data/lib/itamae/resource/user.rb +31 -0
- data/lib/itamae/runner.rb +8 -0
- data/lib/itamae/version.txt +1 -1
- data/spec/integration/default_spec.rb +5 -0
- data/spec/integration/recipes/default.rb +5 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea6fc052b822e3cde537f8c2f7b78116d5ed5875
|
4
|
+
data.tar.gz: c291f27cb784245988bc80b6eb5b41afef44704f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e7c82107830eca10417bd2bc4c2f2e1312420fcee1852015862ab2c992939e12d282a834213b492783b1639d6472f9c1c175822b0931b7e700e05d7e2bf8104
|
7
|
+
data.tar.gz: 7a54dda4b3e814ec755ea74f3fee019236579ba0343cc2339a9cdbe1d64590d312bcb6f63eee0032aa76fcbef67f98a0f4b82ca07c28b4028a91f43f748c56a9
|
data/lib/itamae/logger.rb
CHANGED
data/lib/itamae/recipe.rb
CHANGED
@@ -21,6 +21,8 @@ module Itamae
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def run(options = {})
|
24
|
+
Logger.info "> Applying recipe... (#{@path})"
|
25
|
+
|
24
26
|
@dependencies.each do |resource|
|
25
27
|
case resource
|
26
28
|
when Resource::Base
|
@@ -33,6 +35,8 @@ module Itamae
|
|
33
35
|
@delayed_actions.uniq.each do |action, resource|
|
34
36
|
resource.run(action, dry_run: options[:dry_run])
|
35
37
|
end
|
38
|
+
|
39
|
+
Logger.info "< Finished. (#{@path})"
|
36
40
|
end
|
37
41
|
|
38
42
|
private
|
data/lib/itamae/resource.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'itamae'
|
2
|
+
|
3
|
+
module Itamae
|
4
|
+
module Resource
|
5
|
+
class User < Base
|
6
|
+
define_attribute :action, default: :create
|
7
|
+
define_attribute :username, type: String, default_name: true
|
8
|
+
define_attribute :gid, type: String
|
9
|
+
define_attribute :home, type: String
|
10
|
+
define_attribute :password, type: String
|
11
|
+
define_attribute :system_user, type: [TrueClass, FalseClass]
|
12
|
+
define_attribute :uid, type: [String, Integer]
|
13
|
+
|
14
|
+
def create_action
|
15
|
+
if run_specinfra(:check_user_exists, username)
|
16
|
+
Logger.warn "User already exists. Currently, user resources do not support to modify attributes."
|
17
|
+
else
|
18
|
+
args = ["useradd"]
|
19
|
+
args << "-g" << gid if gid
|
20
|
+
args << "-d" << home if home
|
21
|
+
args << "-p" << password if password
|
22
|
+
args << "-r" if system_user
|
23
|
+
args << "-u" << uid.to_s if uid
|
24
|
+
args << username
|
25
|
+
run_command(args)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
data/lib/itamae/runner.rb
CHANGED
@@ -5,6 +5,8 @@ module Itamae
|
|
5
5
|
class Runner
|
6
6
|
class << self
|
7
7
|
def run(recipe_files, backend_type, options)
|
8
|
+
Logger.info "Starting Itamae..."
|
9
|
+
|
8
10
|
set_backend_from_options(backend_type, options)
|
9
11
|
|
10
12
|
runner = self.new(node_from_options(options))
|
@@ -20,6 +22,12 @@ module Itamae
|
|
20
22
|
hash = {}
|
21
23
|
|
22
24
|
if options[:ohai]
|
25
|
+
unless Backend.instance.run_command("which ohai", error: false).exit_status == 0
|
26
|
+
# install Chef (I'd like to replace Ohai with single binary...)
|
27
|
+
Logger.info "Installing Chef to use Ohai..."
|
28
|
+
Backend.instance.run_command("curl -L https://www.opscode.com/chef/install.sh | bash")
|
29
|
+
end
|
30
|
+
|
23
31
|
Logger.info "Loading node data via ohai..."
|
24
32
|
hash.merge!(JSON.parse(Backend.instance.run_command("ohai").stdout))
|
25
33
|
end
|
data/lib/itamae/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0.
|
1
|
+
1.0.0.beta24
|
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.
|
4
|
+
version: 1.0.0.beta24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
@@ -173,6 +173,7 @@ files:
|
|
173
173
|
- lib/itamae/resource/remote_file.rb
|
174
174
|
- lib/itamae/resource/service.rb
|
175
175
|
- lib/itamae/resource/template.rb
|
176
|
+
- lib/itamae/resource/user.rb
|
176
177
|
- lib/itamae/runner.rb
|
177
178
|
- lib/itamae/version.rb
|
178
179
|
- lib/itamae/version.txt
|