qb 0.1.17 → 0.1.18

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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -2
  3. data/.gitmodules +6 -0
  4. data/.qb-options.yml +1 -1
  5. data/Gemfile +2 -0
  6. data/README.md +6 -1
  7. data/exe/qb +10 -5
  8. data/lib/qb/options.rb +15 -6
  9. data/lib/qb/role.rb +39 -7
  10. data/lib/qb/version.rb +1 -1
  11. data/library/qb_facts.py +47 -7
  12. data/qb.gemspec +12 -6
  13. data/roles/nrser.rb/library/vars.rb +1 -3
  14. data/roles/nrser.state_mate/.gitignore +38 -0
  15. data/roles/nrser.state_mate/.rspec +2 -0
  16. data/roles/nrser.state_mate/Gemfile +8 -0
  17. data/roles/nrser.state_mate/Gemfile.lock +46 -0
  18. data/roles/nrser.state_mate/README.md +45 -0
  19. data/roles/nrser.state_mate/VERSION +1 -0
  20. data/roles/nrser.state_mate/defaults/main.yml +3 -0
  21. data/roles/nrser.state_mate/library/state +82 -0
  22. data/roles/nrser.state_mate/meta/main.yml +138 -0
  23. data/roles/nrser.state_mate/spec/defaults/set_types_spec.rb +112 -0
  24. data/roles/nrser.state_mate/spec/nrser.state_mate_spec.rb +7 -0
  25. data/roles/nrser.state_mate/spec/spec_helper.rb +50 -0
  26. data/roles/nrser.state_mate/tasks/main.yml +7 -0
  27. data/roles/nrser.state_mate/test/ansible/ansible.cfg +5 -0
  28. data/roles/nrser.state_mate/test/ansible/hosts +1 -0
  29. data/roles/nrser.state_mate/test/ansible/template.yml +7 -0
  30. data/roles/qb.hack_npm/README.md +6 -0
  31. data/roles/qb.hack_npm/meta/main.yml +12 -0
  32. data/roles/qb.hack_npm/meta/qb.yml +49 -0
  33. data/roles/qb.hack_npm/tasks/create.yml +21 -0
  34. data/roles/qb.hack_npm/tasks/main.yml +74 -0
  35. data/roles/qb.hack_npm/vars/main.yml +15 -0
  36. data/roles/qb.install_gem/defaults/main.yml +1 -1
  37. data/roles/qb.npm_package/defaults/main.yml +17 -0
  38. data/roles/qb.npm_package/meta/main.yml +16 -0
  39. data/roles/{qb.npm → qb.npm_package}/meta/qb.yml +3 -2
  40. data/roles/qb.npm_package/tasks/main.yml +27 -0
  41. data/roles/qb.qb_role/meta/qb.yml +1 -1
  42. data/roles/qb.qb_role/templates/qb.yml.j2 +1 -1
  43. data/roles/qb.unhack_gem/README.md +10 -0
  44. data/roles/qb.unhack_gem/defaults/main.yml +2 -0
  45. data/roles/qb.unhack_gem/meta/main.yml +8 -0
  46. data/roles/qb.unhack_gem/meta/qb.yml +21 -0
  47. data/roles/qb.unhack_gem/tasks/main.yml +27 -0
  48. data/roles/qb.vars/.qb-options.yml +3 -0
  49. data/roles/qb.vars/README.md +1 -0
  50. data/roles/qb.vars/meta/main.yml +8 -0
  51. data/roles/qb.vars/meta/qb.yml +21 -0
  52. data/roles/qb.vars/tasks/main.yml +6 -0
  53. metadata +70 -7
  54. data/roles/qb.npm/defaults/main.yml +0 -16
  55. data/roles/qb.npm/meta/main.yml +0 -14
  56. data/roles/qb.npm/tasks/main.yml +0 -8
  57. data/roles/qb.npm/templates/package.json.j2 +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5d6098e280b9b7d81dbbf61d2ded63240cbbc82
4
- data.tar.gz: 2b24e1ce4f95cb7028d0db244a8441227fbfc8e1
3
+ metadata.gz: 6eb975b210be08ce0337c76edfd3206c3182b7f3
4
+ data.tar.gz: e33159e190cb5562a43c3cedd7c30e1179ee7a0e
5
5
  SHA512:
