本文整理汇总了Python中ansible.utils.display.Display方法的典型用法代码示例。如果您正苦于以下问题:Python display.Display方法的具体用法?Python display.Display怎么用?Python display.Display使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ansible.utils.display
的用法示例。
在下文中一共展示了display.Display方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pytest_configure
# 需要导入模块: from ansible.utils import display [as 别名]
# 或者: from ansible.utils.display import Display [as 别名]
def pytest_configure(config):
"""Validate --ansible-* parameters."""
log.debug("pytest_configure() called")
config.addinivalue_line("markers", "ansible(**kwargs): Ansible integration")
# Enable connection debugging
if config.option.verbose > 0:
if hasattr(ansible.utils, 'VERBOSITY'):
ansible.utils.VERBOSITY = int(config.option.verbose)
else:
from ansible.utils.display import Display
display = Display()
display.verbosity = int(config.option.verbose)
assert config.pluginmanager.register(PyTestAnsiblePlugin(config), "ansible")
示例2: v2_playbook_on_task_start
# 需要导入模块: from ansible.utils import display [as 别名]
# 或者: from ansible.utils.display import Display [as 别名]
def v2_playbook_on_task_start(self, task, is_conditional):
self._display.banner("TASK [%s]" % task.get_name().strip())
# Display current time
self._display.display("%s" % datetime.now().strftime('%A %d %B %Y %H:%M:%S.%f '))
if self._display.verbosity > 2:
path = task.get_path()
if path:
self._display.display("task path: %s" %
path, color='dark gray')
示例3: display
# 需要导入模块: from ansible.utils import display [as 别名]
# 或者: from ansible.utils.display import Display [as 别名]
def display(*args, **kwargs):
"""Set up display function for Ansible v2"""
display_instance = Display()
display_instance.display(*args, **kwargs)
# Set to minimum required Ansible version
示例4: __init__
# 需要导入模块: from ansible.utils import display [as 别名]
# 或者: from ansible.utils.display import Display [as 别名]
def __init__(self, data_loader, inventory_manager, variable_manager, playbook_filename, options, graph=None):
"""
Main grapher responsible to parse the playbook and draw graph
:param data_loader:
:type data_loader: ansible.parsing.dataloader.DataLoader
:param inventory_manager:
:type inventory_manager: ansible.inventory.manager.InventoryManager
:param variable_manager:
:type variable_manager: ansible.vars.manager.VariableManager
:param options Command line options
:type options: optparse.Values
:param playbook_filename:
:type playbook_filename: str
:param graph:
:type graph: Digraph
"""
self.options = options
self.variable_manager = variable_manager
self.inventory_manager = inventory_manager
self.data_loader = data_loader
self.playbook_filename = playbook_filename
self.options.output_filename = self.options.output_filename
self.rendered_file_path = None
self.display = Display(verbosity=options.verbosity)
if self.options.tags is None:
self.options.tags = ["all"]
if self.options.skip_tags is None:
self.options.skip_tags = []
self.graph_representation = GraphRepresentation()
self.playbook = Playbook.load(self.playbook_filename, loader=self.data_loader,
variable_manager=self.variable_manager)
if graph is None:
self.graph = CustomDigrah(edge_attr=self.DEFAULT_EDGE_ATTR, graph_attr=self.DEFAULT_GRAPH_ATTR,
format="svg")
示例5: ansible_playbook
# 需要导入模块: from ansible.utils import display [as 别名]
# 或者: from ansible.utils.display import Display [as 别名]
def ansible_playbook(inventory, playbook_path, verbose=None,
extra_vars=None, ansible_args=None):
"""Wraps the 'ansible-playbook' CLI.
:param inventory: inventory file to use.
:param playbook_path: the playbook to invoke
:param verbose: Ansible verbosity level
:param extra_vars: dict. Passed to Ansible as extra-vars
:param ansible_args: dict of ansible-playbook arguments to plumb down
directly to Ansible.
"""
ansible_args = ansible_args or []
LOG.debug("Additional ansible args: {}".format(ansible_args))
# hack for verbosity
from ansible.utils.display import Display
display = Display(verbosity=verbose)
import __main__ as main
setattr(main, "display", display)
# TODO(yfried): Use proper ansible API instead of emulating CLI
cli_args = ['execute',
playbook_path,
'--inventory', inventory]
# infrared should not change ansible verbosity unless user specifies that
if verbose:
cli_args.append('-' + 'v' * int(verbose))
cli_args.extend(ansible_args)
results = _run_playbook(cli_args,
vars_dict=extra_vars or {})
if results:
LOG.error('Playbook "%s" failed!' % playbook_path)
return results
示例6: test_single_display_module
# 需要导入模块: from ansible.utils import display [as 别名]
# 或者: from ansible.utils.display import Display [as 别名]
def test_single_display_module():
assert sum(1 for obj in gc.get_objects() if isinstance(obj, Display)) == 1
示例7: __init__
# 需要导入模块: from ansible.utils import display [as 别名]
# 或者: from ansible.utils.display import Display [as 别名]
def __init__(self, playbook, inventory, run_data=None, verbosity=0, tags=None, skip_tags=None):
self.run_data = run_data or {}
self.options = Options()
self.options.verbosity = verbosity
self.options.connection = 'local' # Need a connection type "smart" or "ssh"
self.options.become = True
self.options.become_method = 'sudo'
self.options.become_user = 'root'
self.options.tags = tags or []
self.options.skip_tags = skip_tags or []
# Set global verbosity
self.display = Display()
self.display.verbosity = self.options.verbosity
# Executor appears to have it's own
# verbosity object/setting as well
playbook_executor.verbosity = self.options.verbosity
# Become Pass Needed if not logging in as user root
passwords = {}
# Gets data from YAML/JSON files
self.loader = DataLoader()
self.loader.set_vault_password(os.environ.get('VAULT_PASS',''))
# All the variables from all the various places
self.variable_manager = VariableManager()
self.variable_manager.extra_vars = self.run_data
self.inventory = Inventory(loader=self.loader, variable_manager=self.variable_manager, host_list=inventory)
self.variable_manager.set_inventory(self.inventory)
# Setup playbook executor, but don't run until run() called
self.pbex = playbook_executor.PlaybookExecutor(
playbooks=[playbook],
inventory=self.inventory,
variable_manager=self.variable_manager,
loader=self.loader,
options=self.options,
passwords=passwords)