Support the ability to ignore directories for ansible-lint job

For automation-tools repo, skip comac and comac-in-a-box directories

Change-Id: I1ea1e7b8ee84cd60f10962c67c6496a4912e7cd2
diff --git a/jjb/shell/ansiblelint.sh b/jjb/shell/ansiblelint.sh
index 930c09f..ebb5328 100755
--- a/jjb/shell/ansiblelint.sh
+++ b/jjb/shell/ansiblelint.sh
@@ -17,6 +17,7 @@
 # ansiblelint.sh - check all yaml files that they pass the ansible-lint tool
 
 set +e -u -o pipefail
+
 fail_ansible=0
 
 # verify that we have ansible-lint installed
@@ -27,16 +28,30 @@
 
 echo "=> Linting Ansible Code with $(ansible-lint --version)"
 
+# allow directories to be skipped
+# space separated directory list expected in SKIP_DIRS
+
+SKIP_DIRS=""
+SKIP_REGEX=""
+
+if [[ -n $SKIP_DIRS ]]; then
+  echo "=> Skipping files matching these directories: $SKIP_DIRS"
+  # prefix with ./ as find generates, swap spaces for pipes
+  SKIP_REGEX=$(echo $SKIP_DIRS | sed 's/[^ ]*/.\/&\//g' | sed 's/ /|/g')
+fi
+
 while IFS= read -r -d '' yf
 do
-  echo "==> CHECKING: ${yf}"
-  # Ignore line length limit (E204) as it can't (as of v4.0.1) be
-  # overridden with the skip_ansible_lint tag
-  ansible-lint -x 204 -p "${yf}"
-  rc=$?
-  if [[ $rc != 0 ]]; then
-    echo "==> LINTING FAIL: ${yf}"
-    fail_ansible=1
+  if [[ $yf =~ $SKIP_REGEX ]]; then
+    echo "==> SKIPPING: ${yf}"
+  else
+    echo "==> CHECKING: ${yf}"
+    ansible-lint -p "${yf}"
+    rc=$?
+    if [[ $rc != 0 ]]; then
+      echo "==> LINTING FAIL: ${yf}"
+      fail_ansible=1
+    fi
   fi
 done < <(find "${WORKSPACE}" \( -name "*.yml" -o -name "*.yaml" \) -print0)