Sha256: c518bc6fd5fe29984c45ff28799ac3f0de04a1cd3347e3c54f42f8b0dbe3712c

Contents?: true

Size: 1002 Bytes

Versions: 87

Compression:

Stored size: 1002 Bytes

Contents

require 'fileutils'
require 'yaml'

require 'cmds'

require 'nrser/refinements'
require 'nrser/extras'

using NRSER

ROOT = NRSER.git_root __FILE__
ANSIBLE_DIR = ROOT + 'test' + 'ansible'
ROLES_DIR = ANSIBLE_DIR + 'roles'
ROLE_DIR = ROLES_DIR + 'nrser.state_mate'
TEMPLATE_PATH = ANSIBLE_DIR + 'template.yml'
PLAYBOOK_PATH = ANSIBLE_DIR + 'temp-playbook.yml'

DOMAIN = 'com.nrser.state_mate.ansible'

def playbook options = {}
  data = YAML.load TEMPLATE_PATH.read
  
  [:name, :vars, :roles, :tasks].each do |sym|
    data[0][sym.to_s] = options[sym] if options.key? sym
  end
  
  PLAYBOOK_PATH.open('w') do |f|
    f.write YAML.dump(data)
  end
  
  result = Dir.chdir ANSIBLE_DIR do
    Cmds 'ansible-playbook %{path}', path: PLAYBOOK_PATH
  end
  
  unless result.ok?
    raise binding.erb <<-END
      error executing playbook
      
      path: <%= PLAYBOOK_PATH %>
      
      out:
      
      <%= result.out.indent %>
      
      err:
      
      <%= result.err.indent %>
    END
  end
end

Version data entries

87 entries across 87 versions & 1 rubygems

Version Path
qb-0.3.16 roles/nrser.state_mate/spec/spec_helper.rb
qb-0.3.15 roles/nrser.state_mate/spec/spec_helper.rb
qb-0.3.14 roles/nrser.state_mate/spec/spec_helper.rb
qb-0.3.13 roles/nrser.state_mate/spec/spec_helper.rb
qb-0.3.12 roles/nrser.state_mate/spec/spec_helper.rb
qb-0.3.11 roles/nrser.state_mate/spec/spec_helper.rb
qb-0.3.10 roles/nrser.state_mate/spec/spec_helper.rb
qb-0.3.9 roles/nrser.state_mate/spec/spec_helper.rb
qb-0.3.8 roles/nrser.state_mate/spec/spec_helper.rb
qb-0.3.7 roles/nrser.state_mate/spec/spec_helper.rb
qb-0.3.6 roles/nrser.state_mate/spec/spec_helper.rb
qb-0.3.5 roles/nrser.state_mate/spec/spec_helper.rb
qb-0.3.4 roles/nrser.state_mate/spec/spec_helper.rb
qb-0.3.3 roles/nrser.state_mate/spec/spec_helper.rb
qb-0.3.2 roles/nrser.state_mate/spec/spec_helper.rb
qb-0.3.1 roles/nrser.state_mate/spec/spec_helper.rb
qb-0.1.88 roles/nrser.state_mate/spec/spec_helper.rb
qb-0.1.87 roles/nrser.state_mate/spec/spec_helper.rb
qb-0.1.86 roles/nrser.state_mate/spec/spec_helper.rb
qb-0.1.85 roles/nrser.state_mate/spec/spec_helper.rb