当前位置: 首页>>代码示例>>Python>>正文


Python constants.HOST_KEY_CHECKING属性代码示例

本文整理汇总了Python中ansible.constants.HOST_KEY_CHECKING属性的典型用法代码示例。如果您正苦于以下问题:Python constants.HOST_KEY_CHECKING属性的具体用法?Python constants.HOST_KEY_CHECKING怎么用?Python constants.HOST_KEY_CHECKING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在ansible.constants的用法示例。


在下文中一共展示了constants.HOST_KEY_CHECKING属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_playbook

# 需要导入模块: from ansible import constants [as 别名]
# 或者: from ansible.constants import HOST_KEY_CHECKING [as 别名]
def run_playbook(self, playbook_path,extra_vars=None):
        """
        run ansible palybook
        """
        try:
            # if self.redisKey:self.callback = PlayBookResultsCollectorToSave(self.redisKey,self.logId)
            self.callback = PlayBookResultsCollector()
            if extra_vars:self.variable_manager.extra_vars = extra_vars
            executor = PlaybookExecutor(
                playbooks=[playbook_path], inventory=self.inventory, variable_manager=self.variable_manager, loader=self.loader,
                options=self.options, passwords=self.passwords,
            )
            executor._tqm._stdout_callback = self.callback
            constants.HOST_KEY_CHECKING = False #关闭第一次使用ansible连接客户端是输入命令
            executor.run()
        except Exception as err:
            return False 
开发者ID:iopsgroup,项目名称:imoocc,代码行数:19,代码来源:ansible_api.py

示例2: run_model

# 需要导入模块: from ansible import constants [as 别名]
# 或者: from ansible.constants import HOST_KEY_CHECKING [as 别名]
def run_model(self, host_list, module_name, module_args):
        """
        run module from andible ad-hoc.
        module_name: ansible module_name
        module_args: ansible module args
        """
        play_source = dict(
                name="Ansible Play",
                hosts=host_list,
                gather_facts='no',
                tasks=[dict(action=dict(module=module_name, args=module_args))]
        )

        play = Play().load(play_source, variable_manager=self.variable_manager, loader=self.loader)
        tqm = None
        # if self.redisKey:self.callback = ModelResultsCollectorToSave(self.redisKey,self.logId)
        # else:self.callback = ModelResultsCollector()
        self.callback = ModelResultsCollector()
        import traceback
        try:
            tqm = TaskQueueManager(
                    inventory=self.inventory,
                    variable_manager=self.variable_manager,
                    loader=self.loader,
                    options=self.options,
                    passwords=self.passwords,
                    stdout_callback = "minimal",
            )
            tqm._stdout_callback = self.callback
            constants.HOST_KEY_CHECKING = False #关闭第一次使用ansible连接客户端是输入命令
            tqm.run(play)
        except Exception as err:
            print traceback.print_exc()
            # DsRedis.OpsAnsibleModel.lpush(self.redisKey,data=err)
            # if self.logId:AnsibleSaveResult.Model.insert(self.logId, err)
        finally:
            if tqm is not None:
                tqm.cleanup() 
开发者ID:iopsgroup,项目名称:imoocc,代码行数:40,代码来源:ansible_api.py

示例3: _connect_ssh

# 需要导入模块: from ansible import constants [as 别名]
# 或者: from ansible.constants import HOST_KEY_CHECKING [as 别名]
def _connect_ssh(spec):
    """
    Return ContextService arguments for an SSH connection.
    """
    if C.HOST_KEY_CHECKING:
        check_host_keys = 'enforce'
    else:
        check_host_keys = 'ignore'

    # #334: tilde-expand private_key_file to avoid implementation difference
    # between Python and OpenSSH.
    private_key_file = spec.private_key_file()
    if private_key_file is not None:
        private_key_file = os.path.expanduser(private_key_file)

    return {
        'method': 'ssh',
        'kwargs': {
            'check_host_keys': check_host_keys,
            'hostname': spec.remote_addr(),
            'username': spec.remote_user(),
            'compression': convert_bool(
                default(spec.mitogen_ssh_compression(), True)
            ),
            'password': spec.password(),
            'port': spec.port(),
            'python_path': spec.python_path(),
            'identity_file': private_key_file,
            'identities_only': False,
            'ssh_path': spec.ssh_executable(),
            'connect_timeout': spec.ansible_ssh_timeout(),
            'ssh_args': spec.ssh_args(),
            'ssh_debug_level': spec.mitogen_ssh_debug_level(),
            'remote_name': get_remote_name(spec),
            'keepalive_count': (
                spec.mitogen_ssh_keepalive_count() or 10
            ),
            'keepalive_interval': (
                spec.mitogen_ssh_keepalive_interval() or 30
            ),
        }
    } 
开发者ID:dw,项目名称:mitogen,代码行数:44,代码来源:connection.py


注:本文中的ansible.constants.HOST_KEY_CHECKING属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。