Add CI/CD infrastructure

Change-Id: Id15634c2096394f7de4533c8466e0e0c2e66f8ed
diff --git a/docker/client.yml b/docker/client.yml
new file mode 100644
index 0000000..4691ddb
--- /dev/null
+++ b/docker/client.yml
@@ -0,0 +1,10 @@
+classes:
+  - service.docker.client
+parameters:
+  docker:
+    client:
+      enabled: true
+      compose:
+        source:
+          engine: docker
+          image: "docker/compose:1.8.0"
diff --git a/docker/host.yml b/docker/host.yml
new file mode 100644
index 0000000..cf19bfd
--- /dev/null
+++ b/docker/host.yml
@@ -0,0 +1,9 @@
+classes:
+  - service.docker.host
+  - system.linux.system.repo.docker
+parameters:
+  docker:
+    host:
+      insecure_registries:
+        - ${_param:cluster_vip_address}:5000
+        - ${_param:cluster_public_host}:5000
diff --git a/docker/swarm/manager.yml b/docker/swarm/manager.yml
new file mode 100644
index 0000000..36f5bcb
--- /dev/null
+++ b/docker/swarm/manager.yml
@@ -0,0 +1,7 @@
+parameters:
+  docker:
+    swarm:
+      role: manager
+      advertise_addr: ${_param:single_address}
+      master:
+        host: ${_param:cluster_node01_address}
diff --git a/docker/swarm/master.yml b/docker/swarm/master.yml
new file mode 100644
index 0000000..bb2d83b
--- /dev/null
+++ b/docker/swarm/master.yml
@@ -0,0 +1,5 @@
+parameters:
+  docker:
+    swarm:
+      role: master
+      advertise_addr: ${_param:single_address}
diff --git a/docker/swarm/service/aptly.yml b/docker/swarm/service/aptly.yml
new file mode 100644
index 0000000..d85b1b4
--- /dev/null
+++ b/docker/swarm/service/aptly.yml
@@ -0,0 +1,29 @@
+parameters:
+  docker:
+    client:
+      service:
+        aptly-api:
+          environment:
+            EMAIL_ADDRESS: ${_param:admin_email}
+          restart:
+            condition: any
+          image: ${_param:docker_image_aptly:api}
+          ports:
+            - 18084:8080
+          volume:
+            site:
+              type: bind
+              source: /srv/volumes/aptly
+              destination: /var/lib/aptly
+        aptly-public:
+          replicas: 3
+          restart:
+            condition: any
+          image: ${_param:docker_image_aptly:public}
+          ports:
+            - 18085:80
+          volume:
+            site:
+              type: bind
+              source: /srv/volumes/aptly/public
+              destination: /var/www/html
diff --git a/docker/swarm/service/artifactory.yml b/docker/swarm/service/artifactory.yml
new file mode 100644
index 0000000..d7f8626
--- /dev/null
+++ b/docker/swarm/service/artifactory.yml
@@ -0,0 +1,32 @@
+parameters:
+  docker:
+    client:
+      service:
+        artifactory:
+          environment:
+            MYSQL_HOST: ${_param:cluster_vip_address}
+            MYSQL_USERNAME: artifactory
+            MYSQL_PASSWORD: ${_param:mysql_artifactory_password}
+            MYSQL_DATABASE: artifactory
+          restart:
+            condition: any
+          image: ${_param:docker_image_repository:cicd}/artifactory
+          ports:
+            - 18082:8081
+          volume:
+            data:
+              type: bind
+              source: /srv/volumes/artifactory/data
+              destination: /var/opt/jfrog/artifactory/data
+            backup:
+              type: bind
+              source: /srv/volumes/artifactory/backup
+              destination: /var/opt/jfrog/artifactory/backup
+            etc:
+              type: bind
+              source: /srv/volumes/artifactory/etc
+              destination: /var/opt/jfrog/artifactory/etc
+            logs:
+              type: bind
+              source: /srv/volumes/artifactory/logs
+              destination: /var/opt/jfrog/artifactory/logs
diff --git a/docker/swarm/service/docker.yml b/docker/swarm/service/docker.yml
new file mode 100644
index 0000000..a79fc08
--- /dev/null
+++ b/docker/swarm/service/docker.yml
@@ -0,0 +1,18 @@
+parameters:
+  docker:
+    client:
+      service:
+        registry:
+          replica: 3
+          environment:
+            REGISTRY_HTTP_SECRET: ${_param:docker_registry_http_secret}
+          restart:
+            condition: any
+          image: ${_param:docker_image_registry}
+          ports:
+            - 15000:5000
+          volume:
+            site:
+              type: bind
+              source: /srv/volumes/registry
+              destination: /var/lib/registry
diff --git a/docker/swarm/service/gerrit.yml b/docker/swarm/service/gerrit.yml
new file mode 100644
index 0000000..d1bdfae
--- /dev/null
+++ b/docker/swarm/service/gerrit.yml
@@ -0,0 +1,28 @@
+parameters:
+  docker:
+    client:
+      service:
+        gerrit:
+          environment:
+            #GERRIT_INIT_ARGS: ""
+            DATABASE_TYPE: "mysql"
+            DB_PORT_3306_TCP_ADDR: ${_param:cluster_vip_address}
+            DB_ENV_MYSQL_USER: gerrit
+            DB_ENV_MYSQL_PASSWORD: ${_param:mysql_gerrit_password}
+            DB_ENV_MYSQL_DB: gerrit
+            AUTH_TYPE: ${_param:gerrit_auth_type}
+            WEBURL: ${_param:gerrit_public_host}
+            GERRIT_ADMIN_SSH_PUBLIC: ${_param:gerrit_admin_public_key}
+            GERRIT_ADMIN_PWD: ${_param:gerrit_admin_password}
+            GERRIT_ADMIN_EMAIL: ${_param:gerrit_admin_email}
+          restart:
+            condition: any
+          image: ${_param:docker_image_gerrit}
+          ports:
+            - 18083:8080
+            - 29417:29418
+          volume:
+            site:
+              type: bind
+              source: /srv/volumes/gerrit
+              destination: /var/gerrit/review_site
diff --git a/docker/swarm/service/jenkins.yml b/docker/swarm/service/jenkins.yml
new file mode 100644
index 0000000..c0b0721
--- /dev/null
+++ b/docker/swarm/service/jenkins.yml
@@ -0,0 +1,23 @@
+parameters:
+  docker:
+    client:
+      service:
+        jenkins:
+          environment:
+            JAVA_OPTS: "-Djenkins.install.runSetupWizard=false -Dhudson.footerURL=https://www.mirantis.com"
+            JENKINS_NUM_EXECUTORS: 4
+          restart:
+            condition: any
+          image: ${_param:docker_image_jenkins}
+          ports:
+            - 18081:8080
+            - 50001:50000
+          volume:
+            home:
+              type: bind
+              source: /srv/volumes/jenkins
+              destination: /var/jenkins_home
+            cacerts:
+              type: bind
+              source: /etc/ssl/certs/java/cacerts
+              destination: /etc/ssl/certs/java/cacerts
diff --git a/docker/swarm/service/mysql.yml b/docker/swarm/service/mysql.yml
new file mode 100644
index 0000000..53faa8b
--- /dev/null
+++ b/docker/swarm/service/mysql.yml
@@ -0,0 +1,20 @@
+parameters:
+  docker:
+    client:
+      service:
+        mysql:
+          environment:
+            MYSQL_USER: gerrit
+            MYSQL_PASSWORD: ${_param:mysql_gerrit_password}
+            MYSQL_DATABASE: gerrit
+            MYSQL_ROOT_PASSWORD: ${_param:mysql_admin_password}
+          restart:
+            condition: any
+          image: "mysql:5.6"
+          ports:
+            - 13306:3306
+          volume:
+            data:
+              type: bind
+              source: /srv/volumes/mysql
+              destination: /var/lib/mysql
diff --git a/docker/swarm/service/openldap.yml b/docker/swarm/service/openldap.yml
new file mode 100644
index 0000000..d009ed5
--- /dev/null
+++ b/docker/swarm/service/openldap.yml
@@ -0,0 +1,32 @@
+parameters:
+  docker:
+    client:
+      service:
+        openldap:
+          # XXX: docker service is not able to set hostname
+          # https://github.com/docker/docker/issues/24877
+          restart:
+            condition: any
+          image: osixia/openldap:1.1.7
+          environment:
+            HOSTNAME: ldap01.${_param:cluster_public_host}
+            LDAP_ORGANISATION: "${_param:openldap_organisation}"
+            LDAP_DOMAIN: "${_param:openldap_domain}"
+            LDAP_ADMIN_PASSWORD: ${_param:openldap_admin_password}
+            LDAP_CONFIG_PASSWORD: ${_param:openldap_config_password}
+            LDAP_READONLY_USER: true
+            LDAP_READONLY_USER_USERNAME: readonly
+            LDAP_READONLY_USER_PASSWORD: ${_param:openldap_readonly_password}
+            LDAP_TLS: false
+          ports:
+            - 389:389
+            - 636:636
+          volume:
+            database:
+              type: bind
+              source: /srv/volumes/openldap/database
+              destination: /var/lib/ldap
+            config:
+              type: bind
+              source: /srv/volumes/openldap/config
+              destination: /etc/ldap/slapd.d
diff --git a/docker/swarm/service/visualizer.yml b/docker/swarm/service/visualizer.yml
new file mode 100644
index 0000000..fe52c0b
--- /dev/null
+++ b/docker/swarm/service/visualizer.yml
@@ -0,0 +1,16 @@
+parameters:
+  docker:
+    client:
+      service:
+        visualizer:
+          restart:
+            condition: any
+          image: manomarks/visualizer
+          constraint: "node.role==manager"
+          ports:
+            - 18090:8080
+          volume:
+            docker:
+              type: bind
+              source: /var/run/docker.sock
+              destination: /var/run/docker.sock
diff --git a/docker/swarm/worker.yml b/docker/swarm/worker.yml
new file mode 100644
index 0000000..acdb0cf
--- /dev/null
+++ b/docker/swarm/worker.yml
@@ -0,0 +1,7 @@
+parameters:
+  docker:
+    swarm:
+      role: worker
+      advertise_addr: ${_param:single_address}
+      master:
+        host: ${_param:cluster_node01_address}