fixes to config/setting retrieval

- better variable precedence management
- universal plugin option handling
- also updated comments for future directions
- leverage fragments for plugins
- removed fact namespacing
- added 'firendly name' field
- updated missing descriptions
- removed some unused yaml entries, updated others to reflect possible future
- documented more plugins
- allow reading docs using alias
- short licenses
- corrected args for 'all plugins'
- fixed -a option for ansible-doc
- updated vars plugins to allow docs
- fixed 'gathering'
- only set options IF connection
- added path list and renamed pathspec mostly the diff is , vs : as separator
- readded removed config entries that were deprecated but had no message ... and deprecated again
- now deprecated entries give warning when set
This commit is contained in:
Brian Coca 2017-08-20 11:20:30 -04:00 committed by Toshio Kuratomi
parent f88750d665
commit 075ead8fb0
70 changed files with 1862 additions and 1292 deletions

View file

@ -6,14 +6,13 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os # used to set lang
import os # used to set lang and for backwards compat get_config
from string import ascii_letters, digits
from ansible.module_utils._text import to_text
from ansible.module_utils.parsing.convert_bool import boolean, BOOLEANS_TRUE
from ansible.module_utils.six import string_types
from ansible.config.manager import ConfigManager
from ansible.config.manager import ConfigManager, ensure_type
def _deprecated(msg):
''' display is not guaranteed here, nor it being the full class, but try anyways, fallback to sys.stderr.write '''
@ -33,8 +32,6 @@ def get_config(parser, section, key, env_var, default_value, value_type=None, ex
''' kept for backwarsd compatibility, but deprecated '''
_deprecated('ansible.constants.get_config() is deprecated. There is new config API, see porting docs.')
import os
value = None
# small reconstruction of the old code env/ini/default
value = os.environ.get(env_var, None)
@ -52,6 +49,10 @@ def get_config(parser, section, key, env_var, default_value, value_type=None, ex
return value
def set_constant(name, value, export=vars()):
''' sets constants and returns resolved options dict '''
export[name] = value
### CONSTANTS ### yes, actual ones
BLACKLIST_EXTS = ('.pyc', '.pyo', '.swp', '.bak', '~', '.rpm', '.md', '.txt')
BECOME_METHODS = ['sudo', 'su', 'pbrun', 'pfexec', 'doas', 'dzdo', 'ksu', 'runas', 'pmrun']
@ -98,15 +99,15 @@ config = ConfigManager()
# Generate constants from config
for setting in config.data.get_settings():
# FIXME: find better way to do in manager class and/or ensure types
value = None
if isinstance(setting.value, string_types) and (setting.value.startswith('eval(') and setting.value.endswith(')')):
try:
# FIXME: find better way to do in manager class and/or ensure types
eval_string = setting.value.replace('eval(', '', 1)[:-1]
vars()[setting.name] = eval(eval_string) # FIXME: safe eval?
continue
value = ensure_type(eval(eval_string), setting.type) # FIXME: safe eval?
except:
pass
value = setting.value
vars()[setting.name] = setting.value
set_constant(setting.name, setting.value)