How to use the molecule.util.safe_dump 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 / test_state.py View on Github external
def test_get_data_loads_existing_state_file(temp_dir, molecule_data):
    molecule_directory = config.molecule_directory(temp_dir.strpath)
    scenario_directory = os.path.join(molecule_directory, 'default')
    molecule_file = config.molecule_file(scenario_directory)
    ephemeral_directory = config.molecule_ephemeral_directory(
        scenario_directory)
    state_file = os.path.join(ephemeral_directory, 'state.yml')

    os.makedirs(ephemeral_directory)

    data = {'converged': False, 'created': True, 'driver': None}
    util.write_file(state_file, util.safe_dump(data))

    pytest.helpers.write_molecule_file(molecule_file, molecule_data)
    c = config.Config(molecule_file)
    s = state.State(c)

    assert not s.converged
    assert s.created
    assert not s.driver
github RebelCodeBase / testaid / testaid / moleculelog.py View on Github external
def print_debug(self):
        testaid_env = \
            {k: v for (k, v) in os.environ.items() if 'TESTVARS_' in k}
        if testaid_env:
            print('\n')
            util.print_debug('TESTVARS ENVIRONMENT',
                             util.safe_dump(testaid_env))
        log = self.get_log()
        if log:
            if not testaid_env:
                print('\n')
            util.print_debug('TESTVARS LOG', log)
github ansible / molecule / test / unit / command / test_base.py View on Github external
def test_get_configs(config_instance):
    molecule_file = config_instance.molecule_file
    data = config_instance.config
    util.write_file(molecule_file, util.safe_dump(data))

    result = base.get_configs({}, {})
    assert 1 == len(result)
    assert isinstance(result, list)
    assert isinstance(result[0], config.Config)
github ansible / molecule / molecule / state.py View on Github external
def _write_state_file(self):
        util.write_file(self.state_file, util.safe_dump(self._data))
github ansible / molecule / molecule / command / list.py View on Github external
def _print_yaml_data(headers, data):  # pragma: no cover
    l = [
        dict(zip(headers, [getattr(datum, field) for field in datum._fields]))
        for datum in data
    ]

    print(util.safe_dump(l))
github ansible / molecule / molecule / provisioner / ansible.py View on Github external
def _write_inventory(self):
        """
        Writes the provisioner's inventory file to disk and returns None.

        :return: None
        """
        self._verify_inventory()

        util.write_file(self.inventory_file, util.safe_dump(self.inventory))