Sha256: 1e98bb6fe2308355f04cb232977183b2ff9e173a1ddaadcc6b0362469704a599
Contents?: true
Size: 1.73 KB
Versions: 6
Compression:
Stored size: 1.73 KB
Contents
#!/usr/bin/env ruby # WANT_JSON # Reinstate Bundler ENV vars if they have been moved load ENV['QB_REBUNDLE_PATH'] if ENV['QB_REBUNDLE_PATH'] require 'pp' require 'json' require 'shellwords' require 'yaml' require 'nrser' require 'state_mate' require 'state_mate/adapters/yaml' using NRSER def main input = nil args = nil changed = false # preorder for yaml keys StateMate::Adapters::YAML.preorder = ['name', 'tags', 'command'] begin input = File.read ARGV[0] args = JSON.load input raise "arg fail" if args['fail'] # filter out keys that start with '_ansible', which are ansible-added # values. # # example: # # {"_ansible_version"=>"2.1.0.0", # "_ansible_selinux_special_fs"=>["fuse", "nfs", "vboxsf", "ramfs"], # "_ansible_no_log"=>false, # "_ansible_verbosity"=>0, # "_ansible_syslog_facility"=>"LOG_USER", # "_ansible_diff"=>false, # "_ansible_debug"=>false, # "_ansible_check_mode"=>false} # spec = args.reject {|k, v| k.start_with? '_ansible'} if spec['debug'] StateMate.debug = spec['debug'] spec.delete 'debug' StateMate.debug "START RUN #{ '*' * 42 }" StateMate.debug YAML.dump(spec) end changes = StateMate.execute spec StateMate.debug changes: changes print JSON.dump({ 'changed' => !changes.empty?, 'changes' => changes, }) rescue Exception => e StateMate.debug error: e print JSON.dump({ 'failed' => true, # 'msg' => e.format, # broken? 'msg' => e.message, # 'input' => input, 'args' => args, # 'ARGV' => ARGV, # 'ruby' => RUBY_VERSION, }) end end main if __FILE__ == $0
Version data entries
6 entries across 6 versions & 1 rubygems