Module: Beaker::DSL::PEClientTools::ExecutableHelper

Included in:
Beaker::DSL::PE
Defined in:
lib/beaker-pe/pe-client-tools/executable_helper.rb

Defined Under Namespace

Classes: Private

Instance Method Summary collapse

Instance Method Details

#login_with_puppet_access_on(host, credentialed_dispatcher, opts = {}) ⇒ Object

Logs a user in on a SUT with puppet-access/RBAC API (windows)

Parameters:

  • host (Beaker::Host)

    The SUT to perform the login on

  • credentialed_dispatcher (Scooter::HttpDispatchers::ConsoleDispatcher)

    A Scooter dispatcher that has credentials for the user

  • attribute_hash (Hash)

    a customizable set of options


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/beaker-pe/pe-client-tools/executable_helper.rb', line 80

def (host, credentialed_dispatcher, opts={})

  lifetime = opts[:lifetime] || nil
  unless host.platform =~ /win/

    user = credentialed_dispatcher.credentials.
    password = credentialed_dispatcher.credentials.password
    args = ['login']
    args.push "--lifetime #{lifetime}" if lifetime
    puppet_access_on(host, *args, {:stdin => "#{user}\n#{password}\n"})
  else

    # this is a hack
    # puppet-access needs to support alternative to interactive login
    # create .puppetlabs dir
    cmd = Beaker::Command.new('echo', ['%userprofile%'], :cmdexe => true)
    user_home_dir = host.exec(cmd).stdout.chomp
    win_token_path =  "#{user_home_dir}\\.puppetlabs\\"
    host.exec(Beaker::Command.new('MD', [win_token_path.gsub('\\', '\\\\\\')], :cmdexe => true), :accept_all_exit_codes => true)

    token = credentialed_dispatcher.acquire_token_with_credentials(lifetime)
    create_remote_file(host, "#{win_token_path}\\token", token)
  end
end

#puppet_access_on(*args, &block) ⇒ Object

puppet-access helper win/lin/osx

Parameters:

  • host (BEAKER::Host)

    The SUT that should run the puppet-access command

  • args (String)

    The arguments to puppet-access

  • opts (Hash)

    options hash to the Beaker Command

  • &block (Block)

    optional block


15
16
17
# File 'lib/beaker-pe/pe-client-tools/executable_helper.rb', line 15

def puppet_access_on(*args, &block)
  Private.new.tool(:access, *args, &block)
end

#puppet_app_on(*args, &block) ⇒ Object

puppet-app helper win/lin/osx

Parameters:

  • host (BEAKER::Host)

    The SUT that should run the puppet-app command

  • args (String)

    The arguments to puppet-app

  • opts (Hash)

    options hash to the Beaker Command

  • &block (Block)

    optional block


42
43
44
# File 'lib/beaker-pe/pe-client-tools/executable_helper.rb', line 42

def puppet_app_on(*args, &block)
  Private.new.tool(:app, *args, &block)
end

#puppet_code_on(*args, &block) ⇒ Object

puppet-code helper win/lin/osx

Parameters:

  • host (BEAKER::Host)

    The SUT that should run the puppet-code command

  • args (String)

    The arguments to puppet-code

  • opts (Hash)

    options hash to the Beaker Command

  • &block (Block)

    optional block


24
25
26
# File 'lib/beaker-pe/pe-client-tools/executable_helper.rb', line 24

def puppet_code_on(*args, &block)
  Private.new.tool(:code, *args, &block)
end

#puppet_db_on(*args, &block) ⇒ Object

puppet-db helper win/lin/osx

Parameters:

  • host (BEAKER::Host)

    The SUT that should run the puppet-db command

  • args (String)

    The arguments to puppet-db

  • opts (Hash)

    options hash to the Beaker Command

  • &block (Block)

    optional block


51
52
53
# File 'lib/beaker-pe/pe-client-tools/executable_helper.rb', line 51

def puppet_db_on(*args, &block)
  Private.new.tool(:db, *args, &block)
end

#puppet_job_on(*args, &block) ⇒ Object

puppet-job helper win/lin/osx

Parameters:

  • host (BEAKER::Host)

    The SUT that should run the puppet-job command

  • args (String)

    The arguments to puppet-job

  • opts (Hash)

    options hash to the Beaker Command

  • &block (Block)

    optional block


33
34
35
# File 'lib/beaker-pe/pe-client-tools/executable_helper.rb', line 33

def puppet_job_on(*args, &block)
  Private.new.tool(:job, *args, &block)
end

#puppet_query_on(*args, &block) ⇒ Object

puppet-query helper win/lin/osx

Parameters:

  • host (BEAKER::Host)

    The SUT that should run the puppet-query command

  • args (String)

    The arguments to puppet-query

  • opts (Hash)

    options hash to the Beaker Command

  • &block (Block)

    optional block


60
61
62
# File 'lib/beaker-pe/pe-client-tools/executable_helper.rb', line 60

def puppet_query_on(*args, &block)
  Private.new.tool(:query, *args, &block)
end

#puppet_task_on(*args, &block) ⇒ Object

puppet-task helper win/lin/osx

Parameters:

  • host (BEAKER::Host)

    The SUT that should run the puppet-task command

  • args (String)

    The arguments to puppet-task

  • opts (Hash)

    options hash to the Beaker Command

  • &block (Block)

    optional block


69
70
71
# File 'lib/beaker-pe/pe-client-tools/executable_helper.rb', line 69

def puppet_task_on(*args, &block)
  Private.new.tool(:task, *args, &block)
end