Skip to content

Commit

Permalink
Merge pull request #109 from danny-smit/debian10
Browse files Browse the repository at this point in the history
Rework map.jinja according to the template-formula and add support for Debian 10
  • Loading branch information
myii authored Apr 21, 2020
2 parents 43fc17a + 9b2bab5 commit f0b3c79
Show file tree
Hide file tree
Showing 11 changed files with 308 additions and 137 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
## Define the rest of the matrix based on Kitchen testing
# Make sure the instances listed below match up with
# the `platforms` defined in `kitchen.yml`
# - env: INSTANCE=tomcat-install-debian-10-master-py3
- env: INSTANCE=tomcat-install-debian-10-master-py3
- env: INSTANCE=tomcat-install-ubuntu-1804-master-py3
# - env: INSTANCE=tomcat-extend-ubuntu-1804-master-py3
# - env: INSTANCE=tomcat-install-centos-8-master-py3
Expand Down
2 changes: 1 addition & 1 deletion .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ignore: |
node_modules/
test/**/states/**/*.sls
.kitchen/
tomcat/osmap.yaml
tomcat/osfamilymap.yaml
yaml-files:
# Default settings
Expand Down
7 changes: 6 additions & 1 deletion test/integration/tomcat_install/controls/packages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
packages =
case platform[:family]
when 'debian'
%w[tomcat8 haveged]
case platform[:release]
when /^10/
%w[tomcat9 haveged]
else
%w[tomcat8 haveged]
end
when 'redhat', 'fedora', 'suse'
%w[tomcat]
end
Expand Down
7 changes: 6 additions & 1 deletion test/integration/tomcat_install/controls/services_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
services =
case platform[:family]
when 'debian'
%w[tomcat8 haveged]
case platform[:release]
when /^10/
%w[tomcat9 haveged]
else
%w[tomcat8 haveged]
end
when 'redhat', 'fedora', 'suse'
%w[tomcat]
end
Expand Down
39 changes: 31 additions & 8 deletions test/integration/tomcat_install/controls/yaml_dump_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,36 @@
yaml_dump +=
case platform[:family]
when 'debian'
case platform[:release]
when /^10/
conf_dir = '/etc/tomcat9'
group = 'tomcat'
main_config = '/etc/default/tomcat9'
manager_pkg = 'tomcat9-admin'
pkg = 'tomcat9'
service = 'tomcat9'
user = 'tomcat'
ver = 9
else
conf_dir = '/etc/tomcat8'
group = 'tomcat8'
main_config = '/etc/default/tomcat8'
manager_pkg = 'tomcat8-admin'
pkg = 'tomcat8'
service = 'tomcat8'
user = 'tomcat8'
ver = 8
end
<<~YAML_DUMP.chomp
arch: amd64
authbind: 'no'
catalina_base: /usr/share/tomcat
catalina_home: /usr/share/tomcat
catalina_pid: /var/run/tomcat.pid
catalina_tmpdir: /var/cache/tomcat/temp
cluster:
simple: true
conf_dir: /etc/tomcat8
conf_dir: #{conf_dir}
connectors:
example_connector:
port: 8443
Expand Down Expand Up @@ -72,7 +93,7 @@
global: simpleValue
type: java.lang.Integer
expires_when: 2 weeks
group: tomcat8
group: #{group}
haveged_enabled: true
id:
- example.com
Expand All @@ -91,7 +112,7 @@
soft: 64000
logfile_compress: 1
logfile_days: 14
main_config: /etc/default/tomcat8
main_config: #{main_config}
main_config_template: salt://tomcat/files/tomcat-default-Debian.template
manager:
roles:
Expand All @@ -110,7 +131,7 @@
- manager-script
- manager-jmx
- manager-status
manager_pkg: tomcat8-admin
manager_pkg: #{manager_pkg}
native_pkg: libtcnative-1
other_contexts:
other-contexts:
Expand All @@ -137,10 +158,10 @@
className: org.apache.catalina.webresources.DirResourceSet
base: /var/lib/tomcat8/appconfig
webAppMount: /WEB-INF/classes
pkg: tomcat8
pkg: #{pkg}
resources: {}
security: 'no'
service: tomcat8
service: #{service}
service_enabled: true
service_running: false
sites:
Expand Down Expand Up @@ -175,12 +196,13 @@
pattern: '%h %l %u %t &quot;%m http://%v%U %H&quot; %s %b &quot;%{Referer}i&quot;
&quot;%{User-Agent}i&quot; %D'
- className: org.apache.catalina.authenticator.SingleSignOn
user: tomcat8
ver: 8
user: #{user}
ver: #{ver}
with_haveged: true
YAML_DUMP
when 'redhat', 'fedora'
<<~YAML_DUMP.chomp
arch: amd64
authbind: 'no'
catalina_base: /usr/share/tomcat
catalina_home: /usr/share/tomcat
Expand Down Expand Up @@ -354,6 +376,7 @@
YAML_DUMP
when 'suse'
<<~YAML_DUMP.chomp
arch: amd64
authbind: 'no'
catalina_base: /usr/share/tomcat
catalina_home: /usr/share/tomcat
Expand Down
22 changes: 0 additions & 22 deletions tomcat/codenamemap.yaml

This file was deleted.

60 changes: 42 additions & 18 deletions tomcat/map.jinja
Original file line number Diff line number Diff line change
@@ -1,25 +1,49 @@
# -*- coding: utf-8 -*-
# vim: ft=jinja