6
- metadata.gz: 19ce871a0b7e8e43ed1e0d105cb9bcc89205af709dfa712b552d040a74ca48b432c34280749caa028b71d66c23d3b99f97322fa038064c040c80fab2e43ba3fd
7
- data.tar.gz: 56a79b341ae740a8d4e75d42a8af92b1e019a819b326ea8f7f6c3bc3b9f419f7b5f6f317c3563ebc1fa9e0763cfebcc6eb9589fa448ae1793f9f0685ade7e7a3
6
+ metadata.gz: 741b549e8146722b757941e5c3afd9dc9d67ed889ddd8d455038e18d8dd651fdd6e98003338fa1a277087fd1835d9b447be37d06868db112a1da853491a30af6
7
+ data.tar.gz: e82f75b6e60cae6630c6b9255021ce4da2104608d0b18675ec5da20a0f55cc3f19ee5eb288720e9f6b5c615e243b1480274b52ab41d991e4a9d4e73ce3b7afd3
data/.gitignore CHANGED
@@ -12,8 +12,9 @@
12
12
  .AppleDouble
13
13
  .LSOverride
14
14
 
15
- # Icon must end with two
16
- Icon
15
+ # Icon must end with two
16
+ Icon
17
+
17
18
 
18
19
  # Thumbnails
19
20
  ._*
data/.gitmodules CHANGED
@@ -10,3 +10,9 @@
10
10
  [submodule "roles/nrser.rb"]
11
11
  path = roles/nrser.rb
12
12
  url = git@github.com:nrser/ansible-nrser.rb.git
13
+ [submodule "roles/nrser.state_mate"]
14
+ path = roles/nrser.state_mate
15
+ url = git@github.com:nrser/ansible-nrser.state_mate.git
16
+ [submodule "dev/gems/state_mate"]
17
+ path = dev/gems/state_mate
18
+ url = git@github.com:nrser/state_mate
data/.qb-options.yml CHANGED
@@ -3,6 +3,6 @@ qb.gem:
3
3
  constant: QB
4
4
  license: MIT
5
5
  qb.project:
6
- dev_bin: false
6
+ dev-bin: false
7
7
  qb.install_gem:
8
8
  rubies: global
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ # gem 'state_mate', path: './dev/gems/state_mate'
4
+
3
5
  # Specify your gem's dependencies in qb.gemspec
4
6
  gemspec
data/README.md CHANGED
@@ -8,6 +8,11 @@ if this file exists in a role `qb` sees it will make that role available.
8
8
 
9
9
  the contents of this file allow you to configure how `qb` uses the role.
10
10
 
11
+ ### null values ###
12
+
13
+ values set to `null` are treated like they're not there at all. to tell QB
14
+ *not* to do something assign `false`.
15
+
11
16
  ### var_prefix ###
12
17
 
13
18
  declare prefix to be added to variable names from the command line for
@@ -30,7 +35,7 @@ to the `qb.project` role.
30
35
 
31
36
  however, this setting allows you to specify an alternative prefix.
32
37
 
33
- if this is set to `null` or any varient of `false` the default will be used.
38
+ if this is set to `null` the default will be used.
34
39
 
35
40
  ### default_dir ###
36
41
 
data/exe/qb CHANGED
@@ -58,10 +58,10 @@ def with_clean_env &block
58
58
  end
59
59
 
60
60
  def metadata
61
- if QB.gemspec.metadata
61
+ if QB.gemspec.metadata && !QB.gemspec.metadata.empty?
62
62
  "metadata:\n" + QB.gemspec.metadata.map {|key, value|
63
63
  " #{ key }: #{ value }"
64
- }.join("\n")
64
+ }.join("\n") + "\n"
65
65
  end
66
66
  end
67
67
 
@@ -69,7 +69,6 @@ def help
69
69
  puts <<-END
70
70
  version: #{ QB::VERSION }
71
71
  #{ metadata }
72
-
73
72
  syntax:
74
73
 
75
74
  qb ROLE [OPTIONS] DIRECTORY
@@ -138,7 +137,9 @@ def main args
138
137
 
139
138
  # create the dir if it doesn't exist (so don't have to cover this in
140
139
  # every role)
