gce-xfstests: allow customizing creation of GCE firewall rules
PATCH 1/1 gce-xfstests: allow customizing creation of GCE firewall rules
From: Eric Biggers <[email protected]>
Add a new config variable GCE_FIREWALL_RULES which can be overridden in ~/.config/gce-xfstests to change or disable creation of extra GCE firewall rules like "allow-http". This will be useful for people who want to configure their firewall differently or are not using the gce-xfstests web interface.
Also start creating the firewall rules synchronously and not hiding errors. This will be useful if someone enters incorrect syntax in GCE_FIREWALL_RULES, causing creating a firewall rule to fail.
--- Documentation/gce-xfstests.md | 12 ++++++++++++ kvm-xfstests/config | 4 ++++ kvm-xfstests/util/gce-do-setup | 15 ++++++++++----- 3 files changed, 26 insertions(+), 5 deletions(-)
Documentation/gce-xfstests.md +12 -0
@@ -157,6 +157,18 @@ configuration parameters in order to have reports e-mailed to you: control over the domain used by GCE_REPORT_EMAIL, you may need to choose a different sender address. +Other optional parameters include: + +* GCE_FIREWALL_RULES + * List of firewall rules to add to the GCP project if not already + present. By default a rule "allow-http" is created which makes + the gce-xfstests web interface accessible to anyone over the + Internet. It may be useful to override this if you want to + implement more restrictive firewall rules or disable access to the + web interface entirely. Note that existing firewall rules + associated with the GCP project will not be removed, and by + default there is a default-allow-ssh rule which allows SSH access. + An example ~/.config/gce-xfstests might look like this: GS_BUCKET=tytso-xfstests
kvm-xfstests/config +4 -0
@@ -63,3 +63,7 @@ CONSOLE=" -serial mon:stdio" # GCE_PROJECT=tytso-xfstests-project # GCE_ZONE=us-central1-c # GCE_KERNEL=/u1/ext4-64/arch/x86/boot/bzImage + +# List of firewall rules to create. By default the gce-xfstests web interface +# is made available to everyone over the public Internet. +GCE_FIREWALL_RULES=("allow-http --allow tcp:80 --target-tags http-server")
kvm-xfstests/util/gce-do-setup +10 -5
@@ -119,9 +119,14 @@ if test -n "$GCE_REPORT_EMAIL" ; then fi fi -if test -z "$(gcloud compute firewall-rules list allow-http | sed -e 1d)" -then - gcloud compute --project "$GCE_PROJECT" firewall-rules create \ - allow-http --allow tcp:80 --target-tags http-server >& /dev/null & -fi +for rule in "${GCE_FIREWALL_RULES[@]}"; do + rule_name=$(echo $rule | cut -d' ' -f1) + if test -z "$(gcloud compute firewall-rules list $rule_name | sed -e 1d)" + then + echo "Creating $rule_name firewall rule..." + gcloud compute --project "$GCE_PROJECT" firewall-rules create $rule + fi +done +unset rule rule_name + exit 0
Signature · 1 line
2.12.2.762.g0e3151a226-goog
Theodore Ts'o
AppliedQuoted 8 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Add a new config variable
GCE_FIREWALL_RULESwhich can be overridden in ~/.config/gce-xfstests to change or disable creation of extra GCE firewall rules like "allow-http". This will be useful for people who want to configure their firewall differently or are not using the gce-xfstests web interface.
Quoted 5 lines
Also start creating the firewall rules synchronously and not hiding errors. This will be useful if someone enters incorrect syntax in
GCE_FIREWALL_RULES, causing creating a firewall rule to fail.Signed-off-by Eric Biggers <[email protected]>
Thanks, applied.
- Ted