本文整理匯總了Python中ansible.utils.VERBOSITY屬性的典型用法代碼示例。如果您正苦於以下問題:Python utils.VERBOSITY屬性的具體用法?Python utils.VERBOSITY怎麽用?Python utils.VERBOSITY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類ansible.utils
的用法示例。
在下文中一共展示了utils.VERBOSITY屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_pb
# 需要導入模塊: from ansible import utils [as 別名]
# 或者: from ansible.utils import VERBOSITY [as 別名]
def get_pb(task):
if task:
runner_cb = PlaybookRunnerCallbacks(task, stats, verbose=utils.VERBOSITY)
playbook_cb = PlaybookCallbacks(task, verbose=utils.VERBOSITY)
else:
runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=utils.VERBOSITY)
playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY)
pb = PlayBook(playbook='./test.yaml',
callbacks=playbook_cb,
runner_callbacks=runner_cb,
stats=stats,
inventory=inventory,
extra_vars=vars,
)
return pb
示例2: run
# 需要導入模塊: from ansible import utils [as 別名]
# 或者: from ansible.utils import VERBOSITY [as 別名]
def run(self, playbook_relational_path, extra_vars=None):
"""
run ansible playbook,
only surport relational path.
"""
stats = callbacks.AggregateStats()
playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY)
runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=utils.VERBOSITY)
playbook_path = os.path.join(ANSIBLE_DIR, playbook_relational_path)
pb = PlayBook(
playbook=playbook_path,
stats=stats,
callbacks=playbook_cb,
runner_callbacks=runner_cb,
inventory=self.inventory,
extra_vars=extra_vars,
check=False)
self.results = pb.run()
示例3: go_playbook
# 需要導入模塊: from ansible import utils [as 別名]
# 或者: from ansible.utils import VERBOSITY [as 別名]
def go_playbook(self, playfile, jobid):
try:
# Set ansible api variables
from ansible.playbook import PlayBook
from ansible import callbacks
from ansible import utils
self.playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY)
self.stats = callbacks.AggregateStats()
self.runner_cb = callbacks.PlaybookRunnerCallbacks(self.stats, verbose=utils.VERBOSITY)
except Exception, e:
print(str(e))
print('You need to run [python cldstkdeploy.py --setup all].')
sys.exit()
pass
示例4: playbook_run
# 需要導入模塊: from ansible import utils [as 別名]
# 或者: from ansible.utils import VERBOSITY [as 別名]
def playbook_run(inventory, playbook, default_user=None, default_port=None, default_pri_key_path=None):
stats = callbacks.AggregateStats()
playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY)
runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=utils.VERBOSITY)
# run the playbook
print default_user, default_port, default_pri_key_path, inventory, playbook
if default_user and default_port and default_pri_key_path:
playbook = PlayBook(host_list=inventory,
playbook=playbook,
forks=5,
remote_user=default_user,
remote_port=default_port,
private_key_file=default_pri_key_path,
callbacks=playbook_cb,
runner_callbacks=runner_cb,
stats=stats,
become=True,
become_user='root')
else:
playbook = PlayBook(host_list=inventory,
playbook=playbook,
forks=5,
callbacks=playbook_cb,
runner_callbacks=runner_cb,
stats=stats,
become=True,
become_user='root')
results = playbook.run()
print results
results_r = {'unreachable': [], 'failures': [], 'success': []}
for hostname, result in results.items():
if result.get('unreachable', 2):
results_r['unreachable'].append(hostname)
print "%s >>> unreachable" % hostname
elif result.get('failures', 2):
results_r['failures'].append(hostname)
print "%s >>> Failed" % hostname
else:
results_r['success'].append(hostname)
print "%s >>> Success" % hostname
return results_r