Skip to content

Commit

Permalink
refactor: standardise structure from the template-formula
Browse files Browse the repository at this point in the history
  • Loading branch information
myii committed Apr 21, 2020
1 parent d1bb84f commit db49764
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 27 deletions.
22 changes: 16 additions & 6 deletions tomcat/map.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
{%- 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 %}

{#- Retrieve the config dict only once #}
Expand All @@ -15,14 +17,22 @@
default_settings,
default=tplroot,
merge=salt['grains.filter_by'](
osfamilymap,
grain='os_family',
osarchmap,
grain='osarch',
merge=salt['grains.filter_by'](
osfingermap,
grain='osfinger',
osfamilymap,
grain='os_family',
merge=salt['grains.filter_by'](
_config,
default='lookup'
osmap,
grain='os',
merge=salt['grains.filter_by'](
osfingermap,
grain='osfinger',
merge=salt['grains.filter_by'](
_config,
default='lookup'
)
)
)
)
)
Expand Down
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
27 changes: 18 additions & 9 deletions tomcat/osfamilymap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,20 @@ Debian:
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
openSUSE:
ver: 8
native_pkg: libtcnative-1-0
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
FreeBSD:
native_pkg: tomcat-native
ini_config: /etc/rc.conf
java_home: /usr

Gentoo: {}

Arch:
pkg: tomcat8
ver: 8
Expand All @@ -51,6 +47,19 @@ Arch:
# 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') %}
Expand Down
56 changes: 44 additions & 12 deletions tomcat/osfingermap.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
Ubuntu-14.04:
ver: 7
# os: Debian
Debian-10:
ver: 9
pkg: tomcat9
manager_pkg: tomcat9-admin
conf_dir: /etc/tomcat9
main_config: /etc/default/tomcat9
service: tomcat9
user: tomcat
group: tomcat
Debian-9: {}
Debian-8: {}
Debian-7:
pkg: tomcat7
manager_pkg: tomcat7-admin
conf_dir: /etc/tomcat7
Expand All @@ -11,7 +22,12 @@ Ubuntu-14.04:
service: tomcat7
user: tomcat7
group: tomcat7
Debian-7:

# os: Ubuntu
Ubuntu-18.04: {}
Ubuntu-16.04: {}
Ubuntu-14.04:
ver: 7
pkg: tomcat7
manager_pkg: tomcat7-admin
conf_dir: /etc/tomcat7
Expand All @@ -20,12 +36,28 @@ Debian-7:
service: tomcat7
user: tomcat7
group: tomcat7
Debian-10:
ver: 9
pkg: tomcat9
manager_pkg: tomcat9-admin
conf_dir: /etc/tomcat9
main_config: /etc/default/tomcat9
service: tomcat9
user: tomcat
group: tomcat

# os: Fedora
Fedora-31: {}
Fedora-30: {}

# os: CentOS
CentOS Linux-8: {}
CentOS Linux-7: {}
CentOS-6: {}

# os: Amazon
Amazon Linux-2: {}
Amazon Linux AMI-2018: {}

# os: SUSE
Leap-15: {}

# os: FreeBSD
FreeBSD-12: {}

# os: Windows
Windows-8.1: {}

# os: Gentoo
Gentoo-2: {}
33 changes: 33 additions & 0 deletions tomcat/osmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Setup variables using grains['os'] based logic.
# You just need to add the key:values for an `os` that differ
# from `defaults.yaml` + `osarch.yaml` + `os_family.yaml`.
# Only add an `os` which is/will be supported by the formula.
#
# If you do not need to provide defaults via the `os` grain,
# you will need to provide at least an empty dict in this file, e.g.
# osmap: {}
---
# os_family: Debian
Ubuntu: {}
Raspbian: {}

# os_family: RedHat
Fedora: {}
CentOS: {}
Amazon: {}

# os_family: Suse
SUSE: {}
openSUSE: {}

# os_family: Gentoo
Funtoo: {}

# os_family: Arch
Manjaro: {}

# os_family: Solaris
SmartOS: {}

0 comments on commit db49764

Please sign in to comment.