From 66eaf7473bfc4756e7f3ab734610975b13ce8950 Mon Sep 17 00:00:00 2001
From: Monty Taylor <mordred@inaugust.com>
Date: Sun, 22 Feb 2015 22:54:18 -0500
Subject: [PATCH] Add ansible role for running puppet

Rather than embedding ansible roles inside of puppet modules (which is
mildly more than passing strange) make the ansible role a standalone
role that can be published to ansible galaxy.

Change-Id: I79a5a21278a1268e0e0011a874ff29c6980fd334
---
 .../openstack-infra/ansible-system.config     | 13 +++++++++
 gerrit/projects.yaml                          |  7 +++++
 gerritbot/channels.yaml                       |  1 +
 jenkins/jobs/ansible-role-jobs.yaml           | 19 ++++++++++++
 jenkins/jobs/macros.yaml                      | 29 +++++++++++++++++++
 jenkins/jobs/projects.yaml                    |  8 +++++
 zuul/layout.yaml                              | 11 +++++++
 7 files changed, 88 insertions(+)
 create mode 100644 gerrit/acls/openstack-infra/ansible-system.config
 create mode 100644 jenkins/jobs/ansible-role-jobs.yaml

diff --git a/gerrit/acls/openstack-infra/ansible-system.config b/gerrit/acls/openstack-infra/ansible-system.config
new file mode 100644
index 0000000000..c27ac60faa
--- /dev/null
+++ b/gerrit/acls/openstack-infra/ansible-system.config
@@ -0,0 +1,13 @@
+[access "refs/heads/*"]
+abandon = group infra-core
+label-Code-Review = -2..+2 group infra-core
+label-Workflow = -1..+1 group infra-core
+
+[access "refs/tags/*"]
+pushSignedTag = group infra-core
+
+[receive]
+requireChangeId = true
+
+[submit]
+mergeContent = true
diff --git a/gerrit/projects.yaml b/gerrit/projects.yaml
index 18adfdd0dc..d57e5d3dc6 100755
--- a/gerrit/projects.yaml
+++ b/gerrit/projects.yaml
@@ -53,6 +53,13 @@
   use-storyboard: true
   description: Tech community metrics dash of the OpenStack community based on the Metrics Grimoire toolset
   upstream: git://github.com/Bitergia/openstack-dashboard.git
+- project: openstack-infra/ansible-puppet
+  use-storyboard: true
+  upstream: git://gitorious.org/mordred-temp/ansible-puppet.git
+  acl-config: /home/gerrit2/acls/openstack-infra/ansible-system.config
+  description: Ansible role for running puppet
+  groups:
+    - openstack-ci
 - project: openstack-infra/askbot-theme
   use-storyboard: true
   groups:
diff --git a/gerritbot/channels.yaml b/gerritbot/channels.yaml
index 05932a76ac..3f1edc44bc 100644
--- a/gerritbot/channels.yaml
+++ b/gerritbot/channels.yaml
@@ -8,6 +8,7 @@ openstack-infra:
       - openstack-dev/hacking
       - openstack-dev/pbr
       - openstack-dev/specs-cookiecutter
+      - openstack-infra/ansible-puppet
       - openstack-infra/askbot-theme
       - openstack-infra/bugdaystats
       - openstack-infra/devstack-gate
diff --git a/jenkins/jobs/ansible-role-jobs.yaml b/jenkins/jobs/ansible-role-jobs.yaml
new file mode 100644
index 0000000000..990105ee42
--- /dev/null
+++ b/jenkins/jobs/ansible-role-jobs.yaml
@@ -0,0 +1,19 @@
+- job-template:
+    name: 'gate-{name}-ansible-lint'
+    node: '{node}'
+
+    builders:
+      - ansible-prep
+      - ansible-lint-prep
+      - revoke-sudo
+      - gerrit-git-prep
+      - ansible-syntax
+      - ansible-lint
+
+    publishers:
+      - console-log
+
+- job-group:
+    name: 'ansible-lint-jobs'
+    jobs:
+      - 'gate-{name}-ansible-lint'
diff --git a/jenkins/jobs/macros.yaml b/jenkins/jobs/macros.yaml
index 618d610d52..98049bc53e 100644
--- a/jenkins/jobs/macros.yaml
+++ b/jenkins/jobs/macros.yaml
@@ -162,6 +162,35 @@
           #!/bin/bash -xe
           sudo scripts/gate-check-commit.sh
 
+- builder:
+    name: ansible-prep
+    builders:
+      - shell: |
+          #!/bin/bash -xe
+          sudo -H pip install -U ansible
+
+- builder:
+    name: ansible-syntax
+    builders:
+      - shell: |
+          #!/bin/bash -xe
+          cd tests
+          ansible-playbook --syntax-check -i inventory test.yml -e rolename=$(basename $(dirname $(pwd)))
+
+- builder:
+    name: ansible-lint-prep
+    builders:
+      - shell: |
+          #!/bin/bash -xe
+          sudo -H pip install ansible-lint
+
+- builder:
+    name: ansible-lint
+    builders:
+      - shell: |
+          #!/bin/bash -xe
+          ansible-lint **/*.yml
+
 - builder:
     name: ruby-191-prep
     builders:
diff --git a/jenkins/jobs/projects.yaml b/jenkins/jobs/projects.yaml
index cf59c3ed48..189de59e1e 100755
--- a/jenkins/jobs/projects.yaml
+++ b/jenkins/jobs/projects.yaml
@@ -1915,6 +1915,14 @@
 # Section: OpenStack infrastructure projects
 ########################################################################
 
+- project:
+    name: ansible-puppet
+    node: 'bare-precise || bare-trusty'
+    tarball-site: tarballs.openstack.org
+
+    jobs:
+      - ansible-lint-jobs
+
 - project:
     name: bugdaystats
     node: 'bare-precise || bare-trusty'
diff --git a/zuul/layout.yaml b/zuul/layout.yaml
index 6556237055..de7eda397b 100755
--- a/zuul/layout.yaml
+++ b/zuul/layout.yaml
@@ -464,6 +464,12 @@ project-templates:
     gate:
       - noop
 
+  - name: ansible-lint-jobs
+    check:
+      - gate-{name}-ansible-lint
+    gate:
+      - gate-{name}-ansible-lint
+
   - name: puppet-beaker-jobs
     check:
       - gate-{name}-puppet-beaker-rspec
@@ -3145,6 +3151,11 @@ projects:
       - name: merge-check
       - name: noop-jobs
 
+  - name: openstack-infra/ansible-puppet
+    template:
+      - name: merge-check
+      - name: ansible-lint-jobs
+
   - name: openstack-infra/askbot-theme
     template:
       - name: merge-check