本文整理匯總了Python中ansible.constants方法的典型用法代碼示例。如果您正苦於以下問題:Python ansible.constants方法的具體用法?Python ansible.constants怎麽用?Python ansible.constants使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ansible
的用法示例。
在下文中一共展示了ansible.constants方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _load_ansible_config
# 需要導入模塊: import ansible [as 別名]
# 或者: from ansible import constants [as 別名]
def _load_ansible_config(self, config):
"""Load ansible configuration from command-line."""
option_names = ['ansible_inventory', 'ansible_host_pattern', 'ansible_connection', 'ansible_user',
'ansible_module_path', 'ansible_become', 'ansible_become_method', 'ansible_become_user',
'ansible_ask_become_pass', 'ansible_subset']
kwargs = dict()
# Load command-line supplied values
for key in option_names:
short_key = key[8:]
kwargs[short_key] = config.getoption(key)
# normalize ansible.ansible_become options
kwargs['become'] = kwargs['become'] or ansible.constants.DEFAULT_BECOME
kwargs['become_user'] = kwargs['become_user'] or ansible.constants.DEFAULT_BECOME_USER
kwargs['ask_become_pass'] = kwargs['ask_become_pass'] or ansible.constants.DEFAULT_BECOME_ASK_PASS
log.debug("config: %s" % kwargs)
return kwargs
示例2: _make_secrets
# 需要導入模塊: import ansible [as 別名]
# 或者: from ansible import constants [as 別名]
def _make_secrets(self, secret):
if _ANSIBLE_VER < 2.4:
return secret
from ansible.constants import DEFAULT_VAULT_ID_MATCH
from ansible.parsing.vault import VaultSecret
return [(DEFAULT_VAULT_ID_MATCH, VaultSecret(secret))]
示例3: become_methods
# 需要導入模塊: import ansible [as 別名]
# 或者: from ansible import constants [as 別名]
def become_methods():
"""Return string list of become methods available to ansible."""
if become_loader:
return [method.name for method in become_loader.all()]
else:
return ansible.constants.BECOME_METHODS