Class: VagrantPlugins::AnsibleLocal::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-ansible-local/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vagrant-ansible-local/config.rb', line 22

def initialize
  super

  @playbook          = UNSET_VALUE
  @guest_folder      = UNSET_VALUE
  @extra_vars        = UNSET_VALUE
  @inventory_path    = UNSET_VALUE
  @ask_sudo_pass     = UNSET_VALUE
  @limit             = UNSET_VALUE
  @privileged        = UNSET_VALUE
  @sudo              = UNSET_VALUE
  @sudo_user         = UNSET_VALUE
  @verbose           = UNSET_VALUE
  @tags              = UNSET_VALUE
  @skip_tags         = UNSET_VALUE
  @start_at_task     = UNSET_VALUE
  @raw_arguments     = UNSET_VALUE
  @host_key_checking = "true"
end

Instance Attribute Details

#ask_sudo_passObject

Returns the value of attribute ask_sudo_pass.



8
9
10
# File 'lib/vagrant-ansible-local/config.rb', line 8

def ask_sudo_pass
  @ask_sudo_pass
end

#extra_varsObject

Returns the value of attribute extra_vars.



6
7
8
# File 'lib/vagrant-ansible-local/config.rb', line 6

def extra_vars
  @extra_vars
end

#guest_folderObject

Returns the value of attribute guest_folder.



5
6
7
# File 'lib/vagrant-ansible-local/config.rb', line 5

def guest_folder
  @guest_folder
end

#host_key_checkingObject

Returns the value of attribute host_key_checking.



17
18
19
# File 'lib/vagrant-ansible-local/config.rb', line 17

def host_key_checking
  @host_key_checking
end

#inventory_pathObject

Returns the value of attribute inventory_path.



7
8
9
# File 'lib/vagrant-ansible-local/config.rb', line 7

def inventory_path
  @inventory_path
end

#limitObject

Returns the value of attribute limit.



9
10
11
# File 'lib/vagrant-ansible-local/config.rb', line 9

def limit
  @limit
end

#playbookObject

Returns the value of attribute playbook.



4
5
6
# File 'lib/vagrant-ansible-local/config.rb', line 4

def playbook
  @playbook
end

#privilegedObject

Returns the value of attribute privileged.



10
11
12
# File 'lib/vagrant-ansible-local/config.rb', line 10

def privileged
  @privileged
end

#raw_argumentsObject

Joker attribute, used to pass unsupported arguments to ansible anyway



20
21
22
# File 'lib/vagrant-ansible-local/config.rb', line 20

def raw_arguments
  @raw_arguments
end

#skip_tagsObject

Returns the value of attribute skip_tags.



15
16
17
# File 'lib/vagrant-ansible-local/config.rb', line 15

def skip_tags
  @skip_tags
end

#start_at_taskObject

Returns the value of attribute start_at_task.



16
17
18
# File 'lib/vagrant-ansible-local/config.rb', line 16

def start_at_task
  @start_at_task
end

#sudoObject

Returns the value of attribute sudo.



11
12
13
# File 'lib/vagrant-ansible-local/config.rb', line 11

def sudo
  @sudo
end

#sudo_userObject

Returns the value of attribute sudo_user.



12
13
14
# File 'lib/vagrant-ansible-local/config.rb', line 12

def sudo_user
  @sudo_user
end

#tagsObject

Returns the value of attribute tags.



14
15
16
# File 'lib/vagrant-ansible-local/config.rb', line 14

def tags
  @tags
end

#verboseObject

Returns the value of attribute verbose.



13
14
15
# File 'lib/vagrant-ansible-local/config.rb', line 13

def verbose
  @verbose
end

Instance Method Details

#finalize!Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/vagrant-ansible-local/config.rb', line 42

def finalize!
  super

  @playbook          = nil if @playbook == UNSET_VALUE
  @guest_folder      = "/tmp/vagrant-ansible-local" if @guest_folder == UNSET_VALUE
  @extra_vars        = nil if @extra_vars == UNSET_VALUE
  @inventory_path    = nil if @inventory_path == UNSET_VALUE
  @ask_sudo_pass     = nil if @ask_sudo_pass == UNSET_VALUE
  @limit             = nil if @limit == UNSET_VALUE
  @privileged        = nil if @privileged == UNSET_VALUE
  @sudo              = nil if @sudo == UNSET_VALUE
  @sudo_user         = nil if @sudo_user == UNSET_VALUE
  @verbose           = nil if @verbose == UNSET_VALUE
  @tags              = nil if @tags == UNSET_VALUE
  @skip_tags         = nil if @skip_tags == UNSET_VALUE
  @start_at_task     = nil if @start_at_task == UNSET_VALUE
  @raw_arguments     = nil if @raw_arguments == UNSET_VALUE
  @host_key_checking = nil if @host_key_checking == UNSET_VALUE

  if @extra_vars && @extra_vars.is_a?(Hash)
    @extra_vars.each do |k, v|
      @extra_vars[k] = v.to_s
    end
  end
end

#validate(machine) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/vagrant-ansible-local/config.rb', line 68

def validate(machine)
  errors = _detected_errors

  # Validate that a playbook path was provided
  if !playbook
    errors << I18n.t("vagrant.provisioners.ansible.no_playbook")
  end

  # Validate the existence of said playbook on the host
  if playbook
    expanded_path = Pathname.new(playbook).expand_path(machine.env.root_path)
    if !expanded_path.file?
      errors << I18n.t("vagrant.provisioners.ansible.playbook_path_invalid",
                        :path => expanded_path)
    end
  end

  # Validate that extra_vars is a hash, if set
  if extra_vars
    if !extra_vars.kind_of?(Hash)
      errors << I18n.t("vagrant.provisioners.ansible.extra_vars_not_hash")
    end
  end

  # Validate the existence of the inventory_path, if specified
  if inventory_path
    expanded_path = Pathname.new(inventory_path).expand_path(machine.env.root_path)
    if !expanded_path.exist?
      errors << I18n.t("vagrant.provisioners.ansible.inventory_path_invalid",
                        :path => expanded_path)
    end
  end

  { "ansible-local provisioner" => errors }
end