本文整理汇总了Python中ansible.parsing.dataloader.DataLoader.set_basedir方法的典型用法代码示例。如果您正苦于以下问题:Python DataLoader.set_basedir方法的具体用法?Python DataLoader.set_basedir怎么用?Python DataLoader.set_basedir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ansible.parsing.dataloader.DataLoader
的用法示例。
在下文中一共展示了DataLoader.set_basedir方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _play_prereqs
# 需要导入模块: from ansible.parsing.dataloader import DataLoader [as 别名]
# 或者: from ansible.parsing.dataloader.DataLoader import set_basedir [as 别名]
def _play_prereqs(options):
# all needs loader
loader = DataLoader()
basedir = getattr(options, 'basedir', False)
if basedir:
loader.set_basedir(basedir)
vault_ids = options.vault_ids
default_vault_ids = C.DEFAULT_VAULT_IDENTITY_LIST
vault_ids = default_vault_ids + vault_ids
vault_secrets = CLI.setup_vault_secrets(loader,
vault_ids=vault_ids,
vault_password_files=options.vault_password_files,
ask_vault_pass=options.ask_vault_pass,
auto_prompt=False)
loader.set_vault_secrets(vault_secrets)
# create the inventory, and filter it based on the subset specified (if any)
inventory = InventoryManager(loader=loader, sources=options.inventory)
# create the variable manager, which will be shared throughout
# the code, ensuring a consistent view of global variables
variable_manager = VariableManager(loader=loader, inventory=inventory)
# load vars from cli options
variable_manager.extra_vars = load_extra_vars(loader=loader, options=options)
variable_manager.options_vars = load_options_vars(options, CLI.version_info(gitinfo=False))
return loader, inventory, variable_manager
示例2: ansible_template
# 需要导入模块: from ansible.parsing.dataloader import DataLoader [as 别名]
# 或者: from ansible.parsing.dataloader.DataLoader import set_basedir [as 别名]
def ansible_template(basedir, varname, templatevars, **kwargs):
dl = DataLoader()
dl.set_basedir(basedir)
templar = Templar(dl, variables=templatevars)
return templar.template(varname, **kwargs)
示例3: path_dwim
# 需要导入模块: from ansible.parsing.dataloader import DataLoader [as 别名]
# 或者: from ansible.parsing.dataloader.DataLoader import set_basedir [as 别名]
def path_dwim(basedir, given):
dl = DataLoader()
dl.set_basedir(basedir)
return dl.path_dwim(given)