How to use the molecule.util function in molecule

To help you get started, we’ve selected a few molecule examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ansible / molecule / test / unit / provisioner / test_ansible_playbooks.py View on Github external
def test_get_playbook(tmpdir, _instance):
    x = os.path.join(_instance._config.scenario.directory, 'create.yml')
    util.write_file(x, '')

    assert x == _instance._get_playbook('create')
github ansible / molecule / test / unit / verifier / test_testinfra.py View on Github external
def test_additional_files_or_dirs_property(_instance):
    tests_directory = _instance._config.verifier.directory
    file1_file = os.path.join(tests_directory, 'file1.py')
    file2_file = os.path.join(tests_directory, 'file2.py')
    match1_file = os.path.join(tests_directory, 'match1.py')
    match2_file = os.path.join(tests_directory, 'match2.py')
    test_subdir = os.path.join(tests_directory, 'dir')
    test_subdir_file = os.path.join(test_subdir, 'test_subdir_file.py')

    os.mkdir(tests_directory)
    os.mkdir(test_subdir)
    for f in [file1_file, file2_file, match1_file, match2_file, test_subdir_file]:
        util.write_file(f, '')

    x = [file1_file, file2_file, match1_file, match2_file, test_subdir_file]
    assert sorted(x) == sorted(_instance.additional_files_or_dirs)
github ansible / molecule / test / unit / provisioner / test_ansible_playbooks.py View on Github external
def test_get_ansible_playbook_with_driver_key_when_playbook_key_missing(
    tmpdir, _instance
):
    x = os.path.join(_instance._config.scenario.directory, 'side_effect.yml')
    util.write_file(x, '')

    assert x == _instance._get_playbook('side_effect')
github ansible / molecule / molecule / verifier / lint / precommit.py View on Github external
return

        if self._precommit_command is None:
            self.bake()

        msg = 'Executing pre-commit on files found in {}/...'.format(
            self._config.verifier.directory
        )
        LOG.info(msg)

        try:
            util.run_command(self._precommit_command, debug=self._config.debug)
            msg = 'Lint completed successfully.'
            LOG.success(msg)
        except sh.ErrorReturnCode as e:
            util.sysexit(e.exit_code)
github ansible / molecule / molecule / verifier / serverspec.py View on Github external
def _rake(self,
              rakefile,
              debug=False,
              out=util.callback_info,
              err=util.callback_error):
        """
        Executes rake against specified rakefile and returns a :func:`sh`
        response object.

        :param rakefile: A string containing path to the rakefile.
        :param debug: An optional bool to toggle debug output.
        :param out: An optional function to process STDOUT for underlying
         :func:`sh` call.
        :param err: An optional function to process STDERR for underlying
         :func:`sh` call.
        :return: :func:`sh` response object.
        """
        kwargs = {
            '_out': out,
            '_err': err,
github ansible / molecule / molecule / provisioner / ansible / plugins / modules / molecule_vagrant.py View on Github external
'raw_config_args': self._module.params['instance_raw_config_args'],
            },
            'provider': {
                'name': self._module.params['provider_name'],
                # NOTE(retr0h): Options provided here will be passed to
                # Vagrant as "$provider_name.#{key} = #{value}".
                'options': {
                    'memory': self._module.params['provider_memory'],
                    'cpus': self._module.params['provider_cpus'],
                },
                'raw_config_args': self._module.params['provider_raw_config_args'],
                'override_args': self._module.params['provider_override_args'],
            },
        }

        molecule.util.merge_dicts(
            d['config']['options'], self._module.params['config_options']
        )

        molecule.util.merge_dicts(
            d['provider']['options'], self._module.params['provider_options']
        )

        return d
github ansible / molecule / molecule / dependency / gilt.py View on Github external
def default_env(self):
        return util.merge_dicts(os.environ, self._config.env)