From 2f076757cf31b216d11699d7604f5dc36614e454 Mon Sep 17 00:00:00 2001 From: N Date: Wed, 22 Jul 2020 14:43:35 +0100 Subject: [PATCH] refactor(jinja): depreciate/replacer two variable names --- mongodb/clean.sls | 6 +++--- mongodb/config/alternatives/clean.sls | 2 +- mongodb/config/alternatives/install.sls | 2 +- mongodb/config/clean.sls | 2 +- mongodb/config/environ.sls | 2 +- mongodb/config/file.sls | 2 +- mongodb/config/users.sls | 2 +- mongodb/defaults.yaml | 5 ++--- mongodb/install.sls | 6 +++--- mongodb/map.jinja | 13 +++++++++++-- mongodb/osfamilymap.yaml | 5 ++--- mongodb/service/clean.sls | 2 +- mongodb/service/running.sls | 2 +- 13 files changed, 29 insertions(+), 22 deletions(-) diff --git a/mongodb/clean.sls b/mongodb/clean.sls index cbde49e..597e9bb 100644 --- a/mongodb/clean.sls +++ b/mongodb/clean.sls @@ -24,13 +24,13 @@ include: - sls: {{ sls_service_clean }} - sls: {{ sls_config_clean }} - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} {%- set software = d.pkg[comp][name] %} {%- set package = software.package_format %} - {%- if package in d.software_package_matrix %} + {%- if package in d.use_upstream %} {#- PACKAGE CLEAN #} {%- if package in software and software[package] is mapping %} @@ -42,7 +42,7 @@ include: - file: {{ formula }}-clean-prerequisites file.absent: - name: {{ software['path'] }} - {%- if d.wanted.upstream_repo %} + {%- if d.use_upstream == 'repo' %} pkgrepo.absent: - name: {{ d.pkg['repo']['name'] }} {%- endif %} diff --git a/mongodb/config/alternatives/clean.sls b/mongodb/config/alternatives/clean.sls index 27f7608..fe2a2a3 100644 --- a/mongodb/config/alternatives/clean.sls +++ b/mongodb/config/alternatives/clean.sls @@ -6,7 +6,7 @@ {%- set formula = d.formula %} {%- if grains.kernel|lower == 'linux' and d.linux.altpriority|int > 0 and grains.os_family != 'Arch' %} - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} diff --git a/mongodb/config/alternatives/install.sls b/mongodb/config/alternatives/install.sls index a7b9748..a287ad2 100644 --- a/mongodb/config/alternatives/install.sls +++ b/mongodb/config/alternatives/install.sls @@ -10,7 +10,7 @@ include: - {{ sls_software_install }} {%- if grains.kernel|lower == 'linux' and d.linux.altpriority|int > 0 and grains.os_family != 'Arch' %} - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} diff --git a/mongodb/config/clean.sls b/mongodb/config/clean.sls index a72b518..c0416cc 100644 --- a/mongodb/config/clean.sls +++ b/mongodb/config/clean.sls @@ -11,7 +11,7 @@ include: - {{ sls_service_clean }} - {{ sls_alternatives_clean }} - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} diff --git a/mongodb/config/environ.sls b/mongodb/config/environ.sls index d3d9f7f..c550403 100644 --- a/mongodb/config/environ.sls +++ b/mongodb/config/environ.sls @@ -10,7 +10,7 @@ include: - {{ sls_software_install }} - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} diff --git a/mongodb/config/file.sls b/mongodb/config/file.sls index ce858b4..81267b8 100644 --- a/mongodb/config/file.sls +++ b/mongodb/config/file.sls @@ -22,7 +22,7 @@ include: - require: - sls: {{ sls_software_install }} - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} diff --git a/mongodb/config/users.sls b/mongodb/config/users.sls index 34a9841..950cbfa 100644 --- a/mongodb/config/users.sls +++ b/mongodb/config/users.sls @@ -5,7 +5,7 @@ {%- from tplroot ~ "/map.jinja" import data as d with context %} {%- set formula = d.formula %} - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} diff --git a/mongodb/defaults.yaml b/mongodb/defaults.yaml index b2ecfd6..60f2bd7 100644 --- a/mongodb/defaults.yaml +++ b/mongodb/defaults.yaml @@ -2,8 +2,8 @@ # vim: ft=yaml --- mongodb: - software_component_matrix: ['database', 'gui', 'connectors'] - software_package_matrix: ['archive', 'macapp', 'native'] + components: ['database', 'gui', 'connectors'] # depreciate software_component_matrix + use_upstream: ['archive', 'macapp', 'repo'] # depreciate software_package_matrix wanted: database: - mongod @@ -12,7 +12,6 @@ mongodb: firewall: false selinux: false disable_transparent_hugepages: true - upstream_repo: false default: user: mongodb group: mongodb diff --git a/mongodb/install.sls b/mongodb/install.sls index d8a750d..9fefeaa 100644 --- a/mongodb/install.sls +++ b/mongodb/install.sls @@ -31,13 +31,13 @@ include: - pkg: {{ formula }}-install-prerequisites - pip: {{ formula }}-install-prerequisites - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} {%- set software = d.pkg[comp][name] %} {%- set package = software.package_format %} - {%- if package in d.software_package_matrix %} + {%- if package in d.use_upstream %} {# DOWNLOAD NATIVE PACKAGE #} @@ -76,7 +76,7 @@ include: {#- NATIVE PACKAGE INSTALL #} {%- if package == 'native' %} - {%- if d.wanted.upstream_repo and 'repo' in d.pkg and d.pkg.repo %} + {%- if d.use_upstream = 'repo' and 'repo' in d.pkg and d.pkg.repo %} pkgrepo.managed: {{- format_kwargs(d.pkg['repo']) }} {%- endif %} diff --git a/mongodb/map.jinja b/mongodb/map.jinja index efc334c..534a93d 100644 --- a/mongodb/map.jinja +++ b/mongodb/map.jinja @@ -22,9 +22,18 @@ ) %} +# depreciate two params +{%- if 'software_component_matrix' in d %} + {%- do d.update({ 'components': d.software_component_matrix %} +{%- endif %} +{%- if 'software_package_matrix' in d %} + {%- do d.update({ 'use_upstream': d.software_package_matrix %} +{%- endif %} + +# build dict {%- set d = salt['grains.filter_by']( {'defaults': defaults}, default='defaults', merge=_config) %} -{%- for comp in d.software_component_matrix %} +{%- for comp in d.components %} {%- if comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- set software = d.pkg[comp][name] %} @@ -34,7 +43,7 @@ {%- set release = v.version.split('.')[0] ~ '.' ~ v.version.split('.')[1] %} {%- set dir = '%s-%s'|format(name, v.version) %} {%- set path = d.dir.archive ~ '/' ~ dir %} - {%- for package in d.software_package_matrix %} + {%- for package in d.use_upstream %} {%- if package in v and v[package] %} {%- set path = d.dir[package] if package == 'macapp' else path %} {%- do software[package].update({'name': path}) %} diff --git a/mongodb/osfamilymap.yaml b/mongodb/osfamilymap.yaml index e3cf540..7037ea2 100644 --- a/mongodb/osfamilymap.yaml +++ b/mongodb/osfamilymap.yaml @@ -28,10 +28,9 @@ Arch: Alpine: {} Debian: + use_upstream: 'archive' # using 'repo' caused a conflict wanted: firewall: false - # package conflict occured when true - upstream_repo: false pkg: deps: - curl @@ -61,10 +60,10 @@ Debian: skip_verify: false RedHat: + use_upstream: 'repo' wanted: firewall: false # turned off for travis ci selinux: false # turrned off for travs citrue - upstream_repo: true default: user: mongod group: mongod diff --git a/mongodb/service/clean.sls b/mongodb/service/clean.sls index 7e29e96..5b9a845 100644 --- a/mongodb/service/clean.sls +++ b/mongodb/service/clean.sls @@ -9,7 +9,7 @@ include: - {{ sls_config_clean }} - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} diff --git a/mongodb/service/running.sls b/mongodb/service/running.sls index a430d1d..20f0556 100644 --- a/mongodb/service/running.sls +++ b/mongodb/service/running.sls @@ -37,7 +37,7 @@ include: - enable: True {%- endif %} - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %}