Class: VagrantPlugins::GuestAnsible::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::GuestAnsible::Config
- Defined in:
- lib/vagrant-guest_ansible/config.rb
Instance Attribute Summary collapse
-
#ask_sudo_pass ⇒ Object
Returns the value of attribute ask_sudo_pass.
-
#extra_vars ⇒ Object
Returns the value of attribute extra_vars.
-
#groups ⇒ Object
Returns the value of attribute groups.
-
#host_key_checking ⇒ Object
Returns the value of attribute host_key_checking.
-
#inventory_path ⇒ Object
Returns the value of attribute inventory_path.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#playbook ⇒ Object
Returns the value of attribute playbook.
-
#raw_arguments ⇒ Object
Joker attribute, used to pass unsupported arguments to ansible anyway.
-
#skip_tags ⇒ Object
Returns the value of attribute skip_tags.
-
#start_at_task ⇒ Object
Returns the value of attribute start_at_task.
-
#sudo ⇒ Object
Returns the value of attribute sudo.
-
#sudo_user ⇒ Object
Returns the value of attribute sudo_user.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
- #binary ⇒ Object
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #path ⇒ Object
- #remote? ⇒ Boolean
- #upload_path ⇒ Object
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/vagrant-guest_ansible/config.rb', line 23 def initialize @playbook = UNSET_VALUE @extra_vars = UNSET_VALUE @inventory_path = UNSET_VALUE @ask_sudo_pass = UNSET_VALUE @limit = 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 @groups = UNSET_VALUE @host_key_checking = "true" end |
Instance Attribute Details
#ask_sudo_pass ⇒ Object
Returns the value of attribute ask_sudo_pass.
9 10 11 |
# File 'lib/vagrant-guest_ansible/config.rb', line 9 def ask_sudo_pass @ask_sudo_pass end |
#extra_vars ⇒ Object
Returns the value of attribute extra_vars.
7 8 9 |
# File 'lib/vagrant-guest_ansible/config.rb', line 7 def extra_vars @extra_vars end |
#groups ⇒ Object
Returns the value of attribute groups.
17 18 19 |
# File 'lib/vagrant-guest_ansible/config.rb', line 17 def groups @groups end |
#host_key_checking ⇒ Object
Returns the value of attribute host_key_checking.
18 19 20 |
# File 'lib/vagrant-guest_ansible/config.rb', line 18 def host_key_checking @host_key_checking end |
#inventory_path ⇒ Object
Returns the value of attribute inventory_path.
8 9 10 |
# File 'lib/vagrant-guest_ansible/config.rb', line 8 def inventory_path @inventory_path end |
#limit ⇒ Object
Returns the value of attribute limit.
10 11 12 |
# File 'lib/vagrant-guest_ansible/config.rb', line 10 def limit @limit end |
#playbook ⇒ Object
Returns the value of attribute playbook.
6 7 8 |
# File 'lib/vagrant-guest_ansible/config.rb', line 6 def playbook @playbook end |
#raw_arguments ⇒ Object
Joker attribute, used to pass unsupported arguments to ansible anyway
21 22 23 |
# File 'lib/vagrant-guest_ansible/config.rb', line 21 def raw_arguments @raw_arguments end |
#skip_tags ⇒ Object
Returns the value of attribute skip_tags.
15 16 17 |
# File 'lib/vagrant-guest_ansible/config.rb', line 15 def @skip_tags end |
#start_at_task ⇒ Object
Returns the value of attribute start_at_task.
16 17 18 |
# File 'lib/vagrant-guest_ansible/config.rb', line 16 def start_at_task @start_at_task end |
#sudo ⇒ Object
Returns the value of attribute sudo.
11 12 13 |
# File 'lib/vagrant-guest_ansible/config.rb', line 11 def sudo @sudo end |
#sudo_user ⇒ Object
Returns the value of attribute sudo_user.
12 13 14 |
# File 'lib/vagrant-guest_ansible/config.rb', line 12 def sudo_user @sudo_user end |
#tags ⇒ Object
Returns the value of attribute tags.
14 15 16 |
# File 'lib/vagrant-guest_ansible/config.rb', line 14 def @tags end |
#verbose ⇒ Object
Returns the value of attribute verbose.
13 14 15 |
# File 'lib/vagrant-guest_ansible/config.rb', line 13 def verbose @verbose end |
Instance Method Details
#binary ⇒ Object
52 53 54 |
# File 'lib/vagrant-guest_ansible/config.rb', line 52 def binary false end |
#finalize! ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/vagrant-guest_ansible/config.rb', line 56 def finalize! @playbook = nil if @playbook == 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 @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 @groups = {} if @groups == UNSET_VALUE @host_key_checking = nil if @host_key_checking == UNSET_VALUE end |
#path ⇒ Object
40 41 42 |
# File 'lib/vagrant-guest_ansible/config.rb', line 40 def path @path ||= File.("../guest_script.sh", __FILE__) end |
#remote? ⇒ Boolean
48 49 50 |
# File 'lib/vagrant-guest_ansible/config.rb', line 48 def remote? path =~ URI.regexp(["ftp", "http", "https"]) end |
#upload_path ⇒ Object
44 45 46 |
# File 'lib/vagrant-guest_ansible/config.rb', line 44 def upload_path "/tmp/vagrant-shell" end |
#validate(machine) ⇒ Object
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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/vagrant-guest_ansible/config.rb', line 73 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 = Pathname.new(playbook).(machine.env.root_path) if !.file? errors << I18n.t("vagrant.provisioners.ansible.playbook_path_invalid", :path => ) end end # Validate that extra_vars is either a hash, or a path to an # existing file if extra_vars extra_vars_is_valid = extra_vars.kind_of?(Hash) || extra_vars.kind_of?(String) if extra_vars.kind_of?(String) # Accept the usage of '@' prefix in Vagrantfile (e.g. '@vars.yml' # and 'vars.yml' are both supported) match_data = /^@?(.+)$/.match(extra_vars) extra_vars_path = match_data[1].to_s = Pathname.new(extra_vars_path).(machine.env.root_path) extra_vars_is_valid = .exist? if extra_vars_is_valid @extra_vars = '@' + extra_vars_path end end if !extra_vars_is_valid errors << I18n.t("vagrant.provisioners.ansible.extra_vars_invalid", :type => extra_vars.class.to_s, :value => extra_vars.to_s ) end end # Validate the existence of the inventory_path, if specified if inventory_path = Pathname.new(inventory_path).(machine.env.root_path) if !.exist? errors << I18n.t("vagrant.provisioners.ansible.inventory_path_invalid", :path => ) end end { "ansible provisioner" => errors } end |