Class: Ansible::Config::DefaultConfig
- Inherits:
-
Struct
- Object
- Struct
- Ansible::Config::DefaultConfig
- Defined in:
- lib/ansible/config.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
Returns the value of attribute env.
-
#extra_vars ⇒ Object
Returns the value of attribute extra_vars.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize ⇒ DefaultConfig
constructor
A new instance of DefaultConfig.
-
#options ⇒ Object
NB: –extra-vars can also accept JSON string, see stackoverflow.com/questions/25617273/pass-array-in-extra-vars-ansible.
- #to_s(cmd) ⇒ Object
Constructor Details
#initialize ⇒ DefaultConfig
Returns a new instance of DefaultConfig.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ansible/config.rb', line 9 def initialize self.env = { 'ANSIBLE_FORCE_COLOR' => 'True', 'ANSIBLE_HOST_KEY_CHECKING' => 'False' } self.params = { debug: false } # options self.extra_vars = { # skip creation of .retry files 'retry_files_enabled' => 'False' } # TODO support --ssh-common-args, --ssh-extra-args # e.g. ansible-playbook --ssh-common-args="-o ServerAliveInterval=60" -i inventory install.yml end |
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env
8 9 10 |
# File 'lib/ansible/config.rb', line 8 def env @env end |
#extra_vars ⇒ Object
Returns the value of attribute extra_vars
8 9 10 |
# File 'lib/ansible/config.rb', line 8 def extra_vars @extra_vars end |
#params ⇒ Object
Returns the value of attribute params
8 9 10 |
# File 'lib/ansible/config.rb', line 8 def params @params end |
Instance Method Details
#options ⇒ Object
NB: –extra-vars can also accept JSON string, see stackoverflow.com/questions/25617273/pass-array-in-extra-vars-ansible
29 30 31 32 33 34 |
# File 'lib/ansible/config.rb', line 29 def x = extra_vars.each_with_object('--extra-vars=\'') { |kv, a| a << "#{kv.first}=\"#{kv.last}\" " }.strip+'\'' if extra_vars unless extra_vars.empty? # can test with configure { |config| config.extra_vars.clear } [x, '--ssh-extra-args=\'-o UserKnownHostsFile=/dev/null\'']*' ' end |
#to_s(cmd) ⇒ Object
36 37 38 39 40 |
# File 'lib/ansible/config.rb', line 36 def to_s(cmd) entire_cmd = [env.each_with_object([]) { |kv, a| a << kv*'=' } * ' ', cmd, ]*' ' puts entire_cmd if params[:debug] entire_cmd end |