From 299c18d70009ee7a6d79fe99e5cc9444cefc790d Mon Sep 17 00:00:00 2001 From: Kishin Yagami Date: Sat, 5 Mar 2016 20:15:04 +0900 Subject: [PATCH] Support strategy_plugins setting in a configuration file --- docsite/rst/developing_plugins.rst | 1 + docsite/rst/intro_configuration.rst | 14 ++++++++++++++ examples/ansible.cfg | 1 + lib/ansible/constants.py | 1 + lib/ansible/plugins/__init__.py | 2 +- 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docsite/rst/developing_plugins.rst b/docsite/rst/developing_plugins.rst index 2b0c2344d0..125163407a 100644 --- a/docsite/rst/developing_plugins.rst +++ b/docsite/rst/developing_plugins.rst @@ -112,6 +112,7 @@ to /usr/share/ansible/plugins, in a subfolder for each plugin type:: * connection_plugins * filter_plugins * vars_plugins + * strategy_plugins To change this path, edit the ansible configuration file. diff --git a/docsite/rst/intro_configuration.rst b/docsite/rst/intro_configuration.rst index 4272ef7fb9..190c0cf6be 100644 --- a/docsite/rst/intro_configuration.rst +++ b/docsite/rst/intro_configuration.rst @@ -600,6 +600,20 @@ Additional paths can be provided separated by colon characters, in the same way Roles will be first searched for in the playbook directory. Should a role not be found, it will indicate all the possible paths that were searched. +.. _strategy_plugins: + +strategy_plugins +================== + +Strategy plugin allow users to change the way in which Ansible runs tasks on targeted hosts. + +This is a developer-centric feature that allows low-level extensions around Ansible to be loaded from +different locations:: + + strategy_plugins = ~/.ansible/plugins/strategy_plugins/:/usr/share/ansible_plugins/strategy_plugins + +Most users will not need to use this feature. See :doc:`developing_plugins` for more details + .. _sudo_exe: sudo_exe diff --git a/examples/ansible.cfg b/examples/ansible.cfg index 91ef70b77a..48628441fb 100644 --- a/examples/ansible.cfg +++ b/examples/ansible.cfg @@ -141,6 +141,7 @@ #vars_plugins = /usr/share/ansible/plugins/vars #filter_plugins = /usr/share/ansible/plugins/filter #test_plugins = /usr/share/ansible/plugins/test +#strategy_plugins = /usr/share/ansible/plugins/strategy # by default callbacks are not loaded for /bin/ansible, enable this if you # want, for example, a notification or logging callback to also apply to diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py index 6623b8f0c3..2ca0173438 100644 --- a/lib/ansible/constants.py +++ b/lib/ansible/constants.py @@ -212,6 +212,7 @@ DEFAULT_INVENTORY_PLUGIN_PATH = get_config(p, DEFAULTS, 'inventory_plugins', ' DEFAULT_VARS_PLUGIN_PATH = get_config(p, DEFAULTS, 'vars_plugins', 'ANSIBLE_VARS_PLUGINS', '~/.ansible/plugins/vars:/usr/share/ansible/plugins/vars', ispath=True) DEFAULT_FILTER_PLUGIN_PATH = get_config(p, DEFAULTS, 'filter_plugins', 'ANSIBLE_FILTER_PLUGINS', '~/.ansible/plugins/filter:/usr/share/ansible/plugins/filter', ispath=True) DEFAULT_TEST_PLUGIN_PATH = get_config(p, DEFAULTS, 'test_plugins', 'ANSIBLE_TEST_PLUGINS', '~/.ansible/plugins/test:/usr/share/ansible/plugins/test', ispath=True) +DEFAULT_STRATEGY_PLUGIN_PATH = get_config(p, DEFAULTS, 'strategy_plugins', 'ANSIBLE_STRATEGY_PLUGINS', '~/.ansible/plugins/strategy:/usr/share/ansible/plugins/strategy', ispath=True) DEFAULT_STDOUT_CALLBACK = get_config(p, DEFAULTS, 'stdout_callback', 'ANSIBLE_STDOUT_CALLBACK', 'default') # cache CACHE_PLUGIN = get_config(p, DEFAULTS, 'fact_caching', 'ANSIBLE_CACHE_PLUGIN', 'memory') diff --git a/lib/ansible/plugins/__init__.py b/lib/ansible/plugins/__init__.py index 139e5a7d61..f0fa0ec62b 100644 --- a/lib/ansible/plugins/__init__.py +++ b/lib/ansible/plugins/__init__.py @@ -444,7 +444,7 @@ fragment_loader = PluginLoader( strategy_loader = PluginLoader( 'StrategyModule', 'ansible.plugins.strategy', - None, + C.DEFAULT_STRATEGY_PLUGIN_PATH, 'strategy_plugins', required_base_class='StrategyBase', )