Class: VagrantPlugins::Ansible_Fixed::Config::Base
- Inherits:
-
Object
- Object
- VagrantPlugins::Ansible_Fixed::Config::Base
- Defined in:
- lib/config/base.rb
Constant Summary collapse
- GALAXY_COMMAND_DEFAULT =
"ansible-galaxy install --role-file=%{role_file} --roles-path=%{roles_path} --force".freeze
Instance Attribute Summary collapse
-
#extra_vars ⇒ Object
Returns the value of attribute extra_vars.
-
#galaxy_command ⇒ Object
Returns the value of attribute galaxy_command.
-
#galaxy_role_file ⇒ Object
Returns the value of attribute galaxy_role_file.
-
#galaxy_roles_path ⇒ Object
Returns the value of attribute galaxy_roles_path.
-
#groups ⇒ Object
Returns the value of attribute groups.
-
#host_vars ⇒ Object
Returns the value of attribute host_vars.
-
#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
Returns the value of attribute raw_arguments.
-
#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.
-
#vault_password_file ⇒ Object
Returns the value of attribute vault_password_file.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
- #finalize! ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
-
#validate(machine) ⇒ Object
Just like the normal configuration “validate” method except that it returns an array of errors that should be merged into some other error accumulator.
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/config/base.rb', line 26 def initialize @extra_vars = UNSET_VALUE @galaxy_role_file = UNSET_VALUE @galaxy_roles_path = UNSET_VALUE @galaxy_command = UNSET_VALUE @host_vars = UNSET_VALUE @groups = UNSET_VALUE @inventory_path = UNSET_VALUE @limit = UNSET_VALUE @playbook = UNSET_VALUE @raw_arguments = UNSET_VALUE @skip_tags = UNSET_VALUE @start_at_task = UNSET_VALUE @sudo = UNSET_VALUE @sudo_user = UNSET_VALUE @tags = UNSET_VALUE @vault_password_file = UNSET_VALUE @verbose = UNSET_VALUE end |
Instance Attribute Details
#extra_vars ⇒ Object
Returns the value of attribute extra_vars.
8 9 10 |
# File 'lib/config/base.rb', line 8 def extra_vars @extra_vars end |
#galaxy_command ⇒ Object
Returns the value of attribute galaxy_command.
11 12 13 |
# File 'lib/config/base.rb', line 11 def galaxy_command @galaxy_command end |
#galaxy_role_file ⇒ Object
Returns the value of attribute galaxy_role_file.
9 10 11 |
# File 'lib/config/base.rb', line 9 def galaxy_role_file @galaxy_role_file end |
#galaxy_roles_path ⇒ Object
Returns the value of attribute galaxy_roles_path.
10 11 12 |
# File 'lib/config/base.rb', line 10 def galaxy_roles_path @galaxy_roles_path end |
#groups ⇒ Object
Returns the value of attribute groups.
13 14 15 |
# File 'lib/config/base.rb', line 13 def groups @groups end |
#host_vars ⇒ Object
Returns the value of attribute host_vars.
12 13 14 |
# File 'lib/config/base.rb', line 12 def host_vars @host_vars end |
#inventory_path ⇒ Object
Returns the value of attribute inventory_path.
14 15 16 |
# File 'lib/config/base.rb', line 14 def inventory_path @inventory_path end |
#limit ⇒ Object
Returns the value of attribute limit.
15 16 17 |
# File 'lib/config/base.rb', line 15 def limit @limit end |
#playbook ⇒ Object
Returns the value of attribute playbook.
16 17 18 |
# File 'lib/config/base.rb', line 16 def playbook @playbook end |
#raw_arguments ⇒ Object
Returns the value of attribute raw_arguments.
17 18 19 |
# File 'lib/config/base.rb', line 17 def raw_arguments @raw_arguments end |
#skip_tags ⇒ Object
Returns the value of attribute skip_tags.
18 19 20 |
# File 'lib/config/base.rb', line 18 def @skip_tags end |
#start_at_task ⇒ Object
Returns the value of attribute start_at_task.
19 20 21 |
# File 'lib/config/base.rb', line 19 def start_at_task @start_at_task end |
#sudo ⇒ Object
Returns the value of attribute sudo.
20 21 22 |
# File 'lib/config/base.rb', line 20 def sudo @sudo end |
#sudo_user ⇒ Object
Returns the value of attribute sudo_user.
21 22 23 |
# File 'lib/config/base.rb', line 21 def sudo_user @sudo_user end |
#tags ⇒ Object
Returns the value of attribute tags.
22 23 24 |
# File 'lib/config/base.rb', line 22 def @tags end |
#vault_password_file ⇒ Object
Returns the value of attribute vault_password_file.
23 24 25 |
# File 'lib/config/base.rb', line 23 def vault_password_file @vault_password_file end |
#verbose ⇒ Object
Returns the value of attribute verbose.
24 25 26 |
# File 'lib/config/base.rb', line 24 def verbose @verbose end |
Instance Method Details
#finalize! ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/config/base.rb', line 46 def finalize! @extra_vars = nil if @extra_vars == UNSET_VALUE @galaxy_role_file = nil if @galaxy_role_file == UNSET_VALUE @galaxy_roles_path = nil if @galaxy_roles_path == UNSET_VALUE @galaxy_command = GALAXY_COMMAND_DEFAULT if @galaxy_command == UNSET_VALUE @host_vars = {} if @host_vars == UNSET_VALUE @groups = {} if @groups == UNSET_VALUE @inventory_path = nil if @inventory_path == UNSET_VALUE @limit = nil if @limit == UNSET_VALUE @playbook = nil if @playbook == UNSET_VALUE @raw_arguments = nil if @raw_arguments == UNSET_VALUE @skip_tags = nil if @skip_tags == UNSET_VALUE @start_at_task = nil if @start_at_task == UNSET_VALUE @sudo = false if @sudo != true @sudo_user = nil if @sudo_user == UNSET_VALUE @tags = nil if @tags == UNSET_VALUE @vault_password_file = nil if @vault_password_file == UNSET_VALUE @verbose = false if @verbose == UNSET_VALUE end |
#validate(machine) ⇒ Object
Just like the normal configuration “validate” method except that it returns an array of errors that should be merged into some other error accumulator.
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 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/config/base.rb', line 69 def validate(machine) @errors = _detected_errors # Validate that a playbook path was provided if !playbook @errors << I18n.t("vagrant.provisioners.ansible.errors.no_playbook") end if playbook check_path_is_a_file(machine, playbook, "vagrant.provisioners.ansible.errors.playbook_path_invalid") end if inventory_path check_path_exists(machine, inventory_path, "vagrant.provisioners.ansible.errors.inventory_path_invalid") end if galaxy_role_file check_path_is_a_file(machine, galaxy_role_file, "vagrant.provisioners.ansible.errors.galaxy_role_file_invalid") end if vault_password_file check_path_is_a_file(machine, vault_password_file, "vagrant.provisioners.ansible.errors.vault_password_file_invalid") 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 extra_vars_is_valid = check_path_is_a_file(machine, extra_vars_path) if extra_vars_is_valid @extra_vars = '@' + extra_vars_path end end if !extra_vars_is_valid @errors << I18n.t( "vagrant.provisioners.ansible.errors.extra_vars_invalid", type: extra_vars.class.to_s, value: extra_vars.to_s) end end end |