terraform 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -45,7 +45,7 @@ module Terraform
45
45
  # These are very common tasks which are needed by almost everyone, and so they're bundled with this DSL.
46
46
  #
47
47
 
48
- def package_installed?(package) `dpkg -s #{package} 2> /dev/null | grep Status`.match(/\sinstalled/) end
48
+ def package_installed?(package) !!`dpkg -s #{package} 2> /dev/null | grep Status`.match(/\sinstalled/) end
49
49
  def install_package(package)
50
50
  # Specify a noninteractive frontend, so dpkg won't prompt you for info. -q is quiet; -y is "answer yes".
51
51
  shell "sudo DEBIAN_FRONTEND=noninteractive apt-get install -qy #{package}"
@@ -133,8 +133,7 @@ module Terraform
133
133
  ensure_packages "curl", "build-essential", "libxslt1-dev", "libxml2-dev", "libssl-dev"
134
134
 
135
135
  dep "rbenv ruby: #{ruby_version}" do
136
- # `rbenv version` is better than `ruby -v`, as its version string is consistent across Ruby versions.
137
- met? { `which ruby`.include?("rbenv") && `rbenv version`.include?(ruby_version) }
136
+ met? { `bash -lc 'which ruby'`.include?("rbenv") && `rbenv versions`.include?(ruby_version) }
138
137
  meet do
139
138
  puts "Compiling Ruby will take a few minutes."
140
139
  shell "rbenv install #{ruby_version}"
@@ -142,5 +141,15 @@ module Terraform
142
141
  end
143
142
  end
144
143
  end
144
+
145
+ def user_exists?(username) !!`id #{username} 2> /dev/null`.match(/^uid=\d+/) end
146
+ def create_user(username) shell "useradd -m #{username}" end
147
+
148
+ def ensure_user(username)
149
+ dep "user: #{username}" do
150
+ met? { user_exists?(username) }
151
+ meet { create_user(username) }
152
+ end
153
+ end
145
154
  end
146
155
  end
@@ -1,3 +1,3 @@
1
1
  module Terraform
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -115,4 +115,11 @@ class DslTest < Scope::TestCase
115
115
  assert meet_run
116
116
  end
117
117
  end
118
+
119
+ context "ensure_user" do
120
+ should "determine if a user exists" do
121
+ assert user_exists?("root")
122
+ refute user_exists?("fake_username")
123
+ end
124
+ end
118
125
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terraform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-08 00:00:00.000000000Z
12
+ date: 2012-10-11 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: scope
16
- requirement: &70229330495600 !ruby/object:Gem::Requirement
16
+ requirement: &28526960 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.2.3
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70229330495600
24
+ version_requirements: *28526960
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rr
27
- requirement: &70229330493900 !ruby/object:Gem::Requirement
27
+ requirement: &28526300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 1.0.4
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70229330493900
35
+ version_requirements: *28526300
36
36
  description:
37
37
  email:
38
38
  - phil.crosby@gmail.com
@@ -74,6 +74,5 @@ rubygems_version: 1.8.10
74
74
  signing_key:
75
75
  specification_version: 3
76
76
  summary: Set up a cold, inhospitable system using Terraform.
77
- test_files:
78
- - test/test_helper.rb
79
- - test/unit/terraform/dsl_test.rb
77
+ test_files: []
78
+ has_rdoc: