commit 150f550d898fedc632336086fee78d8699e098d4
Author: Ricardo Carrillo Cruz <ricardo.carrillo.cruz@gmail.com>
Date:   Fri Mar 27 09:47:58 2015 +0100

    Initial commit

diff --git a/gerrit.yml b/gerrit.yml
new file mode 100644
index 0000000..e69de29
diff --git a/hosts b/hosts
new file mode 100644
index 0000000..75474c8
--- /dev/null
+++ b/hosts
@@ -0,0 +1,2 @@
+[local]
+127.0.0.1
diff --git a/instances_config.yml b/instances_config.yml
new file mode 100644
index 0000000..0de2fa7
--- /dev/null
+++ b/instances_config.yml
@@ -0,0 +1,27 @@
+---
+instances_config:
+  - name: puppetdb.infra.test.rcarrillocruz.cloud
+    image: 9d25fe2d-cf31-4b05-8c58-f238ec78e633
+    flavor: standard.small
+    net_name: infra-test-network
+    node_type: puppetdb
+  - name: puppetmaster.infra.test.rcarrillocruz.cloud
+    image: 9d25fe2d-cf31-4b05-8c58-f238ec78e633
+    flavor: standard.small
+    net_name: infra-test-network
+    node_type: puppetmaster
+  - name: jenkins.infra.test.rcarrillocruz.cloud
+    image: 9d25fe2d-cf31-4b05-8c58-f238ec78e633
+    flavor: standard.small
+    net_name: infra-test-network
+    node_type: jenkins
+  - name: gerrit.infra.test.rcarrillocruz.cloud
+    image: 9d25fe2d-cf31-4b05-8c58-f238ec78e633
+    flavor: standard.small
+    net_name: infra-test-network
+    node_type: gerrit
+  - name: nodepool.infra.test.rcarrillocruz.cloud
+    image: 9d25fe2d-cf31-4b05-8c58-f238ec78e633
+    flavor: standard.small
+    net_name: infra-test-network
+    node_type: nodepool
diff --git a/jenkins.yml b/jenkins.yml
new file mode 100644
index 0000000..e69de29
diff --git a/nodepool.yml b/nodepool.yml
new file mode 100644
index 0000000..e69de29
diff --git a/provision.yml b/provision.yml
new file mode 100644
index 0000000..93b0453
--- /dev/null
+++ b/provision.yml
@@ -0,0 +1,6 @@
+---
+# file: provision.yml
+- hosts: localhost
+  connection: local
+  roles:
+    - { role: create_openstack_instances }
diff --git a/puppetdb.yml b/puppetdb.yml
new file mode 100644
index 0000000..d55dde6
--- /dev/null
+++ b/puppetdb.yml
@@ -0,0 +1,9 @@
+---
+# file: puppetdb.yml
+
+- hosts: puppetdb
+  user: ubuntu
+  sudo: yes
+  roles:
+    - { role: common }
+    - { role: configure_puppetdb }
diff --git a/puppetmaster.yml b/puppetmaster.yml
new file mode 100644
index 0000000..e69de29
diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml
new file mode 100644
index 0000000..787a53f
--- /dev/null
+++ b/roles/common/tasks/main.yml
@@ -0,0 +1,31 @@
+---
+# Set hostname and /etc/hosts 
+# (Taken from https://github.com/ansible/ansible/pull/8482)
+- set_fact: full_hostname="{{ inventory_hostname}}"
+            short_hostname="{{ inventory_hostname.split('.', 1)[0] }}"
+
+# " lovely lonely double-quote for fixing vim highlighting
+
+- hostname: name={{ short_hostname }}
+
+- name: add hostname to /etc/hosts
+  lineinfile: dest=/etc/hosts
+              line='{{ hostvars[inventory_hostname]['openstack']['private_v4']}} {{ full_hostname }} {{ short_hostname }}'
+              insertafter='^127\.0\.0\.1'
+              state=present
+
+# Update packages
+- apt: update_cache=yes
+
+# Install git
+- apt: name=git
+
+# Clone system-config 
+- git: repo=https://git.openstack.org/openstack-infra/system-config
+       dest=/opt/git/system-config
+
+# Install puppet
+- command: bash /opt/git/system-config/install_puppet.sh
+
+# Install puppet modules
+- command: bash /opt/git/system-config/install_modules.sh
diff --git a/roles/configure_puppetdb/tasks/main.yml b/roles/configure_puppetdb/tasks/main.yml
new file mode 100644
index 0000000..c07a36c
--- /dev/null
+++ b/roles/configure_puppetdb/tasks/main.yml
@@ -0,0 +1,3 @@
+---
+# Puppet apply the puppetdb manifest
+- command: puppet apply --modulepath='/opt/git/system-config/modules:/etc/puppet/modules' -e 'include openstack_project::puppetdb'
diff --git a/roles/configure_puppetmaster/tasks/main.yml b/roles/configure_puppetmaster/tasks/main.yml
new file mode 100644
index 0000000..c7ac66f
--- /dev/null
+++ b/roles/configure_puppetmaster/tasks/main.yml
@@ -0,0 +1,12 @@
+---
+# Install puppetmaster packages
+- apt: name={{ item }} state=installed
+  with_items:
+    - puppetmaster-passenger
+    - hiera
+    - hiera-puppet
+
+# Puppet apply the puppetmaster manifest
+- command: > 
+    puppet apply --modulepath='/opt/git/system-config/modules:/etc/puppet/modules' 
+    -e 'class {"openstack_project::puppetmaster"':' puppetdb_server => "{{ hostvars[groups['puppetdb'][0]]['openstack']['name'] }}" }'
diff --git a/roles/create_openstack_instances/tasks/main.yml b/roles/create_openstack_instances/tasks/main.yml
new file mode 100644
index 0000000..b104cba
--- /dev/null
+++ b/roles/create_openstack_instances/tasks/main.yml
@@ -0,0 +1,19 @@
+- name: Create OpenStack instances
+  os_server:
+    state: present
+    cloud: openstack
+    name: "{{ item.name }}"
+    region_name: region-b.geo-1
+    availability_zone: az2
+    image: "{{ item.image }}"
+    key_name: workstation
+    timeout: 200
+    flavor: "{{ item.flavor }}"
+    nics:
+      - net-name: "{{ item.net_name }}"
+    security_groups: default
+    auto_floating_ip: yes
+    meta: 
+      group: infra
+      node_type: "{{ item.node_type }}"
+  with_items: instances_config
diff --git a/site.yml b/site.yml
new file mode 100644
index 0000000..d9f6814
--- /dev/null
+++ b/site.yml
@@ -0,0 +1,8 @@
+---
+# file: site.yml
+- include: provision
+- include: puppetdb
+- include: puppetmaster
+- include: jenkins
+- include: gerrit
+- include: nodepool