예제 #1
0
import shutil
import os

import ansible.constants as C
from ansible.galaxy import Galaxy
from ansible.galaxy.role import GalaxyRole
from ansible.playbook.role.requirement import RoleRequirement

import ruamel.yaml
from ruamel.yaml.comments import CommentedMap
from .temp import MakeTempDir

from container import exceptions
from container.utils.visibility import getLogger

logger = getLogger(__name__)

ANSIBLE_CONTAINER_PATH = '/src'


class AttrDict(dict):
    def __init__(self, *args, **kwargs):
        super(AttrDict, self).__init__(*args, **kwargs)
        self.__dict__ = self


class InCaseOfFail(object):
    def __init__(self, temp_dir):
        self.temp_dir = temp_dir

    def __enter__(self):
예제 #2
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from container.utils.visibility import getLogger
logger = getLogger(__name__)

import os
from container import exceptions, __version__ as container_version
from ruamel.yaml.comments import CommentedMap
from six import iteritems

try:
    from docker import errors as docker_errors
except ImportError:
    raise ImportError(
        u'You must install Ansible Container with Docker(tm) support. '
        u'Try:\npip install ansible-container==%s[docker]' % container_version)


class DockerSecretsMixin(object):
    """
    Methods needed to simulate external secrets in Docker. Docker Compose does not currently support external secrets.
    We're using the *docker_service* module, which relies on Compose, to launch services, and so it too does not support
    external secrets. Thus the need for these methods until the docker and/or compose Python modules add support for
    secrets of the external variety.
    """

    @property
    def secrets_volume_name(self):
        return "{}_secrets".format(self.project_name)