Add preupload wrapper for checking anisble configs

Just runs ansible-lint for now.  Skips test if nothing in specified
directory is changed

Change-Id: Ifb2c326e27d27be6902a02f2539ad364784626c9
diff --git a/preupload-hooks/ansible-checks.sh b/preupload-hooks/ansible-checks.sh
new file mode 100755
index 0000000..380fdd5
--- /dev/null
+++ b/preupload-hooks/ansible-checks.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+# Copyright 2023 Google LLC
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Wrapper to run ansible-lint for repo preupload.
+# Usage: ansible-checks.sh path/to/ansible ${PREUPLOAD_COMMIT}
+# The script fails if any of the checks exit with non-zero status.
+
+set -e
+
+ANSIBLE_CHANGE=0
+ANSIBLE_PATH=$1
+shift
+
+# Check to see if any changed files are in the ansible path
+for FILE in $@; do
+  if [[ $FILE == $ANSIBLE_PATH* ]]; then
+    ANSIBLE_CHANGE=1
+    break
+  fi
+done
+
+if (( ANSIBLE_CHANGE == 1 )); then
+  if ! command -v ansible-lint >/dev/null; then
+    echo "Command ansible-lint not found. Install the ansible-lint package."
+    exit 1
+  fi
+
+  # Run ansible checks. Just lint for now
+  ansible-lint $ANSIBLE_PATH
+fi