當前位置: 首頁>>代碼示例>>Python>>正文


Python utils.VERBOSITY屬性代碼示例

本文整理匯總了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 
開發者ID:onlytiancai,項目名稱:ansible-celery-flask-demo,代碼行數:18,代碼來源:test_playbook.py

示例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() 
開發者ID:zsjtoby,項目名稱:DevOpsCloud,代碼行數:22,代碼來源:ansible_api.py

示例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 
開發者ID:thehyperadvisor,項目名稱:cldstk-deploy,代碼行數:16,代碼來源:cldstkdeploy.py

示例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 
開發者ID:zsjtoby,項目名稱:DevOpsCloud,代碼行數:43,代碼來源:tasks.py


注:本文中的ansible.utils.VERBOSITY屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。