From 10acc9cb98cdc979716dbfda2de5e276455c6d4d Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Thu, 15 Feb 2024 02:04:15 +0100 Subject: [PATCH] feat(config): support options as data structure Support the passing of arguments to an exported directory using a proper data structure to facilitate a more uniform configuration and to allow users to utilize pillar merging of hosts/options. Signed-off-by: Georg Pfuetzenreuter --- nfs/files/exports | 16 ++++++++++++++-- pillar.example | 7 +++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/nfs/files/exports b/nfs/files/exports index 95c8622..cf3c9b4 100644 --- a/nfs/files/exports +++ b/nfs/files/exports @@ -3,6 +3,18 @@ # Your changes will be overwritten. ######################################################################## # -{% for dir, opts in salt['pillar.get']('nfs:server:exports', {}).items() -%} +{%- for dir, opts in salt['pillar.get']('nfs:server:exports', {}).items() %} +{%- if opts is string %} {{ dir }} {{ opts }} -{% endfor -%} +{%- elif opts is mapping %} +{{ dir }} +{%- for host, options in opts.items() -%} +{{ ' ' ~ host }}( +{%- if options is iterable and options is not string -%} +{{ ','.join(options) }} +{%- else -%} +{{ options }} +{%- endif -%}) +{%- endfor -%} +{%- endif %} +{%- endfor %} diff --git a/pillar.example b/pillar.example index ff0694f..55b6d84 100644 --- a/pillar.example +++ b/pillar.example @@ -13,6 +13,13 @@ nfs: /srv/homes: >- hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check) + /srv/cats: + hostname1: + - async + - nohide + hostname2: rw + /srv/dogs: + hostname1: nohide # FreeBSD specific: mountd_flags: -l -S