Browse Source

oauth2-proxy app

master
Sean Johnson 5 months ago
parent
commit
e1a478dc05
  1. 16
      app/oauth2_proxy/defaults.yaml
  2. 55
      app/oauth2_proxy/init.sls
  3. 4
      app/oauth2_proxy/map.jinja
  4. 18
      app/oauth2_proxy/templates/config.j2

16
app/oauth2_proxy/defaults.yaml

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
---
container:
binds: []
env: {}
log_options:
max-buffer-size: 4m
max-file: 3
max-size: 10m
image: quay.io/oauth2-proxy/oauth2-proxy
restart: unless-stopped
shm_size: 16M
tag: v7.2.1
settings:
conf_dir: /opt/oauth2-proxy

55
app/oauth2_proxy/init.sls

@ -0,0 +1,55 @@ @@ -0,0 +1,55 @@
---
{% from "app/oauth2_proxy/map.jinja" import container, settings with context %}
{% set config_file = settings.conf_dir | path_join("settings.cfg") %}
{{ config_file }}:
file.managed:
- source: salt://app/oauth2_proxy/templates/config.j2
- makedirs: true
- template: jinja
- context:
config: {{ settings | tojson }}
- mode: 0640
oauth2-proxy image:
docker_image.present:
- name: {{ container.image }}
- tag: {{ container.tag }}
oauth2-proxy container:
docker_container.running:
- require:
- docker_image: oauth2-proxy image
- watch:
- file: {{ config_file }}
- image: {{ container.image }}:{{ container.tag }}
- name: oauth2-proxy
- detach: true
- privileged: false
- shm_size: {{ container.shm_size }}
- restart_policy: "{{ container.restart }}"
{%- if container.log_options %}
- log_opt:
{%- for key, value in container.log_options.items() %}
- {{ key | yaml_squote }}: {{ value | yaml_dquote }}
{%- endfor %}
{% endif %}
- labels:
- appname=oauth2-proxy
- binds:
- {{ settings.conf_dir }}:/etc/oauth2-proxy:ro
{%- for bind in container.binds %}
- {{ bind }}
{%- endfor %}
{% if container.env %}
- environment:
{%- for key, value in container.env.items() %}
- {{ key }}: {{ value | yaml_squote }}
{%- endfor %}
{% endif %}
- command: >
--config=/etc/oauth2-proxy/settings.cfg
{% if settings.args %}{% for arg in settings.args %} {{ arg }}
{% endfor %}{% endif %}

4
app/oauth2_proxy/map.jinja

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
{% import_yaml "app/oauth2_proxy/defaults.yaml" as defaults %}
{% set container = salt.pillar.get("oauth2-proxy:container", default=defaults["container"], merge=true) %}
{% set settings = salt.pillar.get("oauth2-proxy:settings", default=defaults["settings"], merge=true) %}

18
app/oauth2_proxy/templates/config.j2

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
{% macro config_item(key, value) %}
{% if value is string %}
{{ key }} = {{ value|yaml_dquote }}
{% elif value is boolean %}
{{ key }} = {{ value|string|lower }}
{% elif value|is_list %}
{{ key }} = [
{% for item in value %} "{{ value }}",
{% endfor %}
]
{% else %}
{{ raise("config item "~key~" has unhandlable value: "~value) }}
{% endif %}
{% endmacro %}
{% for key, value in config.items() %}
{{ config_item(key, value) }}
{% endfor %}
Loading…
Cancel
Save