How to use the molecule.logger.get_logger 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_logger.py View on Github external
def test_error(capsys):
    log = logger.get_logger(__name__)
    log.error('foo')

    _, stderr = capsys.readouterr()

    print(
        '{}{}{}'.format(colorama.Fore.RED, 'foo'.rstrip(), colorama.Style.RESET_ALL),
        file=sys.stderr,
    )
    _, x = capsys.readouterr()

    assert x in stderr
github ansible / molecule / molecule / config.py View on Github external
from molecule import api
from molecule import interpolation
from molecule import logger
from molecule import platforms
from molecule import scenario
from molecule import state
from molecule import util
from molecule.dependency import ansible_galaxy
from molecule.dependency import gilt
from molecule.dependency import shell
from molecule.lint import yamllint
from molecule.model import schema_v2
from molecule.provisioner import ansible


LOG = logger.get_logger(__name__)
MOLECULE_DEBUG = boolean(os.environ.get('MOLECULE_DEBUG', 'False'))
MOLECULE_DIRECTORY = 'molecule'
MOLECULE_FILE = 'molecule.yml'
MOLECULE_KEEP_STRING = 'MOLECULE_'


# https://stackoverflow.com/questions/16017397/injecting-function-call-after-init-with-decorator  # noqa
class NewInitCaller(type):
    def __call__(cls, *args, **kwargs):
        obj = type.__call__(cls, *args, **kwargs)
        obj.after_init()
        return obj


@six.add_metaclass(NewInitCaller)
class Config(object):
github ansible / molecule / molecule / driver / hetznercloud.py View on Github external
#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#  DEALINGS IN THE SOFTWARE.

import os

from molecule import logger, util
from molecule.api import Driver
from molecule.util import lru_cache
from molecule.util import sysexit_with_message

log = logger.get_logger(__name__)


class HetznerCloud(Driver):
    """
    The class responsible for managing `Hetzner Cloud`_ instances.
    `Hetzner Cloud`_ is **not** the default driver used in Molecule.

    Molecule leverages Ansible's `hcloud_server module`_, by mapping variables
    from ``molecule.yml`` into ``create.yml`` and ``destroy.yml``.

    .. important::

        The ``hcloud_server`` module is only available in Ansible >= 2.8.

    .. _`hcloud_server module`: https://docs.ansible.com/ansible/devel/modules/hcloud_server_module.html#hcloud-server-module
github ansible / molecule / molecule / driver / openstack.py View on Github external
#  all copies or substantial portions of the Software.
#
#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#  DEALINGS IN THE SOFTWARE.

from molecule import logger
from molecule.api import Driver

from molecule import util

LOG = logger.get_logger(__name__)


class Openstack(Driver):
    """
    The class responsible for managing `OpenStack`_ instances.  `OpenStack`_
    is `not` the default driver used in Molecule.

    Molecule leverages Ansible's `openstack_module`_, by mapping variables
    from ``molecule.yml`` into ``create.yml`` and ``destroy.yml``.

    .. _`openstack_module`: https://docs.ansible.com/ansible/latest/os_server_module.html

    .. code-block:: yaml

        driver:
          name: openstack
github ansible / molecule / molecule / driver / docker.py View on Github external
#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#  DEALINGS IN THE SOFTWARE.

from __future__ import absolute_import

import os

from molecule import logger
from molecule.api import Driver
from molecule.util import lru_cache
from molecule.util import sysexit_with_message

log = logger.get_logger(__name__)


class Docker(Driver):
    """
    The class responsible for managing `Docker`_ containers.  `Docker`_ is
    the default driver used in Molecule.

    Molecule leverages Ansible's `docker_container`_ module, by mapping
    variables from ``molecule.yml`` into ``create.yml`` and ``destroy.yml``.

    .. _`docker_container`: https://docs.ansible.com/ansible/latest/docker_container_module.html
    .. _`Docker Security Configuration`: https://docs.docker.com/engine/reference/run/#security-configuration
    .. _`Docker daemon socket options`: https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-socket-option

    .. code-block:: yaml
github ansible / molecule / molecule / command / matrix.py View on Github external
#
#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#  DEALINGS IN THE SOFTWARE.

import click

from molecule import logger
from molecule import scenarios
from molecule.command import base

LOG = logger.get_logger(__name__)


class Matrix(base.Base):
    """
    .. program:: molecule matrix subcommand

    .. option:: molecule matrix subcommand

        Target the default scenario.

    .. program:: molecule matrix --scenario-name foo subcommand

    .. option:: molecule matrix --scenario-name foo subcommand

        Targeting a specific scenario.
github ansible / molecule / molecule / command / side_effect.py View on Github external
#  all copies or substantial portions of the Software.
#
#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#  DEALINGS IN THE SOFTWARE.

import click

from molecule import logger
from molecule.command import base

LOG = logger.get_logger(__name__)


class SideEffect(base.Base):
    """
    This action has side effects and not enabled by default.   See the
    provisioners documentation for further details.

    .. program:: molecule side-effect

    .. option:: molecule side-effect

        Target the default scenario.

    .. program:: molecule side-effect --scenario-name foo

    .. option:: molecule side-effect --scenario-name foo
github ansible / molecule / molecule / command / cleanup.py View on Github external
#  all copies or substantial portions of the Software.
#
#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#  DEALINGS IN THE SOFTWARE.

import click

from molecule import logger
from molecule.command import base

LOG = logger.get_logger(__name__)


class Cleanup(base.Base):
    """
    This action has cleanup and is not enabled by default.
    See the provisioner's documentation for further details.

    .. program:: molecule cleanup

    .. option:: molecule cleanup

        Target the default scenario.

    .. program:: molecule cleanup --scenario-name foo

    .. option:: molecule cleanup --scenario-name foo
github ansible / molecule / molecule / command / destroy.py View on Github external
#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#  DEALINGS IN THE SOFTWARE.

import os
import click

from molecule import logger
from molecule.api import drivers
from molecule.command import base
from molecule import util

LOG = logger.get_logger(__name__)
MOLECULE_PARALLEL = os.environ.get('MOLECULE_PARALLEL', False)


class Destroy(base.Base):
    """
    .. program:: molecule destroy

    .. option:: molecule destroy

        Target the default scenario.

    .. program:: molecule destroy --scenario-name foo

    .. option:: molecule destroy --scenario-name foo

        Targeting a specific scenario.