Commit f2be7d5c authored by Charlie Root's avatar Charlie Root
Browse files

add support for modules and config

parent 0393cff6
......@@ -11,6 +11,58 @@ geoservers:
2.16.2:
jetty:
version: 9.4.18.v20190429
modules:
ext:
enabled: True
files:
recurse:
lib/ext:
source: salt://geoserver/files/jetty/9.4.18.v20190429/ext
jar: False
config: |
[description]
Adds all jar files discovered in $JETTY_HOME/lib/ext
and $JETTY_BASE/lib/ext to the servers classpath.
[tags]
classpath
[lib]
lib/ext/**.jar
[files]
lib/
lib/ext/
jndi:
enabled: False
files:
managed:
etc/jetty-jndi.xml:
source: salt://geoserver/files/jetty/jetty-jndi.xml.jinja
config: |
[depend]
server
ext
[lib]
lib/jetty-jndi-${jetty.version}.jar
[xml]
etc/jetty-jndi.xml
plus:
enabled: False
config: |
[depend]
server
security
jndi
webapp
[lib]
lib/jetty-plus-${jetty.version}.jar
[xml]
etc/jetty-plus.xml
jdks:
FreeBSD:
......@@ -18,3 +70,4 @@ jdks:
pkg: openjdk8
JAVA_HOME: /usr/local/openjdk8
JAVA_OPTS: -server -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Xmx2048m -Xms2048m -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false
jdbc: postgresql-42.2.12.jar
......@@ -2,3 +2,4 @@ include:
- geoserver.install
- geoserver.plugins
- geoserver.data_dir
- geoserver.jetty.modules
{% from "geoserver/map.jinja" import geoserver with context %}
include:
- geoserver.install
{% for instance, config in geoserver.instances.items() %}
{% for module, module_config in config.jetty.modules.items() %}
#######
# JAR #
#######
{% if module_config.name is defined %}
{% if module_config.enabled %}
{{ instance }}_jetty_module_{{ module }}:
file.managed:
- name: {{ module_config.name }}
- source: {{ module_config.source }}
- source_hash: {{ module_config.source_hash }}
- user: {{ config.user }}
- group: {{ config.group }}
- mode: 644
- require:
- archive: {{ instance }}_geoserver_archive
{% else %}
{{ instance }}_jetty_module_{{ module }}:
file.absent:
- name: {{ module_config.name }}
{% endif %}
{% endif %}
##########
# CONFIG #
##########
{% if module_config.config is defined %}
{% if module_config.enabled %}
# Managed configuration files (if any)
{% if module_config.files is defined %}
{% for module_file_op, module_file_config in module_config.files.items() %}
{% if module_file_op == 'managed' %}
{% for conf_file_name, conf_file_params in module_file_config.items() %}
{{ instance }}_jetty_module_{{ module }}_{{ conf_file_name }}_file:
file.managed:
- name: {{ config.GEOSERVER_HOME | path_join(conf_file_name) }}
- source: {{ conf_file_params.source }}
- user: {{ config.user }}
- group: {{ config.group }}
- template: jinja
- context:
instance: {{ instance }}
- mode: 640
- require_in:
- file: {{ instance }}_jetty_module_{{ module }}_config
{% endfor %}
{% elif module_file_op == 'recurse' %}
{% for conf_file_name, conf_file_params in module_file_config.items() %}
{{ instance }}_jetty_module_{{ module }}_{{ conf_file_name }}_file:
file.recurse:
- name: {{ config.GEOSERVER_HOME | path_join(conf_file_name) }}
- source: {{ conf_file_params.source }}
- user: {{ config.user }}
- group: {{ config.group }}
- clean: True
- dir_mode: 755
- file_mode: 644
- require_in:
- file: {{ instance }}_jetty_module_{{ module }}_config
{% endfor %}
{% endif %} # module_file_op
{% endfor %}
{% endif %} # module_config.files
# Management of .mod files
{{ instance }}_jetty_module_{{ module }}_config:
file.managed:
- name: {{ config.GEOSERVER_HOME | path_join('modules', module ~ '.mod') }}
- contents: {{ module_config.config|yaml }}
- user: {{ config.user }}
- group: {{ config.group }}
- mode: 644
{% else %}
{{ instance }}_jetty_module_{{ module }}_config:
file.absent:
- name: {{ config.GEOSERVER_HOME | path_join('modules', module ~ '.mod') }}
{% endif %}
{% endif %}
#############
# start.ini #
#############
# XXX: https://github.com/saltstack/salt/issues/57223
{% if module_config.enabled %}
{{ instance }}_jetty_module_{{ module }}_ini:
cmd.run:
- name: {{ config.jdk_conf.JAVA_HOME | path_join('bin', 'java') }} -jar start.jar --add-to-start={{ module }}
- cwd: {{ config.GEOSERVER_HOME }}
- runas: {{ config.user }}
- group: {{ config.group }}
- shell: /bin/csh
- env:
- JAVA_HOME: {{ config.jdk_conf.JAVA_HOME }}
- JAVA_OPTS: {{ config.jdk_conf.JAVA_OPTS }}
- require:
- file: {{ instance }}_jetty_module_{{ module }}_config
{% else %}
{{ instance }}_jetty_module_{{ module }}_ini:
file.replace:
- name: {{ config.GEOSERVER_HOME | path_join('start.ini') }}
- pattern: ^--module={{ module }}$
- repl: '#--module={{ module }}'
- backup: False
{% endif %}
{% endfor %}
{% endfor %}
......@@ -83,7 +83,34 @@
}, plugin)
) %}
{% endfor %}
{% else %}
{% do config.update({'plugins': []}) %}
{% endif %}
{# jetty #}
{% if config.jetty.modules is defined %}
{% for module, module_config in config.jetty.modules.items() %}
{% if module_config.jar|default(True) %}
{% set _jar = 'jetty-' ~ module ~ '-' ~ config.jetty.version ~ '.jar' %}
{% do module_config.update(
salt.slsutil.merge({
'name': config.GEOSERVER_HOME | path_join('lib', _jar),
'source': 'salt://' ~ 'geoserver'|path_join(
'files', 'jetty', config.jetty.version, _jar
),
'source_hash': 'salt://' ~ 'geoserver'|path_join(
'files', 'jetty', config.jetty.version, 'md5sum'
),
}, module_config)
) %}
{% endif %}
{% endfor %}
{% else %}
{% do config.jetty.update({'modules': []}) %}
{% endif %}
{% endfor %}
{% do salt.log.info(geoserver) %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment