Method: Beaker::DSL::InstallUtils#copy_module_to

Defined in:
lib/beaker/dsl/install_utils.rb

#copy_module_to(one_or_more_hosts, opts = {}) ⇒ Object Also known as: copy_root_module_to

Install local module for acceptance testing should be used as a presuite to ensure local module is copied to the hosts you want, particularly masters

Parameters:

  • one_or_more_hosts (Host, Array<Host>, String, Symbol)

    One or more hosts to act upon, or a role (String or Symbol) that identifies one or more hosts.

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :source (String) — default: './'

    The current directory where the module sits, otherwise will try

    and walk the tree to figure out
    
  • :module_name (String) — default: nil

    Name which the module should be installed under, please do not include author,

    if none is provided it will attempt to parse the metadata.json and then the Modulefile to determine
    the name of the module
    
  • :target_module_path (String) — default: host['distmoduledir']/modules

    Location where the module should be installed, will default

    to host['distmoduledir']/modules
    
  • :ignore_list (Array)
  • :protocol (String)

    Name of the underlying transfer method. Valid options are ‘scp’ or ‘rsync’.

Raises:

  • (ArgumentError)

    if not host is provided or module_name is not provided and can not be found in Modulefile



1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
# File 'lib/beaker/dsl/install_utils.rb', line 1422

def copy_module_to(one_or_more_hosts, opts = {})
  block_on one_or_more_hosts do |host|
    opts = {:source => './',
            :target_module_path => host['distmoduledir'],
            :ignore_list => PUPPET_MODULE_INSTALL_IGNORE}.merge(opts)
    ignore_list = build_ignore_list(opts)
    target_module_dir = on( host, "echo #{opts[:target_module_path]}" ).stdout.chomp
    source_path = File.expand_path( opts[:source] )
    source_dir = File.dirname(source_path)
    source_name = File.basename(source_path)
    if opts.has_key?(:module_name)
      module_name = opts[:module_name]
    else
      _, module_name = parse_for_modulename( source_path )
    end

    opts[:protocol] ||= 'scp'
    case opts[:protocol]
      when 'scp'
        #move to the host
        scp_to host, source_path, target_module_dir, {:ignore => ignore_list}
        #rename to the selected module name, if not correct
        cur_path = File.join(target_module_dir, source_name)
        new_path = File.join(target_module_dir, module_name)
        if cur_path != new_path
          # NOTE: this will need to be updated to handle powershell only windows SUTs
          on host, "mv #{cur_path} #{new_path}"
        end
      when 'rsync'
        rsync_to host, source, File.join(target_module_dir, module_name), {:ignore => ignore_list}
      else
        logger.debug "Unsupported transfer protocol, returning nil"
        nil
    end
  end
end