diff --git a/examples/flask-web-app/salt/testrunner/testrunner_layer.py b/examples/flask-web-app/salt/testrunner/testrunner_layer.py index f83b737..c838b53 100644 --- a/examples/flask-web-app/salt/testrunner/testrunner_layer.py +++ b/examples/flask-web-app/salt/testrunner/testrunner_layer.py @@ -32,7 +32,7 @@ def do_run(self, namespace): namespace.logger.info( "Running tests: type=%s, environment=%r", test_type, environment) container_id = self.docker_create_container( - namespace, None, self.source_image_name, environment=environment) + namespace, None, None, self.source_image_name, environment=environment) self.docker_start(namespace, container_id) cmd = ["/venv/bin/py.test", "--tb=long", test_dir] diff --git a/examples/nginx-grains-centos/README.md b/examples/nginx-grains-centos/README.md new file mode 100644 index 0000000..3b1205d --- /dev/null +++ b/examples/nginx-grains-centos/README.md @@ -0,0 +1,6 @@ +Example States +============== + +Simple example of configuration of a nginx server where the config file for nginx is a jinja template drawing from custom Grains (https://docs.saltstack.com/en/latest/topics/grains/index.html#writing-grains). + +Please keep in mind default path to custom Grains directory: /srv/salt/_grains \ No newline at end of file diff --git a/examples/nginx-grains-centos/flyingcloud.yaml b/examples/nginx-grains-centos/flyingcloud.yaml new file mode 100644 index 0000000..3eb2494 --- /dev/null +++ b/examples/nginx-grains-centos/flyingcloud.yaml @@ -0,0 +1,8 @@ +app_name: 'nginx-grains-centos' +description: 'Sample Test app for FlyingCloud with custom Grains support' +layers: + - nginx + - sysbase +grains: + - dev + - qa diff --git a/examples/nginx-grains-centos/grains/dev/mygrains.py b/examples/nginx-grains-centos/grains/dev/mygrains.py new file mode 100644 index 0000000..cfe94b9 --- /dev/null +++ b/examples/nginx-grains-centos/grains/dev/mygrains.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +def _my_custom_grain(): + my_grain = { + 'server_name': 'webhost-dev.domain.com', + 'log_prefix': 'webhost-dev_domain_com', + 'backend_server': 'apphost-dev.domain.com' + } + return my_grain + +def main(): + # initialize a grains dictionary + grains = {} + grains['my_grains'] = _my_custom_grain() + return grains diff --git a/examples/nginx-grains-centos/grains/qa/mygrains.py b/examples/nginx-grains-centos/grains/qa/mygrains.py new file mode 100644 index 0000000..2649b81 --- /dev/null +++ b/examples/nginx-grains-centos/grains/qa/mygrains.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +def _my_custom_grain(): + my_grain = { + 'server_name': 'webhost-qa.domain.com', + 'log_prefix': 'webhost-qa_domain_com', + 'backend_server': 'apphost-qa.domain.com' + } + return my_grain + +def main(): + # initialize a grains dictionary + grains = {} + grains['my_grains'] = _my_custom_grain() + return grains diff --git a/examples/nginx-grains-centos/salt/nginx/files/my_vhost_conf.jinja b/examples/nginx-grains-centos/salt/nginx/files/my_vhost_conf.jinja new file mode 100644 index 0000000..72797f1 --- /dev/null +++ b/examples/nginx-grains-centos/salt/nginx/files/my_vhost_conf.jinja @@ -0,0 +1,11 @@ +upstream backend { + server {{ backend_server }}; +} + +server { + listen 80; + server_name {{ server_name }}; + root /var/www; + + access_log /var/log/nginx/{{ log_prefix }}_http.log; +} diff --git a/examples/nginx-grains-centos/salt/nginx/init.sls b/examples/nginx-grains-centos/salt/nginx/init.sls new file mode 100644 index 0000000..4c3d2ce --- /dev/null +++ b/examples/nginx-grains-centos/salt/nginx/init.sls @@ -0,0 +1,19 @@ +nginx: + pkg: + - latest + service.running: + - enable: True + +/etc/nginx/conf.d/my_vhost.conf: + file.managed: + - source: salt://files/my_vhost_conf.jinja + - template: jinja + - require: + - pkg: nginx + - user: root + - group: root + - mode: 644 + - context: + {{ salt['grains.get']('my_grains') }} + - watch_in: + - service: nginx diff --git a/examples/nginx-grains-centos/salt/nginx/layer.yaml b/examples/nginx-grains-centos/salt/nginx/layer.yaml new file mode 100644 index 0000000..3a7e108 --- /dev/null +++ b/examples/nginx-grains-centos/salt/nginx/layer.yaml @@ -0,0 +1,5 @@ +help: nginx layer +description: > + Nginx layer +parent: sysbase +grains: dev diff --git a/examples/nginx-grains-centos/salt/nginx/top.sls b/examples/nginx-grains-centos/salt/nginx/top.sls new file mode 100644 index 0000000..a966bc0 --- /dev/null +++ b/examples/nginx-grains-centos/salt/nginx/top.sls @@ -0,0 +1,3 @@ +base: + '*': + - init diff --git a/examples/nginx-grains-centos/salt/sysbase/Dockerfile b/examples/nginx-grains-centos/salt/sysbase/Dockerfile new file mode 100644 index 0000000..445dcac --- /dev/null +++ b/examples/nginx-grains-centos/salt/sysbase/Dockerfile @@ -0,0 +1,15 @@ +FROM centos:centos6 + +CMD ["/sbin/init"] + +# Add EPEL repository +RUN yum -y install epel-release + +# Install salt and deps +RUN yum -y install salt-minion python2-gnupg cronie + +# SaltStack fail hard if any state fails +RUN echo "failhard: True" >> /etc/salt/minion + +# Clean up YUM when done. +RUN yum clean all && rm -rf /tmp/* /var/tmp/* diff --git a/examples/nginx-grains-centos/salt/sysbase/layer.yaml b/examples/nginx-grains-centos/salt/sysbase/layer.yaml new file mode 100644 index 0000000..58c1b4c --- /dev/null +++ b/examples/nginx-grains-centos/salt/sysbase/layer.yaml @@ -0,0 +1,5 @@ +help: Operating System Base Layer +description: > + System base layer + (CentOS 6.8 with salt-minion) + diff --git a/examples/nginx-grains/README.md b/examples/nginx-grains/README.md new file mode 100644 index 0000000..3b1205d --- /dev/null +++ b/examples/nginx-grains/README.md @@ -0,0 +1,6 @@ +Example States +============== + +Simple example of configuration of a nginx server where the config file for nginx is a jinja template drawing from custom Grains (https://docs.saltstack.com/en/latest/topics/grains/index.html#writing-grains). + +Please keep in mind default path to custom Grains directory: /srv/salt/_grains \ No newline at end of file diff --git a/examples/nginx-grains/flyingcloud.yaml b/examples/nginx-grains/flyingcloud.yaml new file mode 100644 index 0000000..c66bbac --- /dev/null +++ b/examples/nginx-grains/flyingcloud.yaml @@ -0,0 +1,8 @@ +app_name: 'nginx-grains' +description: 'Sample Test app for FlyingCloud with custom Grains support' +layers: + - nginx + - sysbase +grains: + - dev + - qa diff --git a/examples/nginx-grains/grains/dev/mygrains.py b/examples/nginx-grains/grains/dev/mygrains.py new file mode 100644 index 0000000..cfe94b9 --- /dev/null +++ b/examples/nginx-grains/grains/dev/mygrains.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +def _my_custom_grain(): + my_grain = { + 'server_name': 'webhost-dev.domain.com', + 'log_prefix': 'webhost-dev_domain_com', + 'backend_server': 'apphost-dev.domain.com' + } + return my_grain + +def main(): + # initialize a grains dictionary + grains = {} + grains['my_grains'] = _my_custom_grain() + return grains diff --git a/examples/nginx-grains/grains/qa/mygrains.py b/examples/nginx-grains/grains/qa/mygrains.py new file mode 100644 index 0000000..2649b81 --- /dev/null +++ b/examples/nginx-grains/grains/qa/mygrains.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +def _my_custom_grain(): + my_grain = { + 'server_name': 'webhost-qa.domain.com', + 'log_prefix': 'webhost-qa_domain_com', + 'backend_server': 'apphost-qa.domain.com' + } + return my_grain + +def main(): + # initialize a grains dictionary + grains = {} + grains['my_grains'] = _my_custom_grain() + return grains diff --git a/examples/nginx-grains/salt/nginx/files/my_vhost_conf.jinja b/examples/nginx-grains/salt/nginx/files/my_vhost_conf.jinja new file mode 100644 index 0000000..72797f1 --- /dev/null +++ b/examples/nginx-grains/salt/nginx/files/my_vhost_conf.jinja @@ -0,0 +1,11 @@ +upstream backend { + server {{ backend_server }}; +} + +server { + listen 80; + server_name {{ server_name }}; + root /var/www; + + access_log /var/log/nginx/{{ log_prefix }}_http.log; +} diff --git a/examples/nginx-grains/salt/nginx/init.sls b/examples/nginx-grains/salt/nginx/init.sls new file mode 100644 index 0000000..18900c0 --- /dev/null +++ b/examples/nginx-grains/salt/nginx/init.sls @@ -0,0 +1,20 @@ +nginx: + pkg: + - name: nginx-full + - latest + service.running: + - enable: True + +/etc/nginx/sites-enabled/my_vhost.conf: + file.managed: + - source: salt://files/my_vhost_conf.jinja + - template: jinja + - require: + - pkg: nginx + - user: root + - group: root + - mode: 644 + - context: + {{ salt['grains.get']('my_grains') }} + - watch_in: + - service: nginx diff --git a/examples/nginx-grains/salt/nginx/layer.yaml b/examples/nginx-grains/salt/nginx/layer.yaml new file mode 100644 index 0000000..3a7e108 --- /dev/null +++ b/examples/nginx-grains/salt/nginx/layer.yaml @@ -0,0 +1,5 @@ +help: nginx layer +description: > + Nginx layer +parent: sysbase +grains: dev diff --git a/examples/nginx-grains/salt/nginx/top.sls b/examples/nginx-grains/salt/nginx/top.sls new file mode 100644 index 0000000..a966bc0 --- /dev/null +++ b/examples/nginx-grains/salt/nginx/top.sls @@ -0,0 +1,3 @@ +base: + '*': + - init diff --git a/examples/nginx-grains/salt/sysbase/Dockerfile b/examples/nginx-grains/salt/sysbase/Dockerfile new file mode 100644 index 0000000..3619028 --- /dev/null +++ b/examples/nginx-grains/salt/sysbase/Dockerfile @@ -0,0 +1,21 @@ +# FlyingCloud base image - phusion/baseimage + SaltStack +# Note: never use :latest, always use a numbered release tag. +FROM phusion/baseimage:0.9.18 +MAINTAINER MetaBrite, Inc. + +# Use baseimage-docker's init system. +CMD ["/sbin/my_init"] + +# After the image is built, we will use salt, mounted via docker run. + +# Update the sources list +RUN apt-get update + +# Install salt and basic applications +RUN apt-get install -y tar git vim nano wget net-tools build-essential salt-minion + +# SaltStack fail hard if any state fails +RUN echo "failhard: True" >> /etc/salt/minion + +# Clean up APT when done. +RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/examples/nginx-grains/salt/sysbase/layer.yaml b/examples/nginx-grains/salt/sysbase/layer.yaml new file mode 100644 index 0000000..a66057e --- /dev/null +++ b/examples/nginx-grains/salt/sysbase/layer.yaml @@ -0,0 +1,6 @@ +help: Operating System Base Layer +description: > + System base layer + (Phusion Ubuntu 14.04 with Salt, build-essential, + various debugging tools) + diff --git a/examples/nginx-pillar/README.md b/examples/nginx-pillar/README.md new file mode 100644 index 0000000..2dc2528 --- /dev/null +++ b/examples/nginx-pillar/README.md @@ -0,0 +1,10 @@ +Example States +============== + +In the example states and pillar, there is some simply example of configuration of a nginx server where the config file for nginx is a jinja template drawing from pillar. + +Based on the way Flyingcloud is called, I'm curious to know if it would be possible to allow for the targetting of pillar data when building a container. This might perhaps be done by being able to call flyingcloud with a a targetted config yaml? e.g. + + flyingcloud -c dev.yaml + +If this were available as an option then it would be possible in a CI situation to programmatically target pillar data when building a container. \ No newline at end of file diff --git a/examples/nginx-pillar/flyingcloud.yaml b/examples/nginx-pillar/flyingcloud.yaml new file mode 100644 index 0000000..00644fb --- /dev/null +++ b/examples/nginx-pillar/flyingcloud.yaml @@ -0,0 +1,18 @@ +app_name: 'nginx_pillar' +description: 'Sample Nginx App With Pillar Support' +layers: + - sysbase + - nginx +pillars: + - dev + - qa + +registry: + host: quay.io + organization: cookbrite + docker_api_version: "1.17" + login_required: false + pull_layer: false + push_layer: false + squash_layer: false + diff --git a/examples/nginx-pillar/pillar/dev/nginx.sls b/examples/nginx-pillar/pillar/dev/nginx.sls new file mode 100644 index 0000000..ec67a93 --- /dev/null +++ b/examples/nginx-pillar/pillar/dev/nginx.sls @@ -0,0 +1,4 @@ +nginx: + server_name: dev.server.com + log_prefix: dev_server_com + backend_server: dev-myapp.server.com diff --git a/examples/nginx-pillar/pillar/dev/top.sls b/examples/nginx-pillar/pillar/dev/top.sls new file mode 100644 index 0000000..928ece9 --- /dev/null +++ b/examples/nginx-pillar/pillar/dev/top.sls @@ -0,0 +1,3 @@ +base: + '*': + - nginx \ No newline at end of file diff --git a/examples/nginx-pillar/pillar/qa/nginx.sls b/examples/nginx-pillar/pillar/qa/nginx.sls new file mode 100644 index 0000000..329662c --- /dev/null +++ b/examples/nginx-pillar/pillar/qa/nginx.sls @@ -0,0 +1,4 @@ +nginx: + server_name: qa.server.com + log_prefix: qa + backend_server: qa-myapp.server.com diff --git a/examples/nginx-pillar/pillar/qa/top.sls b/examples/nginx-pillar/pillar/qa/top.sls new file mode 100644 index 0000000..9c26224 --- /dev/null +++ b/examples/nginx-pillar/pillar/qa/top.sls @@ -0,0 +1,4 @@ +base: + '*': + - nginx + diff --git a/examples/nginx-pillar/salt/nginx/config.sls b/examples/nginx-pillar/salt/nginx/config.sls new file mode 100644 index 0000000..1f741f4 --- /dev/null +++ b/examples/nginx-pillar/salt/nginx/config.sls @@ -0,0 +1,13 @@ +my_config: + file.managed: + - name: /etc/nginx/sites-enabled/my_vhost.conf + - user: root + - group: root + - mode: 644 + - source: salt://files/my_vhost_conf.jinja + - template: jinja + - context: + {{ salt['pillar.get']('nginx') }} + - require: + - pkg: nginx + diff --git a/examples/nginx-pillar/salt/nginx/files/my_vhost_conf.jinja b/examples/nginx-pillar/salt/nginx/files/my_vhost_conf.jinja new file mode 100644 index 0000000..72797f1 --- /dev/null +++ b/examples/nginx-pillar/salt/nginx/files/my_vhost_conf.jinja @@ -0,0 +1,11 @@ +upstream backend { + server {{ backend_server }}; +} + +server { + listen 80; + server_name {{ server_name }}; + root /var/www; + + access_log /var/log/nginx/{{ log_prefix }}_http.log; +} diff --git a/examples/nginx-pillar/salt/nginx/install.sls b/examples/nginx-pillar/salt/nginx/install.sls new file mode 100644 index 0000000..d283904 --- /dev/null +++ b/examples/nginx-pillar/salt/nginx/install.sls @@ -0,0 +1,4 @@ +nginx: + pkg: + - name: nginx-full + - installed \ No newline at end of file diff --git a/examples/nginx-pillar/salt/nginx/layer.yaml b/examples/nginx-pillar/salt/nginx/layer.yaml new file mode 100644 index 0000000..cf8b2ac --- /dev/null +++ b/examples/nginx-pillar/salt/nginx/layer.yaml @@ -0,0 +1,6 @@ +help: nginx layer +description: > + Nginx layer +parent: sysbase +pillar: dev + diff --git a/examples/nginx-pillar/salt/nginx/top.sls b/examples/nginx-pillar/salt/nginx/top.sls new file mode 100644 index 0000000..1380249 --- /dev/null +++ b/examples/nginx-pillar/salt/nginx/top.sls @@ -0,0 +1,4 @@ +base: + '*': + - install + - config \ No newline at end of file diff --git a/examples/nginx-pillar/salt/sysbase/Dockerfile b/examples/nginx-pillar/salt/sysbase/Dockerfile new file mode 100644 index 0000000..3619028 --- /dev/null +++ b/examples/nginx-pillar/salt/sysbase/Dockerfile @@ -0,0 +1,21 @@ +# FlyingCloud base image - phusion/baseimage + SaltStack +# Note: never use :latest, always use a numbered release tag. +FROM phusion/baseimage:0.9.18 +MAINTAINER MetaBrite, Inc. + +# Use baseimage-docker's init system. +CMD ["/sbin/my_init"] + +# After the image is built, we will use salt, mounted via docker run. + +# Update the sources list +RUN apt-get update + +# Install salt and basic applications +RUN apt-get install -y tar git vim nano wget net-tools build-essential salt-minion + +# SaltStack fail hard if any state fails +RUN echo "failhard: True" >> /etc/salt/minion + +# Clean up APT when done. +RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/examples/nginx-pillar/salt/sysbase/layer.yaml b/examples/nginx-pillar/salt/sysbase/layer.yaml new file mode 100644 index 0000000..a66057e --- /dev/null +++ b/examples/nginx-pillar/salt/sysbase/layer.yaml @@ -0,0 +1,6 @@ +help: Operating System Base Layer +description: > + System base layer + (Phusion Ubuntu 14.04 with Salt, build-essential, + various debugging tools) + diff --git a/flyingcloud/base.py b/flyingcloud/base.py index 15a0024..4de04e5 100644 --- a/flyingcloud/base.py +++ b/flyingcloud/base.py @@ -90,18 +90,27 @@ def __init__( help, description=None, container_name=None, + container_hostname=None, exposed_ports=None, registry_config=None, source_version_tag="latest", - environment=None + environment=None, + pillar=None, + grains=None, ): self.app_name = app_name self.layer_name = layer_name + self.container_hostname = container_hostname self.source_image_base_name = source_image_base_name self.help = help self.description = description self.exposed_ports = exposed_ports or [] self.environment = environment + self.pillar = pillar + self.grains = grains + self.base_dir = None + self.pillar_dir = None + self.grains_dir = None config = self.RegistryConfig.copy() if registry_config: @@ -144,6 +153,26 @@ def check_user_is_root(cls): if platform.system() == "Linux" and os.geteuid() != 0 : raise NotSudoError("You must be root (use sudo)") + def set_pillar(self, namespace): + pillar = namespace.pillar or self.pillar + self.base_dir = namespace.base_dir + if pillar: + self.pillar = pillar + pillar_basedir = os.path.join(self.base_dir, 'pillar') + self.pillar_dir = os.path.join(pillar_basedir, self.pillar) + self.docker_layer_name = "{}_{}".format(self.docker_layer_name, pillar) + namespace.logger.info("Using pillar '{}' and setting pillar_dir to '{}'.".format(self.pillar, self.pillar_dir)) + + def set_grains(self, namespace): + grains = namespace.grains or self.grains + self.base_dir = namespace.base_dir + if grains: + self.grains = grains + grains_basedir = os.path.join(self.base_dir, 'grains') + self.grains_dir = os.path.join(grains_basedir, self.grains) + self.docker_layer_name = "{}_{}".format(self.docker_layer_name, grains) + namespace.logger.info("Using custom grains '{}' and setting grains_dir to '{}'.".format(self.grains, self.grains_dir)) + def check_environment_variables(self, namespace): cfg = self.registry_config if cfg['host'] and cfg['login_required'] and not cfg['aws_ecr_region']: @@ -161,6 +190,7 @@ def do_run(self, namespace): target_container_name = self.docker_create_container( namespace, self.container_name, + self.container_hostname, self.layer_latest_name, environment=self.make_environment(namespace.env_vars, self.environment)) self.docker_start(namespace, target_container_name) @@ -232,6 +262,7 @@ def build(self, namespace): self.layer_squashed_name = "{}-sq".format(self.layer_timestamp_name) self.initialize_build(namespace, salt_dir) + namespace.logger.info("Building docker layer '{}' with tag '{}'.".format(self.layer_name, self.docker_layer_name)) if (namespace.pull_layer and self.registry_config['pull_layer'] @@ -247,7 +278,7 @@ def build(self, namespace): self.make_expose_ports(namespace) target_container_name = self.salt_highstate( - namespace, self.container_name, + namespace, self.container_name, self.container_hostname, source_image_name=self.source_image_name, result_image_name=self.layer_timestamp_name, salt_dir=salt_dir) @@ -286,6 +317,7 @@ def salt_highstate( self, namespace, container_name, + container_hostname, source_image_name, result_image_name, salt_dir, timeout=SaltExecTimeout): @@ -300,11 +332,19 @@ def salt_highstate( error, commit = None, True target_container_name = None + volume_map = { + salt_dir: "/srv/salt", + } + if self.pillar_dir: + volume_map[self.pillar_dir] = "/srv/pillar" + if self.grains_dir: + volume_map[self.grains_dir] = "/srv/salt/_grains" try: target_container_name = self.docker_create_container( - namespace, container_name, source_image_name, + namespace, container_name, container_hostname, source_image_name, environment=self.make_environment(namespace.env_vars, self.environment), - volume_map={salt_dir: "/srv/salt"}) + volume_map=volume_map + ) self.docker_start(namespace, target_container_name) @@ -466,7 +506,7 @@ def build_dockerfile(self, namespace, tag, dockerfile=None, fileobj=None): return image_id def docker_create_container( - self, namespace, container_name, image_name, + self, namespace, container_name, container_hostname, image_name, environment=None, detach=True, volume_map=None, **kwargs): namespace.logger.info("Creating container '%s' from image %s", container_name, image_name) @@ -480,6 +520,7 @@ def docker_create_container( kwargs['environment'] = environment kwargs['detach'] = detach kwargs['ports'] = self.container_ports(self.exposed_ports) + kwargs['hostname'] = container_hostname kwargs.update(self.docker_host_config(namespace, volume_map)) namespace.logger.info("create_container: %r", kwargs) @@ -766,6 +807,11 @@ def parse_args(self, defaults, *layer_classes, **kwargs): defaults = defaults or {} defaults.setdefault('base_dir', os.path.abspath(os.path.dirname(__file__))) defaults.setdefault('salt_dir', os.path.join(defaults['base_dir'], "salt")) + defaults.setdefault('pillar_dir', None) + defaults.setdefault('pillar', None) + defaults.setdefault('grains_dir', None) + defaults.setdefault('grains', None) + defaults.setdefault('hostname', None) defaults.setdefault('logfile', os.path.join(defaults['base_dir'], "flyingcloud.log")) defaults.setdefault('docker_tagsfile', os.path.join(defaults['base_dir'], "docker_tags.json")) defaults.setdefault('timestamp_format', '%Y-%m-%dt%H%M%Sz') @@ -831,6 +877,16 @@ def parse_args(self, defaults, *layer_classes, **kwargs): parser.add_argument( '--email', '-e', help="Email address for Docker registry. Default: %(default)r") + parser.add_argument( + '--pillar', '-l', dest='pillar', type=str, + help="Specify pillar to use for this layer. Default: %(default)r") + parser.add_argument( + '--grains', '-g', dest='grains', type=str, + help="Specify custom grains to use for this layer. Default: %(default)r") + parser.add_argument( + '--hostname', '-n', dest='hostname', type=str, + help="Specify hostname to use for this layer. Default: %(default)r") + if self.docker_machine_platform(): parser.add_argument( @@ -898,6 +954,7 @@ def parse_args(self, defaults, *layer_classes, **kwargs): self.add_additional_configuration(namespace) + namespace.base_dir = defaults['base_dir'] return namespace @classmethod diff --git a/flyingcloud/main.py b/flyingcloud/main.py index 7b456c5..a7e57df 100755 --- a/flyingcloud/main.py +++ b/flyingcloud/main.py @@ -28,7 +28,10 @@ def get_layer(app_name, layer_name, layer_data, registry_config): description = layer_info.get('description') exposed_ports = layer_info.get('exposed_ports') container_name = layer_info.get('image_name') + container_hostname = layer_info.get('hostname') environment = layer_info.get('environment') + pillar = layer_info.get('pillar') + grains = layer_info.get('grains') layer = layer_class( app_name=app_name, @@ -37,9 +40,12 @@ def get_layer(app_name, layer_name, layer_data, registry_config): help=help, description=description, container_name=container_name, + container_hostname=container_hostname, exposed_ports=exposed_ports, registry_config=registry_config, environment=environment, + pillar=pillar, + grains=grains, ) # print(layer.__dict__) @@ -108,8 +114,12 @@ def main(): namespace = instance.parse_args( defaults, *layers, - description=project_info['description']) + description=project_info['description'] + ) instance.check_environment_variables(namespace) + for layer in layers: + layer.set_pillar(namespace) + layer.set_grains(namespace) instance = namespace.layer_inst instance.do_operation(namespace)