From 5de9073d48ac7373a9f94b7f350a4a05678a7f33 Mon Sep 17 00:00:00 2001 From: A Holt Date: Fri, 20 Aug 2021 05:58:24 -0400 Subject: [PATCH] iiab-support: Emulate Ansible & /etc/openvpn/scripts/announcer --- roles/openvpn/templates/iiab-support | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/roles/openvpn/templates/iiab-support b/roles/openvpn/templates/iiab-support index 0897f1031..5dbc309e6 100755 --- a/roles/openvpn/templates/iiab-support +++ b/roles/openvpn/templates/iiab-support @@ -13,11 +13,16 @@ DEBUG=false # Using /usr/bin/true or /usr/bin/false # PARSE local_vars.yml JUST AS Ansible & /etc/openvpn/scripts/announcer DO: # (1) In case var's defined multiple times, 'tail 1' takes the last assignment. -# (2) sed: Strip 'varname:\s' on left. -# (3) sed: Strip '# comment' on right. Optional on live/keyboard input. -# (4) sed: Strip any outer spacing, as Ansible would do. Optional on live input. -# (5) sed: Strip up-to-1 pair of matching outer quotes, as Ansible would do. -# (6) Convert remaining spaces to underscores, just as 'announcer' does. +# (2) sed: Strip 'varname:\s' on left. Not applicable for live/keyboard input. +# (3) sed: Strip '#comment' on right. +# (4) sed: Strip any outer spacing. +# (5) sed: Strip up-to-1 pair of matching outer quotes. + +[*] Steps (1) and (2) are not applicable for live/keyboard input. +[*] Steps (3), (4) and (5) are optional for live/keyboard input (we do it!) + +# /etc/openvpn/scripts/announcer ALSO GOES ONE STEP FURTHER THAN ANSIBLE: +# (6) Convert remaining spaces to underscores. # NOTE Ansible vars can have non-string value null. This is different from # undefined -- from Ansible's perspective -- SEE /opt/iiab/iiab/test.yml @@ -79,7 +84,7 @@ else # NEXT 4 LINES AREN'T ESSENTIAL: but they allow user to type in a '# comment' for the right side of /etc/iiab/local_vars.yml - # (3) sed: Strip '# comment' on right. + # (3) sed: Strip '# comment' on right, as Ansible would do. ans=$(echo "$ans" | sed "s/#.*//") # Double quote var to prevent field splitting (eats spaces) # (4) sed: Strip any outer spacing, as Ansible would do. ans=$(echo "$ans" | sed "s/^\s*//; s/\s*$//") # Code Safety: lstrip not nec, given "read" command above, but one day $ans might arise from elsewhere