From 05b05b0c3e1187ad75e15ec2f52d5180653a4bd9 Mon Sep 17 00:00:00 2001
From: Kostiantyn Kalynovskyi <kkalynovskyi@mirantis.com>
Date: Thu, 9 Jan 2020 21:25:03 +0000
Subject: [PATCH] Initial commit with empty lint job

Change-Id: I7d81ad1faca6ce896b4d2caedcea15b1abd035ef
---
 .gitignore              |  1 +
 tests/ansible/lint.yaml | 33 +++++++++++++++++++++++++++++++++
 zuul.d/jobs.yaml        | 16 ++++++++++++++++
 zuul.d/nodesets.yaml    | 17 +++++++++++++++++
 zuul.d/project.yaml     |  7 +++++++
 5 files changed, 74 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 tests/ansible/lint.yaml
 create mode 100644 zuul.d/jobs.yaml
 create mode 100644 zuul.d/nodesets.yaml
 create mode 100644 zuul.d/project.yaml

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a8b42eb
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.retry
diff --git a/tests/ansible/lint.yaml b/tests/ansible/lint.yaml
new file mode 100644
index 0000000..f62ef67
--- /dev/null
+++ b/tests/ansible/lint.yaml
@@ -0,0 +1,33 @@
+---
+- hosts: primary
+  tasks:
+    - block:
+      - name: Ensuring ansible-lint package is present
+        fail:
+          msg: "Centos or RHEL is not yet supported"
+        when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
+
+      - name: Ensuring ansible-lint package is present
+        become: true
+        apt:
+          name: ansible-lint
+          state: present
+        when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
+
+
+    - name: find files to lint
+      find:
+        paths:
+          - "{{ src_dir| default('../..') }}/playbooks"
+          - "{{ src_dir| default('../..') }}/roles"
+        patterns:
+          - "*.yaml"
+          - "*.yml"
+      register: files_to_lint
+
+# TODO (kkalynovskyi) develop suitable ansible-lint configuration
+    - name: run ansible-lint against found files
+      command: "ansible-lint {{ item.path }}"
+      with_items: "{{ files_to_lint.files }}"
+
+
diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml
new file mode 100644
index 0000000..7764817
--- /dev/null
+++ b/zuul.d/jobs.yaml
@@ -0,0 +1,16 @@
+# 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.
+
+- job:
+    name: ansible-lint-airship
+    run: tests/ansible/lint.yaml
+    nodeset: ubuntu-single-airship
\ No newline at end of file
diff --git a/zuul.d/nodesets.yaml b/zuul.d/nodesets.yaml
new file mode 100644
index 0000000..84caf6f
--- /dev/null
+++ b/zuul.d/nodesets.yaml
@@ -0,0 +1,17 @@
+# 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.
+
+- nodeset:
+    name: ubuntu-single-airship
+    nodes:
+      - name: primary
+        label: ubuntu-bionic
diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml
new file mode 100644
index 0000000..0e5189b
--- /dev/null
+++ b/zuul.d/project.yaml
@@ -0,0 +1,7 @@
+- project:
+    check:
+      jobs:
+        - ansible-lint-airship
+    gate:
+      jobs:
+        - ansible-lint-airship