Class: Orats::Commands::Diff::Exec

Inherits:
Common
  • Object
show all
Includes:
Compare, Parse
Defined in:
lib/orats/commands/diff/exec.rb

Constant Summary

Constants inherited from Common

Common::RELATIVE_PATHS

Instance Attribute Summary

Attributes inherited from Common

#local_paths, #remote_gem_version, #remote_paths

Instance Method Summary collapse

Methods included from Compare

#local_to_user, #remote_to_local, #remote_to_local_galaxyfiles, #remote_to_local_gem_versions

Methods included from Parse

#galaxyfile, #gem_version, #hosts, #inventory, #playbook

Methods inherited from Common

#base_path, copy_from_local_gem, #exit_if_path_exists, #exit_if_process, #file_to_string, #repo_path, #url_to_string

Methods included from UI

#git_commit, #log_error, #log_local_info, #log_remote_info, #log_results, #log_status_bottom, #log_status_top, #log_task, #run_from

Constructor Details

#initialize(target_path = '', options = {}) ⇒ Exec



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/orats/commands/diff/exec.rb', line 13

def initialize(target_path = '', options = {})
  super

  @remote_galaxyfile = galaxyfile url_to_string(@remote_paths[:galaxyfile])
  @remote_hosts      = hosts url_to_string(@remote_paths[:hosts])
  @remote_inventory  = inventory url_to_string(@remote_paths[:inventory])
  @remote_playbook   = playbook url_to_string(@remote_paths[:playbook])

  @local_galaxyfile = galaxyfile file_to_string(@local_paths[:galaxyfile])
  @local_hosts      = hosts file_to_string(@local_paths[:hosts])
  @local_inventory  = inventory file_to_string(@local_paths[:inventory])
  @local_playbook   = playbook file_to_string(@local_paths[:playbook])
end

Instance Method Details

#initObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/orats/commands/diff/exec.rb', line 27

def init
  remote_to_local_gem_versions
  remote_to_local_galaxyfiles
  remote_to_local 'hosts', 'groups', @remote_hosts, @local_hosts
  remote_to_local 'inventory', 'variables', @remote_inventory, @local_inventory
  remote_to_local 'playbook', 'roles', @remote_playbook, @local_playbook

  local_to_user_hosts @options[:hosts] unless @options[:hosts].empty?

  unless @options[:inventory].empty?
    inventory_path = @options[:inventory]

    if File.directory?(inventory_path)
      hosts_path = File.join(inventory_path, 'hosts')

      inventory_path = File.join(inventory_path,
                                 'group_vars/all.yml')

      local_to_user_hosts hosts_path
    end

    local_to_user_inventory inventory_path
  end

  unless @options[:playbook].empty?
    playbook_path = @options[:playbook]

    if File.directory?(playbook_path)
      playbook_path = File.join(playbook_path, 'site.yml')

      local_to_user_playbook playbook_path
    end

    local_to_user_playbook playbook_path
  end
end