itamae 1.0.0.beta23 → 1.0.0.beta24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e06a0ae4cf1116d4f4adc8965745ad028023900
4
- data.tar.gz: a76dd8f567f9f0abc222ea7f3fab1c4b4d94281b
3
+ metadata.gz: ea6fc052b822e3cde537f8c2f7b78116d5ed5875
4
+ data.tar.gz: c291f27cb784245988bc80b6eb5b41afef44704f
5
5
  SHA512:
6
- metadata.gz: 66f85f60c27e01d31d9d18ffbd4583135ecffb16347a8b4c4033ade2a2d3fc635d837ca1d13b77c4d810ea57c072474e713e7fd3b03f8fa80842bb1a124db720
7
- data.tar.gz: f85fba9783ee770af7fd6030cb75dfd8629c5b49e278663a3aabffd9fcdd3345f754f868896723162d0e5904383112c6a89d036df10df6515a5eb8008bf5a11f
6
+ metadata.gz: 5e7c82107830eca10417bd2bc4c2f2e1312420fcee1852015862ab2c992939e12d282a834213b492783b1639d6472f9c1c175822b0931b7e700e05d7e2bf8104
7
+ data.tar.gz: 7a54dda4b3e814ec755ea74f3fee019236579ba0343cc2339a9cdbe1d64590d312bcb6f63eee0032aa76fcbef67f98a0f4b82ca07c28b4028a91f43f748c56a9
data/lib/itamae/logger.rb CHANGED
@@ -39,6 +39,8 @@ module Itamae
39
39
  color_code = case severity
40
40
  when "INFO"
41
41
  :green
42
+ when "WARN"
43
+ :magenta
42
44
  when "ERROR"
43
45
  :red
44
46
  else
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
@@ -11,6 +11,7 @@ require 'itamae/resource/service'
11
11
  require 'itamae/resource/link'
12
12
  require 'itamae/resource/local_ruby_block'
13
13
  require 'itamae/resource/git'
14
+ require 'itamae/resource/user'
14
15
 
15
16
  module Itamae
16
17
  module Resource
@@ -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
@@ -1 +1 @@
1
- 1.0.0.beta23
1
+ 1.0.0.beta24
@@ -1,5 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
+ describe user("itamae") do
4
+ it { should exist }
5
+ it { should have_uid 1234 }
6
+ end
7
+
3
8
  describe file('/tmp/included_recipe') do
4
9
  it { should be_file }
5
10
  end
@@ -1,7 +1,11 @@
1
1
  include_recipe "./included.rb"
2
2
 
3
3
  # TODO: replace with user resource
4
- execute 'id itamae || useradd itamae'
4
+ #execute 'id itamae || useradd itamae'
5
+
6
+ user "itamae" do
7
+ uid 1234
8
+ end
5
9
 
6
10
  ######
7
11
 
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.beta23
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