Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/flask-web-app/salt/testrunner/testrunner_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 6 additions & 0 deletions examples/nginx-grains-centos/README.md
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions examples/nginx-grains-centos/flyingcloud.yaml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions examples/nginx-grains-centos/grains/dev/mygrains.py
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions examples/nginx-grains-centos/grains/qa/mygrains.py
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions examples/nginx-grains-centos/salt/nginx/files/my_vhost_conf.jinja
Original file line number Diff line number Diff line change
@@ -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;
}
19 changes: 19 additions & 0 deletions examples/nginx-grains-centos/salt/nginx/init.sls
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions examples/nginx-grains-centos/salt/nginx/layer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
help: nginx layer
description: >
Nginx layer
parent: sysbase
grains: dev
3 changes: 3 additions & 0 deletions examples/nginx-grains-centos/salt/nginx/top.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
base:
'*':
- init
15 changes: 15 additions & 0 deletions examples/nginx-grains-centos/salt/sysbase/Dockerfile
Original file line number Diff line number Diff line change
@@ -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/*
5 changes: 5 additions & 0 deletions examples/nginx-grains-centos/salt/sysbase/layer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
help: Operating System Base Layer
description: >
System base layer
(CentOS 6.8 with salt-minion)

6 changes: 6 additions & 0 deletions examples/nginx-grains/README.md
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions examples/nginx-grains/flyingcloud.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
app_name: 'nginx-grains'
description: 'Sample Test app for FlyingCloud with custom Grains support'
layers:
- nginx
- sysbase
grains:
- dev
- qa
14 changes: 14 additions & 0 deletions examples/nginx-grains/grains/dev/mygrains.py
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions examples/nginx-grains/grains/qa/mygrains.py
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions examples/nginx-grains/salt/nginx/files/my_vhost_conf.jinja
Original file line number Diff line number Diff line change
@@ -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;
}
20 changes: 20 additions & 0 deletions examples/nginx-grains/salt/nginx/init.sls
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions examples/nginx-grains/salt/nginx/layer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
help: nginx layer
description: >
Nginx layer
parent: sysbase
grains: dev
3 changes: 3 additions & 0 deletions examples/nginx-grains/salt/nginx/top.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
base:
'*':
- init
21 changes: 21 additions & 0 deletions examples/nginx-grains/salt/sysbase/Dockerfile
Original file line number Diff line number Diff line change
@@ -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/*
6 changes: 6 additions & 0 deletions examples/nginx-grains/salt/sysbase/layer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
help: Operating System Base Layer
description: >
System base layer
(Phusion Ubuntu 14.04 with Salt, build-essential,
various debugging tools)

10 changes: 10 additions & 0 deletions examples/nginx-pillar/README.md
Original file line number Diff line number Diff line change
@@ -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.
18 changes: 18 additions & 0 deletions examples/nginx-pillar/flyingcloud.yaml
Original file line number Diff line number Diff line change
@@ -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

4 changes: 4 additions & 0 deletions examples/nginx-pillar/pillar/dev/nginx.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
nginx:
server_name: dev.server.com
log_prefix: dev_server_com
backend_server: dev-myapp.server.com
3 changes: 3 additions & 0 deletions examples/nginx-pillar/pillar/dev/top.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
base:
'*':
- nginx
4 changes: 4 additions & 0 deletions examples/nginx-pillar/pillar/qa/nginx.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
nginx:
server_name: qa.server.com
log_prefix: qa
backend_server: qa-myapp.server.com
4 changes: 4 additions & 0 deletions examples/nginx-pillar/pillar/qa/top.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
base:
'*':
- nginx

13 changes: 13 additions & 0 deletions examples/nginx-pillar/salt/nginx/config.sls
Original file line number Diff line number Diff line change
@@ -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

11 changes: 11 additions & 0 deletions examples/nginx-pillar/salt/nginx/files/my_vhost_conf.jinja
Original file line number Diff line number Diff line change
@@ -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;
}
4 changes: 4 additions & 0 deletions examples/nginx-pillar/salt/nginx/install.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
nginx:
pkg:
- name: nginx-full
- installed
6 changes: 6 additions & 0 deletions examples/nginx-pillar/salt/nginx/layer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
help: nginx layer
description: >
Nginx layer
parent: sysbase
pillar: dev

4 changes: 4 additions & 0 deletions examples/nginx-pillar/salt/nginx/top.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
base:
'*':
- install
- config
21 changes: 21 additions & 0 deletions examples/nginx-pillar/salt/sysbase/Dockerfile
Original file line number Diff line number Diff line change
@@ -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/*
6 changes: 6 additions & 0 deletions examples/nginx-pillar/salt/sysbase/layer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
help: Operating System Base Layer
description: >
System base layer
(Phusion Ubuntu 14.04 with Salt, build-essential,
various debugging tools)

Loading