{% import_yaml "tomcat/defaults.yaml" as defaults %}
{% import_yaml "tomcat/osmap.yaml" as osmap %}
{% import_yaml "tomcat/codenamemap.yaml" as codemap %}
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{#- Start imports as #}
{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %}
{%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %}
{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
{%- import_yaml tplroot ~ "/osmap.yaml" as osmap %}
{%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %}

{# get the settings for the os_family grain #}
{% set osfam = salt['grains.filter_by'](osmap) or {} %}
{# get the settings for the oscodename grain, os_family data will override
oscodename data #}
{% set oscode = salt['grains.filter_by'](codemap,
grain='oscodename',
merge=osfam) or {} %}
{#- Retrieve the config dict only once #}
{%- set _config = salt['config.get'](tplroot, default={}) %}

{# merge the os family/codename specific data over the defaults #}
{% do defaults.tomcat.update(oscode) %}
{%- set defaults = salt['grains.filter_by'](
default_settings,
default=tplroot,
merge=salt['grains.filter_by'](
osarchmap,
grain='osarch',
merge=salt['grains.filter_by'](
osfamilymap,
grain='os_family',
merge=salt['grains.filter_by'](
osmap,
grain='os',
merge=salt['grains.filter_by'](
osfingermap,
grain='osfinger',
merge=salt['grains.filter_by'](
_config,
default='lookup'
)
)
)
)
)
)
%}

{# merge the pillar:lookup dict into the defaults/os specific dict #}
{% set lookup = salt['pillar.get']('tomcat:lookup',
default=defaults.tomcat,
merge=True) %}
{%- set config = salt['grains.filter_by'](
{'defaults': defaults},
default='defaults',
merge=_config
)
%}

{# merge the actual tomcat pillar into the above combined dict #}
{% set tomcat = salt['pillar.get']('tomcat', default=lookup, merge=True) %}
{%- set tomcat = config %}
35 changes: 35 additions & 0 deletions tomcat/osarchmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Setup variables using grains['osarch'] based logic.
# You just need to add the key:values for an `osarch` that differ
# from `defaults.yaml`.
# Only add an `osarch` which is/will be supported by the formula.
#
# If you do not need to provide defaults via the `osarch` grain,
# you will need to provide at least an empty dict in this file, e.g.
# osarch: {}
---
amd64:
arch: amd64

x86_64:
arch: amd64

386:
arch: 386

arm64:
arch: arm64

armv6l:
arch: armv6l

armv7l:
arch: armv7l

ppc64le:
arch: ppc64le

s390x:
arch: s390x
98 changes: 98 additions & 0 deletions tomcat/osfamilymap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
Debian:
ver: 8
pkg: tomcat8
native_pkg: libtcnative-1
manager_pkg: tomcat8-admin
with_haveged: true
haveged_enabled: true
conf_dir: /etc/tomcat8
main_config: /etc/default/tomcat8
main_config_template: salt://tomcat/files/tomcat-default-Debian.template
service: tomcat8
user: tomcat8
group: tomcat8
java_home: /usr/lib/jvm/default-java

RedHat:
native_pkg: tomcat-native
manager_pkg: tomcat-admin-webapps
main_config_template: salt://tomcat/files/tomcat-default-CentOS.template

Suse:
ver: 8
native_pkg: libtcnative-1-0
manager_pkg: tomcat-admin-webapps
main_config_template: salt://tomcat/files/tomcat-default-CentOS.template

Gentoo: {}

Arch:
pkg: tomcat8
ver: 8
service: tomcat8
native_pkg: tomcat-native
conf_dir: /etc/tomcat8
main_config: /usr/lib/systemd/system/tomcat8.service
main_config_template: salt://tomcat/files/tomcat-default-Arch.template
user: tomcat8
group: tomcat8
java_home: /usr/lib/jvm/default-runtime
jvm_tmp: /var/tmp/tomcat8/temp
catalina_pid: /var/run/tomcat8.pid
catalina_base: /usr/share/tomcat8
catalina_home: /usr/share/tomcat8
# Not used on Arch
manager_pkg: ''

Alpine: {}

FreeBSD:
native_pkg: tomcat-native
ini_config: /etc/rc.conf
java_home: /usr

OpenBSD: {}

Solaris: {}

Windows: {}

{%- if grains.os == 'MacOS' %}
{%- if salt['cmd.run']('/usr/libexec/java_home -F', output_loglevel="quiet") == 0 %}
{%- set darwin_javahome = salt['cmd.run']('/usr/libexec/java_home') %}
{%- else %}
{%- set darwin_javahome = "" %}
{%- endif %}
MacOS:
# yamllint disable rule:line-length
user: {{ salt['pillar.get']('tomcat:user', salt['cmd.run']("stat -f '%Su' /dev/console")) }}
group: {{ salt['pillar.get']('tomcat:group', salt['cmd.run']("stat -f '%Sg' /dev/console")) }}
# yamllint enable rule:line-length

java_home: {{ darwin_javahome }}
service: homebrew.mxcl.tomcat
ver: 8
pkg: tomcat
native_pkg: tomcat-native
conf_dir: /usr/local/opt/tomcat/libexec/conf
main_config: /usr/local/opt/tomcat/libexec/bin/setenv.sh
main_config_template: salt://tomcat/files/tomcat-default-CentOS.template
limits_prefix: /Library/LaunchAgents/maxfiles.plist
jvm_tmp: /usr/local/opt/tomcat/libexec/temp
catalina_base: /usr/local/opt/tomcat/libexec
catalina_home: /usr/local/opt/tomcat/libexec
catalina_tmpdir: /usr/local/opt/tomcat/libexec/temp

# Not used on Darwin
manager_pkg: ''
with_haveged: false
haveged_enabled: false

# Not verified on Darwin
cluster:
simple: false

{%- endif %}
Loading

0 comments on commit f0b3c79

Please sign in to comment.