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


Python ansible.__version__方法代码示例

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


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

示例1: configure_context_processors

# 需要导入模块: import ansible [as 别名]
# 或者: from ansible import __version__ [as 别名]
def configure_context_processors(app):
    @app.context_processor
    def ctx_add_nav_data():
        """
        Returns standard data that will be available in every template view.
        """
        try:
            models.Playbook.query.one()
            empty_database = False
        except models.MultipleResultsFound:
            empty_database = False
        except models.NoResultFound:
            empty_database = True

        # Get python version info
        major, minor, micro, release, serial = sys.version_info

        return dict(ara_version=ara_release,
                    ansible_version=ansible_version,
                    python_version="{0}.{1}".format(major, minor),
                    empty_database=empty_database) 
开发者ID:dmsimard,项目名称:ara-archive,代码行数:23,代码来源:context_processors.py

示例2: get_play_prereqs_2

# 需要导入模块: import ansible [as 别名]
# 或者: from ansible import __version__ [as 别名]
def get_play_prereqs_2(self, options):
        loader = DataLoader()

        if self.vault_pass:
            loader.set_vault_password(self.vault_pass)

        variable_manager = VariableManager()
        variable_manager.extra_vars = self.extra_vars
        variable_manager.options_vars = {'ansible_version': self.version_info(ansible_version)}

        inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list=options.inventory)
        variable_manager.set_inventory(inventory)

        # let inventory know which playbooks are using so it can know the
        # basedirs
        inventory.set_playbook_basedir(os.path.dirname(self.playbook_file))

        return loader, inventory, variable_manager 
开发者ID:grycap,项目名称:im,代码行数:20,代码来源:ansible_launcher.py

示例3: get_play_prereqs_2_4

# 需要导入模块: import ansible [as 别名]
# 或者: from ansible import __version__ [as 别名]
def get_play_prereqs_2_4(self, options):
        loader = DataLoader()

        if self.vault_pass:
            loader.set_vault_secrets([('default', VaultSecret(_bytes=to_bytes(self.vault_pass)))])

        # 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
        try:
            # Ansible 2.8
            variable_manager = VariableManager(loader=loader, inventory=inventory,
                                               version_info=self.version_info(ansible_version))
            variable_manager._extra_vars = self.extra_vars
        except TypeError:
            variable_manager = VariableManager(loader=loader, inventory=inventory)
            variable_manager.extra_vars = self.extra_vars
            variable_manager.options_vars = {'ansible_version': self.version_info(ansible_version)}

        return loader, inventory, variable_manager 
开发者ID:grycap,项目名称:im,代码行数:24,代码来源:ansible_launcher.py

示例4: run

# 需要导入模块: import ansible [as 别名]
# 或者: from ansible import __version__ [as 别名]
def run(self):
        cur_python_ver = "%d.%d" % (sys.version_info[0], sys.version_info[1])
        if LooseVersion(cur_python_ver) < LooseVersion(PYTHON_REQUIRE):
            print("Error: Python version " + cur_python_ver + " < " + PYTHON_REQUIRE)
            return False
        os.system("%s -m pip install ansible>=%s" % (sys.executable, ABSIBLE_REQUIRE))
        os.system("%s -m pip install ansible-runner>=%s" % (sys.executable, ABSIBLER_REQUIRE))
        os.system("%s -m pip install sanic>=%s" % (sys.executable, SANIC_REQUIRE))
        try:
            import ansible
            import ansible_runner
        except ImportError:
            print("Error: I can NOT work without ansible-runner")
        # path = os.path.dirname(ansible.__file__)
        if LooseVersion(ansible.__version__) >= LooseVersion(ABSIBLE_REQUIRE) and \
                LooseVersion(pkg_resources.require("ansible_runner")[0].version) >= LooseVersion(ABSIBLER_REQUIRE):
            install.run(self)
            self.init_config_file()
            print("\033[1;37mAnsible-api v%s install complete.\033[0m" %
                  __version__)
        else:
            print("Error: ansible [%s] or ansible-runner [%s] version too low" %
                  (ansible_runner.__version__, pkg_resources.require("ansible_runner")[0].version)) 
开发者ID:lfbear,项目名称:ansible-api,代码行数:25,代码来源:setup.py

示例5: _assert_supported_release

# 需要导入模块: import ansible [as 别名]
# 或者: from ansible import __version__ [as 别名]
def _assert_supported_release():
    """
    Throw AnsibleError with a descriptive message in case of being loaded into
    an unsupported Ansible release.
    """
    v = ansible.__version__
    if not isinstance(v, tuple):
        v = tuple(distutils.version.LooseVersion(v).version)

    if v[:2] < ANSIBLE_VERSION_MIN:
        raise ansible.errors.AnsibleError(
            OLD_VERSION_MSG % (v, ANSIBLE_VERSION_MIN)
        )

    if v[:2] > ANSIBLE_VERSION_MAX:
        raise ansible.errors.AnsibleError(
            NEW_VERSION_MSG % (ansible.__version__, ANSIBLE_VERSION_MAX)
        ) 
开发者ID:dw,项目名称:mitogen,代码行数:20,代码来源:strategy.py

示例6: wrap_action_loader__get

# 需要导入模块: import ansible [as 别名]
# 或者: from ansible import __version__ [as 别名]
def wrap_action_loader__get(name, *args, **kwargs):
    """
    While the mitogen strategy is active, trap action_loader.get() calls,
    augmenting any fetched class with ActionModuleMixin, which replaces various
    helper methods inherited from ActionBase with implementations that avoid
    the use of shell fragments wherever possible.

    This is used instead of static subclassing as it generalizes to third party
    action plugins outside the Ansible tree.
    """
    get_kwargs = {'class_only': True}
    if name in ('fetch',):
        name = 'mitogen_' + name
    if ansible.__version__ >= '2.8':
        get_kwargs['collection_list'] = kwargs.pop('collection_list', None)

    klass = ansible_mitogen.loaders.action_loader__get(name, **get_kwargs)
    if klass:
        bases = (ansible_mitogen.mixins.ActionModuleMixin, klass)
        adorned_klass = type(str(name), bases, {})
        if kwargs.get('class_only'):
            return adorned_klass
        return adorned_klass(*args, **kwargs) 
开发者ID:dw,项目名称:mitogen,代码行数:25,代码来源:strategy.py

示例7: _set_temp_file_args

# 需要导入模块: import ansible [as 别名]
# 或者: from ansible import __version__ [as 别名]
def _set_temp_file_args(self, module_args, wrap_async):
        # Ansible>2.5 module_utils reuses the action's temporary directory if
        # one exists. Older versions error if this key is present.
        if ansible.__version__ > '2.5':
            if wrap_async:
                # Sharing is not possible with async tasks, as in that case,
                # the directory must outlive the action plug-in.
                module_args['_ansible_tmpdir'] = None
            else:
                module_args['_ansible_tmpdir'] = self._connection._shell.tmpdir

        # If _ansible_tmpdir is unset, Ansible>2.6 module_utils will use
        # _ansible_remote_tmp as the location to create the module's temporary
        # directory. Older versions error if this key is present.
        if ansible.__version__ > '2.6':
            module_args['_ansible_remote_tmp'] = (
                self._connection.get_good_temp_dir()
            ) 
开发者ID:dw,项目名称:mitogen,代码行数:20,代码来源:mixins.py

示例8: _setup_responder

# 需要导入模块: import ansible [as 别名]
# 或者: from ansible import __version__ [as 别名]
def _setup_responder(responder):
    """
    Configure :class:`mitogen.master.ModuleResponder` to only permit
    certain packages, and to generate custom responses for certain modules.
    """
    responder.whitelist_prefix('ansible')
    responder.whitelist_prefix('ansible_mitogen')
    _setup_simplejson(responder)

    # Ansible 2.3 is compatible with Python 2.4 targets, however
    # ansible/__init__.py is not. Instead, executor/module_common.py writes
    # out a 2.4-compatible namespace package for unknown reasons. So we
    # copy it here.
    responder.add_source_override(
        fullname='ansible',
        path=ansible.__file__,
        source=(ANSIBLE_PKG_OVERRIDE % (
            ansible.__version__,
            ansible.__author__,
        )).encode(),
        is_pkg=True,
    ) 
开发者ID:dw,项目名称:mitogen,代码行数:24,代码来源:process.py

示例9: __init__

# 需要导入模块: import ansible [as 别名]
# 或者: from ansible import __version__ [as 别名]
def __init__(self, complete=True, path='playbook.yml',
                 options={'fake': 'yes'}):
        self.ansible_version = ansible_version
        self.complete = complete
        self.options = options
        self.path = path

        # Callback specific parameter
        self._file_name = path 
开发者ID:dmsimard,项目名称:ara-archive,代码行数:11,代码来源:fakes.py

示例10: model

# 需要导入模块: import ansible [as 别名]
# 或者: from ansible import __version__ [as 别名]
def model(self):
        return m.Playbook(ansible_version=ansible_version,
                          complete=self.complete,
                          options=self.options,
                          path=self.path) 
开发者ID:dmsimard,项目名称:ara-archive,代码行数:7,代码来源:fakes.py

示例11: _ara_config

