Class: Bow::InventoryExample
- Inherits:
-
Object
- Object
- Bow::InventoryExample
- Defined in:
- lib/bow/inventory_example.rb
Constant Summary collapse
- TARGETING_EXAMPLE =
{ 'example_group1' => [ '192.168.50.27', '192.168.50.37' ], 'example_group2' => [ '192.168.50.47', '192.168.50.57' ] }.freeze
- RAKEFILE_EXAMPLE =
" require 'bow/rake'\n\n Rake.application.options.trace_rules = true\n\n PROVISION_DIR = '/tmp/rake_provision'\n\n namespace :example_group1 do\n task provision: :print_hello do\n end\n\n flow run: :once\n task :print_hello do\n sh 'echo \"Hello from example group #1 server!\"'\n end\n end\n\n namespace :example_group2 do\n task provision: :print_hello do\n end\n\n flow enabled: false, revert_task: :print_goodbye\n task :print_hello do\n sh 'echo \"Hello from example group #2 server!\"'\n end\n\n task :print_goodbye do\n sh 'echo \"Goodbye! The task at example group #2 is disabled!\"'\n end\n end\n".gsub(/^ {6}/, '').freeze
Instance Method Summary collapse
Instance Method Details
#init ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/bow/inventory_example.rb', line 49 def init raise 'Can not init. Directory not empty!' unless Dir.empty?(Dir.pwd) { 'Rakefile' => RAKEFILE_EXAMPLE, 'targets.json' => JSON.pretty_generate(TARGETING_EXAMPLE) }.each do |targ, code| f = File.open(targ, 'w') f.write(code) f.close end end |