141
- FileUtils.mkdir_p dir unless File.exists? dir
140
+ if role.mkdir
141
+ FileUtils.mkdir_p dir unless File.exists? dir
142
+ end
142
143
 
143
144
  saved_options_path = Pathname.new(dir) + '.qb-options.yml'
144
145
 
@@ -203,7 +204,11 @@ def main args
203
204
  'that' => "'ansible 2.1.2' in lookup('pipe', 'ansible --version')",
204
205
  },
205
206
  },
206
- {'qb_facts' => nil},
207
+ {
208
+ 'qb_facts' => {
209
+ 'qb_dir' => dir,
210
+ }
211
+ },
207
212
  ],
208
213
  'roles' => [
209
214
  'nrser.blockinfile',
data/lib/qb/options.rb CHANGED
@@ -64,11 +64,11 @@ module QB
64
64
  @cli_name = if @include_path.empty?
65
65
  Options.cli_ize_name @meta_name
66
66
  else
67
- "#{ @include_path.join('-') }-#{ Options.cli_ize_name @meta_name }"
67
+ Options.cli_ize_name "#{ @include_path.join('-') }-#{ @meta_name }"
68
68
  end
69
69
 
70
70
  @var_name = if role.var_prefix
71
- "#{ role.var_prefix }_#{ Options.var_ize_name @meta_name }"
71
+ Options.var_ize_name "#{ role.var_prefix }_#{ @meta_name }"
72
72
  else
73
73
  Options.var_ize_name @meta_name
74
74
  end
@@ -102,11 +102,15 @@ module QB
102
102
  private
103
103
 
104
104
  # get the value at the first found of the keys or the default.
105
+ #
106
+ # `nil` (`null` in yaml files) are treated like they're not there at
107
+ # all. you need to use `false` if you want to tell QB not to do something.
108
+ #
105
109
  def meta_or keys, default
106
110
  keys = [keys] if keys.is_a? String
107
111
  keys.each do |key|
108
- if @meta.key? key
109
- return @meta[key]
112
+ if meta.key?(key) && !meta[key].nil?
113
+ return meta[key]
110
114
  end
111
115
  end
112
116
  default
@@ -196,10 +200,15 @@ module QB
196
200
 
197
201
  # don't use short names when included (for now)
198
202
  if include_path.empty? && option.meta['short']
199
- on_args << "-#{ option.meta['short'] } #{ option.cli_name.upcase }"
203
+ on_args << "-#{ option.meta['short'] } #{ option.meta_name.upcase }"
200
204
  end
201
205
 
202
- on_args << "--#{ option.cli_name }=#{ option.cli_name.upcase }"
206
+ if option.meta['accept_false']
207
+ on_args << "--[no-]#{ option.cli_name }=#{ option.meta_name.upcase }"
208
+ else
209
+ on_args << "--#{ option.cli_name }=#{ option.meta_name.upcase }"
210
+ end
211
+
203
212
 
204
213
  on_args << ruby_type
205
214
  end
data/lib/qb/role.rb CHANGED
@@ -180,18 +180,22 @@ module QB
180
180
  # passing them to the role. defaults to `#namespaceless` unless specified
181
181
  # in meta.
182
182
  def var_prefix
183
- meta['var_prefix'] || namespaceless
183
+ # ugh, i was generating meta/qb.yml files that set 'var_prefix' to
184
+ # `null`, but it would be nice to
185
+ #
186
+ meta_or 'var_prefix', namespaceless
184
187
  end
185
188
 
186
189
  # get the options from the metadata, defaulting to [] if none defined
187
190
  def options
188
- meta['options'] || meta['opts'] || meta['vars'] || []
191
+ meta_or ['options', 'opts', 'vars'], []
189
192
  end
190
193
 
191
194
  # old name
192
195
  alias_method :vars, :options
193
196
 
194
- # loads the defaults from defaults/main.yml, caching by default
197
+ # loads the defaults from vars/main.yml and defaults/main.yml,
198
+ # caching by default. vars override defaults values.
195
199
  def load_defaults cache = true
196
200
  defaults_path = @path + 'defaults' + 'main.yml'
197
201
  defaults = if defaults_path.file?
@@ -200,6 +204,15 @@ module QB
200
204
  {}
201
205
  end
202
206
 
207
+ vars_path = @path + 'vars' + 'main.yml'
208
+ vars = if vars_path.file?
209
+ YAML.load(vars_path.read) || {}
210
+ else
211
+ {}
212
+ end
213
+
214
+ defaults = defaults.merge! vars
215
+
203
216
  if cache
204
217
  @defaults = defaults
205
218
  end
@@ -213,11 +226,30 @@ module QB
213
226
  end
214
227
 
215
228
  def save_options
216
- if meta.key? 'save_options'
217
- !!meta['save_options']
218
- else
219
- true
229
+ !!meta_or('save_options', true)
230
+ end
231
+
232
+ # if the exe should auto-make the directory. this is nice for most roles
233
+ # but some need it to be missing
234
+ def mkdir
235
+ !!meta_or('mkdir', true)
236
+ end
237
+
238
+ private
239
+
240
+ # get the value at the first found of the keys or the default.
241
+ #
242
+ # `nil` (`null` in yaml files) are treated like they're not there at
243
+ # all. you need to use `false` if you want to tell QB not to do something.
244
+ #
245
+ def meta_or keys, default
246
+ keys = [keys] if keys.is_a? String
247
+ keys.each do |key|
248
+ if meta.key?(key) && !meta[key].nil?
249
+ return meta[key]
250
+ end
220
251
  end
252
+ default
221
253
  end
222
254
  end
223
255
  end
data/lib/qb/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module QB
2
2
  GEM_NAME = 'qb'
3
3
 
4
- VERSION = "0.1.17"
4
+ VERSION = "0.1.18"
5
5
 
6
6
  def self.gemspec
7
7
  Gem.loaded_specs[GEM_NAME]
data/library/qb_facts.py CHANGED
@@ -1,28 +1,68 @@
1
1
  #!/usr/bin/python
2
2
 
3
3
  import subprocess
4
+ import os
5
+ import glob
6
+ import json
7
+
8
+ def gemspec_path(dir):
9
+ paths = glob.glob(os.path.join(dir, '*.gemspec'))
10
+
11
+ if len(paths) == 0:
12
+ return None
13
+ elif len(paths) == 1:
14
+ return paths[0]
15
+ else:
16
+ # this shouldn't really happen, but i don't want to stop the show...
17
+ return paths[0]
18
+
19
+ def is_gem(dir):
20
+ return bool(gemspec_path(dir))
4
21
 
5
22
  def main():
6
23
  module = AnsibleModule(
7
24
  argument_spec = dict(
25
+ qb_dir = dict(require = True, type = 'path'),
8
26
  ),
9
27
  supports_check_mode = False,
10
28
  )
11
-
29
+
30
+ qb_dir = module.params['qb_dir']
12
31
 
13
32
  facts = {}
14
33
 
15
- d = {
16
- 'git_user_name': ['git', 'config', 'user.name'],
17
- 'git_user_email': ['git', 'config', 'user.email'],
34
+ cmds = {
35
+ 'qb_git_user_name': ['git', 'config', 'user.name'],
36
+ 'qb_git_user_email': ['git', 'config', 'user.email'],
18
37
  }
19
38
 
20
- for key, cmd in d.iteritems():
39
+ for key, cmd in cmds.iteritems():
21
40
  try:
22
- facts[key] = subprocess.check_output(cmd).rstrip()
41
+ value = subprocess.check_output(cmd).rstrip()
42
+ facts[key] = value
23
43
  except subprocess.CalledProcessError as e:
24
- pass
44
+ pass
45
+
46
+ if is_gem(qb_dir):
47
+ ruby = '''
48
+ require 'json'
49
+ spec = Gem::Specification::load("%s")
50
+ puts JSON.dump({
51
+ 'name' => spec.name,
52
+ 'version' => spec.version,
53
+ })
54
+ ''' % (gemspec_path(qb_dir))
55
+
56
+ spec_json = subprocess.check_output(['ruby', '-e', ruby])
57
+ gem_info = json.loads(spec_json)
58
+ gem_info['gemspec_path'] = gemspec_path(qb_dir)
25
59
 
60
+ facts['qb_gem_info'] = gem_info
61
+
62
+ # depreciated namespaceless names
63
+ facts['git_user_name'] = facts['qb_git_user_name']
64
+ facts['git_user_email'] = facts['qb_git_user_email']
65
+
26
66
  changed = False
27
67
 
28
68
  module.exit_json(
data/qb.gemspec CHANGED
@@ -21,10 +21,14 @@ Gem::Specification.new do |spec|
21
21
  `git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
22
22
  Dir.chdir(submodule_path) do
23
23
  submodule_relative_path = submodule_path.sub gem_dir, ""
24
- # issue git ls-files in submodule's directory and
25
- # prepend the submodule path to create absolute file paths
26
- `git ls-files`.split($\).each do |filename|
27
- spec.files << "#{submodule_relative_path}/#{filename}"
24
+
25
+ # don't bundle dev submods
26
+ unless submodule_relative_path.start_with? 'dev/'
27
+ # issue git ls-files in submodule's directory and
28
+ # prepend the submodule path to create absolute file paths
29
+ `git ls-files`.split($\).each do |filename|
30
+ spec.files << "#{submodule_relative_path}/#{filename}"
31
+ end
28
32
  end
29
33
  end
30
34
  end
@@ -37,8 +41,10 @@ Gem::Specification.new do |spec|
37
41
  spec.add_development_dependency "rake", "~> 10.0"
38
42
  spec.add_development_dependency "rspec"
39
43
 
40
- spec.add_dependency "cmds", ">= 0.0.9"
41
- spec.add_dependency "nrser-extras", ">= 0.0.3"
44
+ spec.add_dependency "cmds",'~> 0.0', ">= 0.0.9"
45
+ spec.add_dependency "nrser-extras", '~> 0.0', ">= 0.0.3"
46
+ spec.add_dependency "state_mate", '~> 0.0', ">= 0.0.8"
47
+
42
48
 
43
49
  if QB::VERSION.end_with? '.dev'
44
50
  commit = `git rev-parse HEAD`.strip
@@ -47,11 +47,9 @@ def main
47
47
  })
48
48
 
49
49
  rescue Exception => e
50
- raise e
51
-
52
50
  print JSON.dump({
53
51
  'failed' => true,
54
- 'msg' => e,
52
+ 'msg' => e.message,
55
53
  # 'input' => input,
56
54
  # 'args' => args,
57
55
  # 'ARGV' => ARGV,
@@ -0,0 +1,38 @@
1
+ # ruby / gem / bundler stuff
2
+ # ==========================
3
+
4
+ *.gem
5
+ *.rbc
6
+ .bundle
7
+ .config
8
+ .yardoc
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
20
+ *.bundle
21
+ *.so
22
+ *.o
23
+ *.a
24
+ mkmf.log
25
+
26
+ # osx
27
+ # ===
28
+
29
+ .DS_Store
30
+
31
+ # test stuff
32
+ # ==========
33
+
34
+ # stuff copied in from the repo
35
+ test/ansible/roles/nrser.state_mate
36
+
37
+ # temp playbook generated by rspec tests
38
+ test/ansible/temp-playbook.yml
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test, :development do
4
+ gem "rspec"
5
+ gem "cmds"
6
+ gem "nrser-extras"
7
+ gem "state_mate", path: "#{ ENV.fetch('GITHUB_ROOT') }/nrser/state_mate"
8
+ end
@@ -0,0 +1,46 @@
1
+ PATH
2
+ remote: /Users/nrser/dev/gh/nrser/state_mate
3
+ specs:
4
+ state_mate (0.0.7.dev)
5
+ CFPropertyList (~> 2.3)
6
+ cmds (~> 0.0, >= 0.0.9)
7
+ nrser (~> 0.0, >= 0.0.13)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ CFPropertyList (2.3.2)
13
+ cmds (0.0.9)
14
+ erubis (~> 2.7)
15
+ nrser (>= 0.0.13)
16
+ diff-lcs (1.2.5)
17
+ erubis (2.7.0)
18
+ nrser (0.0.13)
19
+ nrser-extras (0.0.3)
20
+ cmds (>= 0.0.7)
21
+ nrser (>= 0.0.13)
22
+ rspec (3.3.0)
23
+ rspec-core (~> 3.3.0)
24
+ rspec-expectations (~> 3.3.0)
25
+ rspec-mocks (~> 3.3.0)
26
+ rspec-core (3.3.2)
27
+ rspec-support (~> 3.3.0)
28
+ rspec-expectations (3.3.1)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.3.0)
31
+ rspec-mocks (3.3.2)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.3.0)
34
+ rspec-support (3.3.0)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ cmds
41
+ nrser-extras
42
+ rspec
43
+ state_mate!
44
+
45
+ BUNDLED WITH
46
+ 1.10.6
@@ -0,0 +1,45 @@
1
+ nrser.state_mate
2
+ ================
3
+
4
+ installs the `state_mate` gem and provides the `state` Ansible module for
5
+ maintaining system state on OSX.
6
+
7
+ Requirements
8
+ ------------
9
+
10
+ a Ruby version where the user you run Ansible as can install gems.
11
+
12
+ Role Variables
13
+ --------------
14
+
15
+ - `state_mate_version`: version of the `state_mate` gem to install.
16
+
17
+ Dependencies
18
+ ------------
19
+
20
+ none.
21
+
22
+ Example Playbook
23
+ ----------------
24
+
25
+ Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
26
+
27
+ - hosts: servers
28
+ roles:
29
+ - role: nrser.state_mate
30
+ tasks:
31
+ - name: always show scrollbars
32
+ state:
33
+ defaults:
34
+ key: NSGlobalDomain:AppleShowScrollBars
35
+ set: Always
36
+
37
+ License
38
+ -------
39
+
40
+ BSD
41
+
42
+ Author Information
43
+ ------------------
44
+
45
+ <https://github.com/nrser>
@@ -0,0 +1 @@
1
+ 0.1.1
@@ -0,0 +1,3 @@
1
+ ---
2
+ # defaults file for nrser.state_mate
3
+ state_mate_version: 0.0.7
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env ruby
2
+ # WANT_JSON
3
+
4
+ # needed for dev
5
+ begin
6
+ require 'bundler/setup'
7
+ rescue LoadError => e
8
+ end
9
+
10
+ require 'json'
11
+ require 'shellwords'
12
+ require 'pp'
13
+ require 'yaml'
14
+
15
+ require 'nrser'
16
+ require 'state_mate'
17
+ require 'state_mate/adapters/yaml'
18
+
19
+ using NRSER
20
+
21
+ def main
22
+ input = nil
23
+ args = nil
24
+ changed = false
25
+
26
+ # preorder for yaml keys
27
+ StateMate::Adapters::YAML.preorder = ['name', 'tags', 'command']
28
+
29
+ begin
30
+ input = File.read ARGV[0]
31
+ args = JSON.load input
32
+
33
+ raise "arg fail" if args['fail']
34
+
35
+ # filter out keys that start with '_ansible', which are ansible-added
36
+ # values.
37
+ #
38
+ # example:
39
+ #
40
+ # {"_ansible_version"=>"2.1.0.0",
41
+ # "_ansible_selinux_special_fs"=>["fuse", "nfs", "vboxsf", "ramfs"],
42
+ # "_ansible_no_log"=>false,
43
+ # "_ansible_verbosity"=>0,
44
+ # "_ansible_syslog_facility"=>"LOG_USER",
45
+ # "_ansible_diff"=>false,
46
+ # "_ansible_debug"=>false,
47
+ # "_ansible_check_mode"=>false}
48
+ #
49
+ spec = args.reject {|k, v| k.start_with? '_ansible'}
50
+
51
+ if spec['debug']
52
+ StateMate.debug = spec['debug']
53
+ spec.delete 'debug'
54
+
55
+ StateMate.debug "START RUN #{ '*' * 42 }"
56
+ StateMate.debug YAML.dump(spec)
57
+ end
58
+
59
+ changes = StateMate.execute spec
60
+
61
+ StateMate.debug changes: changes
62
+
63
+ print JSON.dump({
64
+ 'changed' => !changes.empty?,
65
+ 'changes' => changes,
66
+ })
67
+ rescue Exception => e
68
+ StateMate.debug error: e
69
+
70
+ print JSON.dump({
71
+ 'failed' => true,
72
+ # 'msg' => e.format, # broken?
73
+ 'msg' => e.message,
74
+ # 'input' => input,
75
+ 'args' => args,
76
+ # 'ARGV' => ARGV,
77
+ # 'ruby' => RUBY_VERSION,
78
+ })
79
+ end
80
+ end
81
+
82
+ main if __FILE__ == $0