mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
Config continued (#31024)
* included inventory and callback in new config allow inventory to be configurable updated connection options settings also updated winrm to work with new configs removed now obsolete set_host_overrides added notes for future bcoca, current one is just punting, it's future's problem updated docs per feedback added remove group/host methods to inv data moved fact cache from data to constructed cleaner/better options fix when vars are added extended ignore list to config dicts updated paramiko connection docs removed options from base that paramiko already handles left the look option as it is used by other plugin types resolve delegation updated cache doc options fixed test_script better fragment merge for options fixed proxy command restore ini for proxy normalized options moved pipelining to class updates for host_key_checking restructured mixins * fix typo
This commit is contained in:
@@ -1319,36 +1319,13 @@ PARAMIKO_HOST_KEY_AUTO_ADD:
|
||||
- {key: host_key_auto_add, section: paramiko_connection}
|
||||
type: boolean
|
||||
PARAMIKO_LOOK_FOR_KEYS:
|
||||
# TODO: move to plugin
|
||||
name: look for keys
|
||||
default: True
|
||||
description: 'TODO: write it'
|
||||
env: [{name: ANSIBLE_PARAMIKO_LOOK_FOR_KEYS}]
|
||||
ini:
|
||||
- {key: look_for_keys, section: paramiko_connection}
|
||||
type: boolean
|
||||
PARAMIKO_PROXY_COMMAND:
|
||||
# TODO: move to plugin
|
||||
default:
|
||||
description: 'TODO: write it'
|
||||
env: [{name: ANSIBLE_PARAMIKO_PROXY_COMMAND}]
|
||||
ini:
|
||||
- {key: proxy_command, section: paramiko_connection}
|
||||
PARAMIKO_PTY:
|
||||
# TODO: move to plugin
|
||||
default: True
|
||||
description: 'TODO: write it'
|
||||
env: [{name: ANSIBLE_PARAMIKO_PTY}]
|
||||
ini:
|
||||
- {key: pty, section: paramiko_connection}
|
||||
type: boolean
|
||||
PARAMIKO_RECORD_HOST_KEYS:
|
||||
# TODO: move to plugin
|
||||
default: True
|
||||
description: 'TODO: write it'
|
||||
env: [{name: ANSIBLE_PARAMIKO_RECORD_HOST_KEYS}]
|
||||
ini:
|
||||
- {key: record_host_keys, section: paramiko_connection}
|
||||
type: boolean
|
||||
PERSISTENT_CONTROL_PATH_DIR:
|
||||
name: Persistence socket path
|
||||
default: ~/.ansible/pc
|
||||
|
||||
@@ -128,7 +128,7 @@ def get_ini_config_value(p, entry):
|
||||
if p is not None:
|
||||
try:
|
||||
value = p.get(entry.get('section', 'defaults'), entry.get('key', ''), raw=True)
|
||||
except: # FIXME: actually report issues here
|
||||
except Exception: # FIXME: actually report issues here
|
||||
pass
|
||||
return value
|
||||
|
||||
@@ -224,15 +224,24 @@ class ConfigManager(object):
|
||||
''' Load YAML Config Files in order, check merge flags, keep origin of settings'''
|
||||
pass
|
||||
|
||||
def get_plugin_options(self, plugin_type, name, variables=None):
|
||||
def get_plugin_options(self, plugin_type, name, keys=None, variables=None):
|
||||
|
||||
options = {}
|
||||
defs = self.get_configuration_definitions(plugin_type, name)
|
||||
for option in defs:
|
||||
options[option] = self.get_config_value(option, plugin_type=plugin_type, plugin_name=name, variables=variables)
|
||||
options[option] = self.get_config_value(option, plugin_type=plugin_type, plugin_name=name, keys=keys, variables=variables)
|
||||
|
||||
return options
|
||||
|
||||
def get_plugin_vars(self, plugin_type, name):
|
||||
|
||||
pvars = []
|
||||
for pdef in self.get_configuration_definitions(plugin_type, name).values():
|
||||
if 'vars' in pdef and pdef['vars']:
|
||||
for var_entry in pdef['vars']:
|
||||
pvars.append(var_entry['name'])
|
||||
return pvars
|
||||
|
||||
def get_configuration_definitions(self, plugin_type=None, name=None):
|
||||
''' just list the possible settings, either base or for specific plugins or plugin '''
|
||||
|
||||
@@ -264,12 +273,12 @@ class ConfigManager(object):
|
||||
|
||||
return value, origin
|
||||
|
||||
def get_config_value(self, config, cfile=None, plugin_type=None, plugin_name=None, variables=None):
|
||||
def get_config_value(self, config, cfile=None, plugin_type=None, plugin_name=None, keys=None, variables=None):
|
||||
''' wrapper '''
|
||||
value, _drop = self.get_config_value_and_origin(config, cfile=cfile, plugin_type=plugin_type, plugin_name=plugin_name, variables=variables)
|
||||
value, _drop = self.get_config_value_and_origin(config, cfile=cfile, plugin_type=plugin_type, plugin_name=plugin_name, keys=keys, variables=variables)
|
||||
return value
|
||||
|
||||
def get_config_value_and_origin(self, config, cfile=None, plugin_type=None, plugin_name=None, variables=None):
|
||||
def get_config_value_and_origin(self, config, cfile=None, plugin_type=None, plugin_name=None, keys=None, variables=None):
|
||||
''' Given a config key figure out the actual value and report on the origin of the settings '''
|
||||
|
||||
if cfile is None:
|
||||
@@ -290,10 +299,15 @@ class ConfigManager(object):
|
||||
|
||||
if config in defs:
|
||||
# Use 'variable overrides' if present, highest precedence, but only present when querying running play
|
||||
if variables:
|
||||
if variables and defs[config].get('vars'):
|
||||
value, origin = self._loop_entries(variables, defs[config]['vars'])
|
||||
origin = 'var: %s' % origin
|
||||
|
||||
# use playbook keywords if you have em
|
||||
if value is None and keys:
|
||||
value, origin = self._loop_entries(keys, defs[config]['keywords'])
|
||||
origin = 'keyword: %s' % origin
|
||||
|
||||
# env vars are next precedence
|
||||
if value is None and defs[config].get('env'):
|
||||
value, origin = self._loop_entries(os.environ, defs[config]['env'])
|
||||
@@ -319,13 +333,6 @@ class ConfigManager(object):
|
||||
# FIXME: implement, also , break down key from defs (. notation???)
|
||||
origin = cfile
|
||||
|
||||
'''
|
||||
# for plugins, try using existing constants, this is for backwards compatiblity
|
||||
if plugin_name and defs[config].get('constants'):
|
||||
value, origin = self._loop_entries(self.data, defs[config]['constants'])
|
||||
origin = 'constant: %s' % origin
|
||||
'''
|
||||
|
||||
# set default if we got here w/o a value
|
||||
if value is None:
|
||||
value = defs[config].get('default')
|
||||
|
||||
Reference in New Issue
Block a user