mirror of
https://github.com/iiab/iiab.git
synced 2025-02-15 04:32:11 +00:00
iiab-support: Emulate Ansible & /etc/openvpn/scripts/announcer
This commit is contained in:
parent
5fcc91988c
commit
5de9073d48
1 changed files with 11 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue