How to use the molecule.util.merge_dicts 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 / molecule / verifier / testinfra.py View on Github external
def default_env(self):
        env = util.merge_dicts(os.environ, self._config.env)
        env = util.merge_dicts(env, self._config.provisioner.env)

        return env
github ansible / molecule / test / unit / test_util.py View on Github external
def test_merge_dicts():
    # example taken from python-anyconfig/anyconfig/__init__.py
    a = {'b': [{'c': 0}, {'c': 2}], 'd': {'e': 'aaa', 'f': 3}}
    b = {'a': 1, 'b': [{'c': 3}], 'd': {'e': 'bbb'}}
    x = {'a': 1, 'b': [{'c': 3}], 'd': {'e': "bbb", 'f': 3}}

    assert x == util.merge_dicts(a, b)
github ansible / molecule / molecule / provisioner / ansible / plugins / modules / molecule_vagrant.py View on Github external
# 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 / ansible_galaxy.py View on Github external
def options(self):
        o = self._config.config['dependency']['options']
        # NOTE(retr0h): Remove verbose options added by the user while in
        # debug.
        if self._config.debug:
            o = util.filter_verbose_permutation(o)

        return util.merge_dicts(self.default_options, o)
github ansible / molecule / molecule / driver / openstack.py View on Github external
def login_options(self, instance_name):
        d = {'instance': instance_name}

        return util.merge_dicts(d, self._get_instance_config(instance_name))
github ansible / molecule / molecule / lint / yamllint.py View on Github external
def default_env(self):
        return util.merge_dicts(os.environ, self._config.env)
github ansible / molecule / molecule / config.py View on Github external
def _reget_config(self):
        """
        Perform the same prioritized recursive merge from `get_config`, this
        time, interpolating the ``keep_string`` left behind in the original
        ``get_config`` call.  This is probably __very__ bad.

        :return: dict
        """
        env = util.merge_dicts(os.environ, self.env)
        env = set_env_from_file(env, self.env_file)

        return self._combine(env=env)
github ansible / molecule / molecule / driver / delegated.py View on Github external
def login_options(self, instance_name):
        if self.managed:
            d = {'instance': instance_name}

            return util.merge_dicts(d, self._get_instance_config(instance_name))
        return {'instance': instance_name}
github ansible / molecule / molecule / config.py View on Github external
base_config = self.args.get('base_config')
        if base_config and os.path.exists(base_config):
            with util.open_file(base_config) as stream:
                s = stream.read()
                self._preflight(s)
                interpolated_config = self._interpolate(s, env, keep_string)
                defaults = util.merge_dicts(
                    defaults, util.safe_load(interpolated_config)
                )

        if self.molecule_file:
            with util.open_file(self.molecule_file) as stream:
                s = stream.read()
                self._preflight(s)
                interpolated_config = self._interpolate(s, env, keep_string)
                defaults = util.merge_dicts(
                    defaults, util.safe_load(interpolated_config)
                )

        return defaults
github ansible / molecule / molecule / model / schema_v2.py View on Github external
def validate(c):
    schema = base_schema

    # Dependency
    if c['dependency']['name'] == 'shell':
        schema = util.merge_dicts(schema, dependency_command_nullable_schema)

    # Driver
    if c['driver']['name'] == 'docker':
        schema = util.merge_dicts(schema, platforms_docker_schema)
    elif c['driver']['name'] == 'podman':
        schema = util.merge_dicts(schema, platforms_podman_schema)

    # Verifier
    schema = util.merge_dicts(schema, api.verifiers()[c['verifier']['name']].schema())

    v = Validator(allow_unknown=True)
    v.validate(c, schema)

    return v.errors