# 需要导入模块: import ansible [as 别名]
# 或者: from ansible import __version__ [as 别名]
def _ara_config(config, key, env_var, default=None, section='ara',
                value_type=None):
    """
    Wrapper around Ansible's get_config backward/forward compatibility
    """
    if default is None:
        try:
            # We're using env_var as keys in the DEFAULTS dict
            default = DEFAULTS.get(env_var)
        except KeyError as e:
            msg = 'There is no default value for {0}: {1}'.format(key, str(e))
            raise KeyError(msg)

    # >= 2.3.0.0 (NOTE: Ansible trunk versioning scheme has 3 digits, not 4)
    if LooseVersion(ansible_version) >= LooseVersion('2.3.0'):
        return get_config(config, section, key, env_var, default,
                          value_type=value_type)

    # < 2.3.0.0 compatibility
    if value_type is None:
        return get_config(config, section, key, env_var, default)

    args = {
        'boolean': dict(boolean=True),
        'integer': dict(integer=True),
        'list': dict(islist=True),
        'tmppath': dict(istmppath=True)
    }
    return get_config(config, section, key, env_var, default,
                      **args[value_type]) 
开发者ID:dmsimard,项目名称:ara-archive,代码行数:32,代码来源:config.py

示例12: v2_playbook_on_start

# 需要导入模块: import ansible [as 别名]
# 或者: from ansible import __version__ [as 别名]
def v2_playbook_on_start(self, playbook):
        path = os.path.abspath(playbook._file_name)
        if self._options is not None:
            options = self._options.__dict__.copy()
        else:
            options = {}

        # Potentially sanitize some user-specified keys
        for parameter in app.config['ARA_IGNORE_PARAMETERS']:
            if parameter in options:
                msg = "Parameter not saved by ARA due to configuration"
                options[parameter] = msg

        LOG.debug('starting playbook %s', path)
        self.playbook = models.Playbook(
            ansible_version=ansible_version,
            path=path,
            options=options
        )

        self.playbook.start()
        db.session.add(self.playbook)
        db.session.commit()

        file_ = self.get_or_create_file(path)
        file_.is_playbook = True

        # We need to persist the playbook id so it can be used by the modules
        data = {
            'playbook': {
                'id': self.playbook.id
            }
        }
        tmpfile = os.path.join(app.config['ARA_TMP_DIR'], 'ara.json')
        with open(tmpfile, 'w') as file:
            file.write(jsonutils.dumps(data)) 
开发者ID:dmsimard,项目名称:ara-archive,代码行数:38,代码来源:log_ara.py

示例13: get_vault_editor

# 需要导入模块: import ansible [as 别名]
# 或者: from ansible import __version__ [as 别名]
def get_vault_editor(vault_password):
        """
        Get the correct VaultEditor object in different Ansible versions
        """
        if LooseVersion(ansible_version) >= LooseVersion("2.4.0"):
            # for Ansible version 2.4.0 or higher
            vault_secrets = [('default', VaultSecret(_bytes=to_bytes(vault_password)))]
            return VaultEditor(VaultLib(vault_secrets))
        else:
            # for Ansible version 2.3.2 or lower
            return VaultEditor(vault_password) 
开发者ID:grycap,项目名称:im,代码行数:13,代码来源:ConfManager.py

示例14: get_play_prereqs

# 需要导入模块: import ansible [as 别名]
# 或者: from ansible import __version__ [as 别名]
def get_play_prereqs(self, options):
        if LooseVersion(ansible_version) >= LooseVersion("2.4.0"):
            # for Ansible version 2.4.0 or higher
            return self.get_play_prereqs_2_4(options)
        else:
            # for Ansible version 2.3.2 or lower
            return self.get_play_prereqs_2(options) 
开发者ID:grycap,项目名称:im,代码行数:9,代码来源:ansible_launcher.py

示例15: _gen_options

# 需要导入模块: import ansible [as 别名]
# 或者: from ansible import __version__ [as 别名]
def _gen_options(self):
        if LooseVersion(ansible_version) >= LooseVersion("2.8.0"):
            from ansible.module_utils.common.collections import ImmutableDict
            from ansible import context
            context.CLIARGS = ImmutableDict(connection='ssh',
                                            module_path=None,
                                            forks=self.threads,
                                            become=False,
                                            become_method='sudo',
                                            become_user='root',
                                            check=False,
                                            diff=False,
                                            inventory=self.inventory_file,
                                            private_key_file=self.pk_file,
                                            remote_user=self.user)

        Options = namedtuple('Options',
                             ['connection',
                              'module_path',
                              'forks',
                              'become',
                              'become_method',
                              'become_user',
                              'check',
                              'diff',
                              'inventory',
                              'private_key_file',
                              'remote_user'])
        options = Options(connection='ssh',
                          module_path=None,
                          forks=self.threads,
                          become=False,
                          become_method='sudo',
                          become_user='root',
                          check=False,
                          diff=False,
                          inventory=self.inventory_file,
                          private_key_file=self.pk_file,
                          remote_user=self.user)
        return options 
开发者ID:grycap,项目名称:im,代码行数:42,代码来源:ansible_launcher.py


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