diff --git a/doc/source/admin/components.rst b/doc/source/admin/components.rst
index ba14752..84ebc10 100644
--- a/doc/source/admin/components.rst
+++ b/doc/source/admin/components.rst
@@ -660,6 +660,16 @@
       Base URL on which the websocket service is exposed, if different
       than the base URL of the web app.
 
+   .. attr:: stats_url
+
+      Base URL from which statistics emitted via statsd can be queried.
+
+   .. attr:: stats_type
+      :default: graphite
+
+      Type of server hosting the statistics information. Currently only
+      'graphite' is supported by the dashboard.
+
    .. attr:: static_cache_expiry
       :default: 3600
 
diff --git a/doc/source/user/config.rst b/doc/source/user/config.rst
index 8492423..0932c56 100644
--- a/doc/source/user/config.rst
+++ b/doc/source/user/config.rst
@@ -710,6 +710,21 @@
       timeout is supplied, the job may run indefinitely.  Supplying a
       timeout is highly recommended.
 
+      This timeout only applies to the pre-run and run playbooks in a
+      job.
+
+   .. attr:: post-timeout
+
+      The time in seconds that each post playbook should be allowed to run
+      before it is automatically aborted and failure is reported.  If no
+      post-timeout is supplied, the job may run indefinitely.  Supplying a
+      post-timeout is highly recommended.
+
+      The post-timeout is handled separately from the above timeout because
+      the post playbooks are typically where you will copy jobs logs.
+      In the event of the pre-run or run playbooks timing out we want to
+      do our best to copy the job logs in the post-run playbooks.
+
    .. attr:: attempts
       :default: 3
 
@@ -862,6 +877,48 @@
       same name will override a previously defined variable, but new
       variable names will be added to the set of defined variables.
 
+   .. attr:: host_vars
+
+      A dictionary of host variables to supply to Ansible.  The keys
+      of this dictionary are node names as defined in a
+      :ref:`nodeset`, and the values are dictionaries of variables,
+      just as in :attr:`job.vars`.
+
+   .. attr:: group_vars
+
+      A dictionary of group variables to supply to Ansible.  The keys
+      of this dictionary are node groups as defined in a
+      :ref:`nodeset`, and the values are dictionaries of variables,
+      just as in :attr:`job.vars`.
+
+   An example of three kinds of variables:
+
+   .. code-block:: yaml
+
+      - job:
+          name: variable-example
+          nodeset:
+            nodes:
+              - name: controller
+                label: fedora-27
+              - name: api1
+                label: centos-7
+              - name: api2
+                label: centos-7
+            groups:
+              - name: api
+                nodes:
+                  - api1
+                  - api2
+         vars:
+           foo: "this variable is visible to all nodes"
+         host_vars:
+           controller:
+             bar: "this variable is visible only on the controller node"
+         group_vars:
+           api:
+             baz: "this variable is visible on api1 and api2"
+
    .. attr:: dependencies
 
       A list of other jobs upon which this job depends.  Zuul will not
diff --git a/doc/source/user/jobs.rst b/doc/source/user/jobs.rst
index 820e316..4e1c33d 100644
--- a/doc/source/user/jobs.rst
+++ b/doc/source/user/jobs.rst
@@ -289,6 +289,10 @@
 
       The job timeout, in seconds.
 
+   .. var:: post_timeout
+
+      The post-run playbook timeout, in seconds.
+
    .. var:: jobtags
 
       A list of tags associated with the job.  Not to be confused with
diff --git a/etc/status/public_html/jquery.zuul.js b/etc/status/public_html/jquery.zuul.js
index 50dbed5..ac8a302 100644
--- a/etc/status/public_html/jquery.zuul.js
+++ b/etc/status/public_html/jquery.zuul.js
@@ -49,7 +49,7 @@
         options = $.extend({
             'enabled': true,
             'graphite_url': '',
-            'source': 'status.json',
+            'source': 'status',
             'msg_id': '#zuul_msg',
             'pipelines_id': '#zuul_pipelines',
             'queue_events_num': '#zuul_queue_events_num',
diff --git a/etc/status/public_html/zuul.app.js b/etc/status/public_html/zuul.app.js
index bf90a4d..6e35eb3 100644
--- a/etc/status/public_html/zuul.app.js
+++ b/etc/status/public_html/zuul.app.js
@@ -55,7 +55,7 @@
     var demo = location.search.match(/[?&]demo=([^?&]*)/),
         source_url = location.search.match(/[?&]source_url=([^?&]*)/),
         source = demo ? './status-' + (demo[1] || 'basic') + '.json-sample' :
-            'status.json';
+            'status';
     source = source_url ? source_url[1] : source;
 
     var zuul = $.zuul({
diff --git a/requirements.txt b/requirements.txt
index 7057c5a..115b096 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,8 +4,6 @@
 # is in a release
 git+https://github.com/sigmavirus24/github3.py.git@develop#egg=Github3.py
 PyYAML>=3.1.0
-Paste
-WebOb>=1.2.3
 paramiko>=2.0.1
 GitPython>=2.1.8
 python-daemon>=2.0.4,<2.1.0
diff --git a/tests/base.py b/tests/base.py
index 2e0ea1c..013a6e1 100755
--- a/tests/base.py
+++ b/tests/base.py
@@ -1350,7 +1350,7 @@
                 host['host_vars']['ansible_connection'] = 'local'
 
         hosts.append(dict(
-            name=['localhost'],
+            name='localhost',
             host_vars=dict(ansible_connection='local'),
             host_keys=[]))
         return hosts
@@ -1857,7 +1857,7 @@
         # from libraries that zuul depends on such as gear.
         log_defaults_from_env = os.environ.get(
             'OS_LOG_DEFAULTS',
-            'git.cmd=INFO,kazoo.client=WARNING,gear=INFO,paste=INFO')
+            'git.cmd=INFO,kazoo.client=WARNING,gear=INFO')
 
         if log_defaults_from_env:
             for default in log_defaults_from_env.split(','):
diff --git a/tests/fixtures/config/ansible/git/common-config/playbooks/check-hostvars.yaml b/tests/fixtures/config/ansible/git/common-config/playbooks/check-hostvars.yaml
new file mode 100644
index 0000000..36e0eca
--- /dev/null
+++ b/tests/fixtures/config/ansible/git/common-config/playbooks/check-hostvars.yaml
@@ -0,0 +1,26 @@
+- hosts: host1
+  tasks:
+    - name: Assert hostvar is present.
+      assert:
+        that:
+          - allvar == 'all'
+          - hostvar == 'host'
+          - groupvar is not defined
+
+- hosts: host2
+  tasks:
+    - name: Assert groupvar is present.
+      assert:
+        that:
+          - allvar == 'all'
+          - hostvar is not defined
+          - groupvar == 'group'
+
+- hosts: host3
+  tasks:
+    - name: Assert groupvar is present.
+      assert:
+        that:
+          - allvar == 'all'
+          - hostvar is not defined
+          - groupvar == 'group'
diff --git a/tests/fixtures/config/ansible/git/common-config/zuul.yaml b/tests/fixtures/config/ansible/git/common-config/zuul.yaml
index d0a8f7b..13a19da 100644
--- a/tests/fixtures/config/ansible/git/common-config/zuul.yaml
+++ b/tests/fixtures/config/ansible/git/common-config/zuul.yaml
@@ -99,6 +99,12 @@
 
 - job:
     parent: python27
+    name: post-timeout
+    post-run: playbooks/timeout.yaml
+    post-timeout: 1
+
+- job:
+    parent: python27
     name: check-vars
     run: playbooks/check-vars.yaml
     nodeset:
@@ -115,6 +121,32 @@
 
 - job:
     parent: python27
+    name: check-hostvars
+    run: playbooks/check-hostvars.yaml
+    nodeset:
+      nodes:
+        - name: host1
+          label: ubuntu-xenial
+        - name: host2
+          label: ubuntu-xenial
+        - name: host3
+          label: ubuntu-xenial
+      groups:
+        - name: group1
+          nodes:
+            - host2
+            - host3
+    vars:
+      allvar: all
+    host_vars:
+      host1:
+        hostvar: host
+    group_vars:
+      group1:
+        groupvar: group
+
+- job:
+    parent: python27
     name: check-secret-names
     run: playbooks/check-secret-names.yaml
     nodeset:
diff --git a/tests/fixtures/config/ansible/git/org_project/.zuul.yaml b/tests/fixtures/config/ansible/git/org_project/.zuul.yaml
index 447f6cd..e332924 100644
--- a/tests/fixtures/config/ansible/git/org_project/.zuul.yaml
+++ b/tests/fixtures/config/ansible/git/org_project/.zuul.yaml
@@ -15,7 +15,9 @@
         - python27
         - faillocal
         - check-vars
+        - check-hostvars
         - check-secret-names
         - timeout
+        - post-timeout
         - hello-world
         - failpost
diff --git a/tests/unit/test_executor.py b/tests/unit/test_executor.py
index 46e1d99..c67eb55 100755
--- a/tests/unit/test_executor.py
+++ b/tests/unit/test_executor.py
@@ -425,12 +425,14 @@
         node = {'name': 'fake-host',
                 'host_keys': ['fake-host-key'],
                 'interface_ip': 'localhost'}
-        keys = self.test_job.getHostList({'nodes': [node]})[0]['host_keys']
+        keys = self.test_job.getHostList({'nodes': [node],
+                                          'host_vars': {}})[0]['host_keys']
         self.assertEqual(keys[0], 'localhost fake-host-key')
 
         # Test with custom connection_port set
         node['connection_port'] = 22022
-        keys = self.test_job.getHostList({'nodes': [node]})[0]['host_keys']
+        keys = self.test_job.getHostList({'nodes': [node],
+                                          'host_vars': {}})[0]['host_keys']
         self.assertEqual(keys[0], '[localhost]:22022 fake-host-key')
 
 
diff --git a/tests/unit/test_model.py b/tests/unit/test_model.py
index 5c586ca..6ec5232 100644
--- a/tests/unit/test_model.py
+++ b/tests/unit/test_model.py
@@ -23,6 +23,7 @@
 from zuul import configloader
 from zuul.lib import encryption
 from zuul.lib import yamlutil as yaml
+import zuul.lib.connections
 
 from tests.base import BaseTestCase, FIXTURE_DIR
 
@@ -36,6 +37,8 @@
 class TestJob(BaseTestCase):
     def setUp(self):
         super(TestJob, self).setUp()
+        self.connections = zuul.lib.connections.ConnectionRegistry()
+        self.addCleanup(self.connections.stop)
         self.connection = Dummy(connection_name='dummy_connection')
         self.source = Dummy(canonical_hostname='git.example.com',
                             connection=self.connection)
@@ -47,6 +50,9 @@
         self.pipeline = model.Pipeline('gate', self.layout)
         self.layout.addPipeline(self.pipeline)
         self.queue = model.ChangeQueue(self.pipeline)
+        self.pcontext = configloader.ParseContext(
+            self.connections, None, self.tenant, self.layout)
+        self.pcontext.setPipelines()
 
         private_key_file = os.path.join(FIXTURE_DIR, 'private.pem')
         with open(private_key_file, "rb") as f:
@@ -61,9 +67,7 @@
 
     @property
     def job(self):
-        tenant = model.Tenant('tenant')
-        layout = model.Layout(tenant)
-        job = configloader.JobParser.fromYaml(tenant, layout, {
+        job = self.pcontext.job_parser.fromYaml({
             '_source_context': self.context,
             '_start_mark': self.start_mark,
             'name': 'job',
@@ -147,33 +151,27 @@
             job.applyVariant(bad_final)
 
     def test_job_inheritance_job_tree(self):
-        tenant = model.Tenant('tenant')
-        layout = model.Layout(tenant)
-
-        tpc = model.TenantProjectConfig(self.project)
-        tenant.addUntrustedProject(tpc)
-
-        pipeline = model.Pipeline('gate', layout)
-        layout.addPipeline(pipeline)
+        pipeline = model.Pipeline('gate', self.layout)
+        self.layout.addPipeline(pipeline)
         queue = model.ChangeQueue(pipeline)
 
-        base = configloader.JobParser.fromYaml(tenant, layout, {
+        base = self.pcontext.job_parser.fromYaml({
             '_source_context': self.context,
             '_start_mark': self.start_mark,
             'name': 'base',
             'parent': None,
             'timeout': 30,
         })
-        layout.addJob(base)
-        python27 = configloader.JobParser.fromYaml(tenant, layout, {
+        self.layout.addJob(base)
+        python27 = self.pcontext.job_parser.fromYaml({
             '_source_context': self.context,
             '_start_mark': self.start_mark,
             'name': 'python27',
             'parent': 'base',
             'timeout': 40,
         })
-        layout.addJob(python27)
-        python27diablo = configloader.JobParser.fromYaml(tenant, layout, {
+        self.layout.addJob(python27)
+        python27diablo = self.pcontext.job_parser.fromYaml({
             '_source_context': self.context,
             '_start_mark': self.start_mark,
             'name': 'python27',
@@ -182,13 +180,9 @@
             ],
             'timeout': 50,
         })
-        layout.addJob(python27diablo)
+        self.layout.addJob(python27diablo)
 
-        project_template_parser = configloader.ProjectTemplateParser(
-            tenant, layout)
-        project_parser = configloader.ProjectParser(
-            tenant, layout, project_template_parser)
-        project_config = project_parser.fromYaml([{
+        project_config = self.pcontext.project_parser.fromYaml([{
             '_source_context': self.context,
             '_start_mark': self.start_mark,
             'name': 'project',
@@ -199,12 +193,12 @@
                 ]
             }
         }])
-        layout.addProjectConfig(project_config)
+        self.layout.addProjectConfig(project_config)
 
         change = model.Change(self.project)
         change.branch = 'master'
         item = queue.enqueueChange(change)
-        item.layout = layout
+        item.layout = self.layout
 
         self.assertTrue(base.changeMatches(change))
         self.assertTrue(python27.changeMatches(change))
@@ -218,7 +212,7 @@
 
         change.branch = 'stable/diablo'
         item = queue.enqueueChange(change)
-        item.layout = layout
+        item.layout = self.layout
 
         self.assertTrue(base.changeMatches(change))
         self.assertTrue(python27.changeMatches(change))
@@ -231,25 +225,19 @@
         self.assertEqual(job.timeout, 70)
 
     def test_inheritance_keeps_matchers(self):
-        tenant = model.Tenant('tenant')
-        layout = model.Layout(tenant)
-
-        pipeline = model.Pipeline('gate', layout)
-        layout.addPipeline(pipeline)
+        pipeline = model.Pipeline('gate', self.layout)
+        self.layout.addPipeline(pipeline)
         queue = model.ChangeQueue(pipeline)
-        project = model.Project('project', self.source)
-        tpc = model.TenantProjectConfig(project)
-        tenant.addUntrustedProject(tpc)
 
-        base = configloader.JobParser.fromYaml(tenant, layout, {
+        base = self.pcontext.job_parser.fromYaml({
             '_source_context': self.context,
             '_start_mark': self.start_mark,
             'name': 'base',
             'parent': None,
             'timeout': 30,
         })
-        layout.addJob(base)
-        python27 = configloader.JobParser.fromYaml(tenant, layout, {
+        self.layout.addJob(base)
+        python27 = self.pcontext.job_parser.fromYaml({
             '_source_context': self.context,
             '_start_mark': self.start_mark,
             'name': 'python27',
@@ -257,13 +245,9 @@
             'timeout': 40,
             'irrelevant-files': ['^ignored-file$'],
         })
-        layout.addJob(python27)
+        self.layout.addJob(python27)
 
-        project_template_parser = configloader.ProjectTemplateParser(
-            tenant, layout)
-        project_parser = configloader.ProjectParser(
-            tenant, layout, project_template_parser)
-        project_config = project_parser.fromYaml([{
+        project_config = self.pcontext.project_parser.fromYaml([{
             '_source_context': self.context,
             '_start_mark': self.start_mark,
             'name': 'project',
@@ -273,13 +257,13 @@
                 ]
             }
         }])
-        layout.addProjectConfig(project_config)
+        self.layout.addProjectConfig(project_config)
 
-        change = model.Change(project)
+        change = model.Change(self.project)
         change.branch = 'master'
         change.files = ['/COMMIT_MSG', 'ignored-file']
         item = queue.enqueueChange(change)
-        item.layout = layout
+        item.layout = self.layout
 
         self.assertTrue(base.changeMatches(change))
         self.assertFalse(python27.changeMatches(change))
@@ -288,28 +272,26 @@
         self.assertEqual([], item.getJobs())
 
     def test_job_source_project(self):
-        tenant = self.tenant
-        layout = self.layout
         base_project = model.Project('base_project', self.source)
         base_context = model.SourceContext(base_project, 'master',
                                            'test', True)
         tpc = model.TenantProjectConfig(base_project)
-        tenant.addUntrustedProject(tpc)
+        self.tenant.addUntrustedProject(tpc)
 
-        base = configloader.JobParser.fromYaml(tenant, layout, {
+        base = self.pcontext.job_parser.fromYaml({
             '_source_context': base_context,
             '_start_mark': self.start_mark,
             'parent': None,
             'name': 'base',
         })
-        layout.addJob(base)
+        self.layout.addJob(base)
 
         other_project = model.Project('other_project', self.source)
         other_context = model.SourceContext(other_project, 'master',
                                             'test', True)
         tpc = model.TenantProjectConfig(other_project)
-        tenant.addUntrustedProject(tpc)
-        base2 = configloader.JobParser.fromYaml(tenant, layout, {
+        self.tenant.addUntrustedProject(tpc)
+        base2 = self.pcontext.job_parser.fromYaml({
             '_source_context': other_context,
             '_start_mark': self.start_mark,
             'name': 'base',
@@ -318,11 +300,11 @@
                 Exception,
                 "Job base in other_project is not permitted "
                 "to shadow job base in base_project"):
-            layout.addJob(base2)
+            self.layout.addJob(base2)
 
     def test_job_pipeline_allow_untrusted_secrets(self):
         self.pipeline.post_review = False
-        job = configloader.JobParser.fromYaml(self.tenant, self.layout, {
+        job = self.pcontext.job_parser.fromYaml({
             '_source_context': self.context,
             '_start_mark': self.start_mark,
             'name': 'job',
@@ -332,11 +314,7 @@
 
         self.layout.addJob(job)
 
-        project_template_parser = configloader.ProjectTemplateParser(
-            self.tenant, self.layout)
-        project_parser = configloader.ProjectParser(
-            self.tenant, self.layout, project_template_parser)
-        project_config = project_parser.fromYaml(
+        project_config = self.pcontext.project_parser.fromYaml(
             [{
                 '_source_context': self.context,
                 '_start_mark': self.start_mark,
diff --git a/tests/unit/test_v3.py b/tests/unit/test_v3.py
index 1338d20..f019ead 100755
--- a/tests/unit/test_v3.py
+++ b/tests/unit/test_v3.py
@@ -2033,6 +2033,8 @@
     tenant_config_file = 'config/ansible/main.yaml'
 
     def test_playbook(self):
+        # This test runs a bit long and needs extra time.
+        self.wait_timeout = 120
         # Keep the jobdir around so we can inspect contents if an
         # assert fails.
         self.executor_server.keep_jobdir = True
@@ -2048,6 +2050,12 @@
         build_timeout = self.getJobFromHistory('timeout')
         with self.jobLog(build_timeout):
             self.assertEqual(build_timeout.result, 'TIMED_OUT')
+            post_flag_path = os.path.join(self.test_root, build_timeout.uuid +
+                                          '.post.flag')
+            self.assertTrue(os.path.exists(post_flag_path))
+        build_post_timeout = self.getJobFromHistory('post-timeout')
+        with self.jobLog(build_post_timeout):
+            self.assertEqual(build_post_timeout.result, 'POST_FAILURE')
         build_faillocal = self.getJobFromHistory('faillocal')
         with self.jobLog(build_faillocal):
             self.assertEqual(build_faillocal.result, 'FAILURE')
diff --git a/tests/unit/test_web.py b/tests/unit/test_web.py
index b5ebe9f..602209f 100644
--- a/tests/unit/test_web.py
+++ b/tests/unit/test_web.py
@@ -22,20 +22,30 @@
 import urllib
 import time
 import socket
-from unittest import skip
-
-import webob
 
 import zuul.web
 
 from tests.base import ZuulTestCase, FIXTURE_DIR
 
 
-class TestWeb(ZuulTestCase):
+class FakeConfig(object):
+
+    def __init__(self, config):
+        self.config = config or {}
+
+    def has_option(self, section, option):
+        return option in self.config.get(section, {})
+
+    def get(self, section, option):
+        return self.config.get(section, {}).get(option)
+
+
+class BaseTestWeb(ZuulTestCase):
     tenant_config_file = 'config/single-tenant/main.yaml'
+    config_ini_data = {}
 
     def setUp(self):
-        super(TestWeb, self).setUp()
+        super(BaseTestWeb, self).setUp()
         self.executor_server.hold_jobs_in_build = True
         A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
         A.addApproval('Code-Review', 2)
@@ -45,10 +55,13 @@
         self.fake_gerrit.addEvent(B.addApproval('Approved', 1))
         self.waitUntilSettled()
 
+        self.zuul_ini_config = FakeConfig(self.config_ini_data)
         # Start the web server
         self.web = zuul.web.ZuulWeb(
             listen_address='127.0.0.1', listen_port=0,
-            gear_server='127.0.0.1', gear_port=self.gearman_server.port)
+            gear_server='127.0.0.1', gear_port=self.gearman_server.port,
+            info=zuul.model.WebInfo.fromConfig(self.zuul_ini_config)
+        )
         loop = asyncio.new_event_loop()
         loop.set_debug(True)
         ws_thread = threading.Thread(target=self.web.run, args=(loop,))
@@ -75,7 +88,10 @@
         self.executor_server.hold_jobs_in_build = False
         self.executor_server.release()
         self.waitUntilSettled()
-        super(TestWeb, self).tearDown()
+        super(BaseTestWeb, self).tearDown()
+
+
+class TestWeb(BaseTestWeb):
 
     def test_web_status(self):
         "Test that we can retrieve JSON status info"
@@ -89,7 +105,7 @@
         self.waitUntilSettled()
 
         req = urllib.request.Request(
-            "http://localhost:%s/tenant-one/status.json" % self.port)
+            "http://localhost:%s/tenant-one/status" % self.port)
         f = urllib.request.urlopen(req)
         headers = f.info()
         self.assertIn('Content-Length', headers)
@@ -184,7 +200,6 @@
             "http://localhost:%s/status/foo" % self.port)
         self.assertRaises(urllib.error.HTTPError, urllib.request.urlopen, req)
 
-    @skip("This is not supported by zuul-web")
     def test_web_find_change(self):
         # can we filter by change id
         req = urllib.request.Request(
@@ -213,24 +228,84 @@
         f = urllib.request.urlopen(req)
         self.assertEqual(f.read(), public_pem)
 
-    @skip("This may not apply to zuul-web")
-    def test_web_custom_handler(self):
-        def custom_handler(path, tenant_name, request):
-            return webob.Response(body='ok')
-
-        self.webapp.register_path('/custom', custom_handler)
-        req = urllib.request.Request(
-            "http://localhost:%s/custom" % self.port)
-        f = urllib.request.urlopen(req)
-        self.assertEqual(b'ok', f.read())
-
-        self.webapp.unregister_path('/custom')
-        self.assertRaises(urllib.error.HTTPError, urllib.request.urlopen, req)
-
-    @skip("This returns a 500")
     def test_web_404_on_unknown_tenant(self):
         req = urllib.request.Request(
-            "http://localhost:{}/non-tenant/status.json".format(self.port))
+            "http://localhost:{}/non-tenant/status".format(self.port))
         e = self.assertRaises(
             urllib.error.HTTPError, urllib.request.urlopen, req)
         self.assertEqual(404, e.code)
+
+
+class TestInfo(BaseTestWeb):
+
+    def setUp(self):
+        super(TestInfo, self).setUp()
+        web_config = self.config_ini_data.get('web', {})
+        self.websocket_url = web_config.get('websocket_url')
+        self.stats_url = web_config.get('stats_url')
+        statsd_config = self.config_ini_data.get('statsd', {})
+        self.stats_prefix = statsd_config.get('prefix')
+
+    def test_info(self):
+        req = urllib.request.Request(
+            "http://localhost:%s/info" % self.port)
+        f = urllib.request.urlopen(req)
+        info = json.loads(f.read().decode('utf8'))
+        self.assertEqual(
+            info, {
+                "info": {
+                    "endpoint": "http://localhost:%s" % self.port,
+                    "capabilities": {
+                        "job_history": False
+                    },
+                    "stats": {
+                        "url": self.stats_url,
+                        "prefix": self.stats_prefix,
+                        "type": "graphite",
+                    },
+                    "websocket_url": self.websocket_url,
+                }
+            })
+
+    def test_tenant_info(self):
+        req = urllib.request.Request(
+            "http://localhost:%s/tenant-one/info" % self.port)
+        f = urllib.request.urlopen(req)
+        info = json.loads(f.read().decode('utf8'))
+        self.assertEqual(
+            info, {
+                "info": {
+                    "endpoint": "http://localhost:%s" % self.port,
+                    "tenant": "tenant-one",
+                    "capabilities": {
+                        "job_history": False
+                    },
+                    "stats": {
+                        "url": self.stats_url,
+                        "prefix": self.stats_prefix,
+                        "type": "graphite",
+                    },
+                    "websocket_url": self.websocket_url,
+                }
+            })
+
+
+class TestWebSocketInfo(TestInfo):
+
+    config_ini_data = {
+        'web': {
+            'websocket_url': 'wss://ws.example.com'
+        }
+    }
+
+
+class TestGraphiteUrl(TestInfo):
+
+    config_ini_data = {
+        'statsd': {
+            'prefix': 'example'
+        },
+        'web': {
+            'stats_url': 'https://graphite.example.com',
+        }
+    }
diff --git a/tools/zuul-changes.py b/tools/zuul-changes.py
index d258354..cdedf51 100755
--- a/tools/zuul-changes.py
+++ b/tools/zuul-changes.py
@@ -24,7 +24,7 @@
 parser.add_argument('pipeline', help='The name of the Zuul pipeline')
 options = parser.parse_args()
 
-data = urllib2.urlopen('%s/status.json' % options.url).read()
+data = urllib2.urlopen('%s/status' % options.url).read()
 data = json.loads(data)
 
 for pipeline in data['pipelines']:
diff --git a/zuul/cmd/web.py b/zuul/cmd/web.py
index abdb1cb..8b0e3ee 100755
--- a/zuul/cmd/web.py
+++ b/zuul/cmd/web.py
@@ -20,6 +20,7 @@
 import threading
 
 import zuul.cmd
+import zuul.model
 import zuul.web
 
 from zuul.lib.config import get_default
@@ -33,8 +34,11 @@
         self.web.stop()
 
     def _run(self):
+        info = zuul.model.WebInfo.fromConfig(self.config)
+
         params = dict()
 
+        params['info'] = info
         params['listen_address'] = get_default(self.config,
                                                'web', 'listen_address',
                                                '127.0.0.1')
diff --git a/zuul/configloader.py b/zuul/configloader.py
index f0f78b7..3511f96 100644
--- a/zuul/configloader.py
+++ b/zuul/configloader.py
@@ -365,11 +365,12 @@
 
     schema = vs.Schema(pragma)
 
-    def __init__(self):
+    def __init__(self, pcontext):
         self.log = logging.getLogger("zuul.PragmaParser")
+        self.pcontext = pcontext
 
     def fromYaml(self, conf):
-        with configuration_exceptions('project-template', conf):
+        with configuration_exceptions('pragma', conf):
             self.schema(conf)
 
         bm = conf.get('implied-branch-matchers')
@@ -384,8 +385,13 @@
 
 
 class NodeSetParser(object):
-    @staticmethod
-    def getSchema(anonymous=False):
+    def __init__(self, pcontext):
+        self.log = logging.getLogger("zuul.NodeSetParser")
+        self.pcontext = pcontext
+        self.schema = self.getSchema(False)
+        self.anon_schema = self.getSchema(True)
+
+    def getSchema(self, anonymous=False):
         node = {vs.Required('name'): to_list(str),
                 vs.Required('label'): str,
                 }
@@ -404,9 +410,11 @@
             nodeset[vs.Required('name')] = str
         return vs.Schema(nodeset)
 
-    @staticmethod
-    def fromYaml(conf, anonymous=False):
-        NodeSetParser.getSchema(anonymous)(conf)
+    def fromYaml(self, conf, anonymous=False):
+        if anonymous:
+            self.anon_schema(conf)
+        else:
+            self.schema(conf)
         ns = model.NodeSet(conf.get('name'), conf.get('_source_context'))
         node_names = set()
         group_names = set()
@@ -432,8 +440,12 @@
 
 
 class SecretParser(object):
-    @staticmethod
-    def getSchema():
+    def __init__(self, pcontext):
+        self.log = logging.getLogger("zuul.SecretParser")
+        self.pcontext = pcontext
+        self.schema = self.getSchema()
+
+    def getSchema(self):
         data = {str: vs.Any(str, EncryptedPKCS1_OAEP)}
 
         secret = {vs.Required('name'): str,
@@ -444,10 +456,9 @@
 
         return vs.Schema(secret)
 
-    @staticmethod
-    def fromYaml(layout, conf):
+    def fromYaml(self, conf):
         with configuration_exceptions('secret', conf):
-            SecretParser.getSchema()(conf)
+            self.schema(conf)
         s = model.Secret(conf['name'], conf['_source_context'])
         s.secret_data = conf['data']
         return s
@@ -491,6 +502,7 @@
                       # validation happens in NodeSetParser
                       'nodeset': vs.Any(dict, str),
                       'timeout': int,
+                      'post-timeout': int,
                       'attempts': int,
                       'pre-run': to_list(str),
                       'post-run': to_list(str),
@@ -500,6 +512,8 @@
                       'roles': to_list(role),
                       'required-projects': to_list(vs.Any(job_project, str)),
                       'vars': dict,
+                      'host_vars': {str: dict},
+                      'group_vars': {str: dict},
                       'dependencies': to_list(str),
                       'allowed-projects': to_list(str),
                       'override-branch': str,
@@ -518,6 +532,7 @@
         'abstract',
         'protected',
         'timeout',
+        'post-timeout',
         'workspace',
         'voting',
         'hold-following-changes',
@@ -531,8 +546,11 @@
         'override-checkout',
     ]
 
-    @staticmethod
-    def _getImpliedBranches(tenant, job):
+    def __init__(self, pcontext):
+        self.log = logging.getLogger("zuul.JobParser")
+        self.pcontext = pcontext
+
+    def _getImpliedBranches(self, job):
         # If the user has set a pragma directive for this, use the
         # value (if unset, the value is None).
         if job.source_context.implied_branch_matchers is True:
@@ -549,7 +567,8 @@
 
         # If this project only has one branch, don't create implied
         # branch matchers.  This way central job repos can work.
-        branches = tenant.getProjectBranches(job.source_context.project)
+        branches = self.pcontext.tenant.getProjectBranches(
+            job.source_context.project)
         if len(branches) == 1:
             return None
 
@@ -557,12 +576,11 @@
             return job.source_context.implied_branches
         return [job.source_context.branch]
 
-    @staticmethod
-    def fromYaml(tenant, layout, conf, project_pipeline=False,
-                 name=None, validate=True):
+    def fromYaml(self, conf, project_pipeline=False, name=None,
+                 validate=True):
         if validate:
             with configuration_exceptions('job', conf):
-                JobParser.schema(conf)
+                self.schema(conf)
 
         if name is None:
             name = conf['name']
@@ -596,14 +614,16 @@
         for secret_config in as_list(conf.get('secrets', [])):
             if isinstance(secret_config, str):
                 secret_name = secret_config
-                secret = layout.secrets.get(secret_name)
+                secret = self.pcontext.layout.secrets.get(secret_name)
             else:
                 secret_name = secret_config['name']
-                secret = layout.secrets.get(secret_config['secret'])
+                secret = self.pcontext.layout.secrets.get(
+                    secret_config['secret'])
             if secret is None:
                 raise SecretNotFoundError(secret_name)
-            if secret_name == 'zuul':
-                raise Exception("Secrets named 'zuul' are not allowed.")
+            if secret_name == 'zuul' or secret_name == 'nodepool':
+                raise Exception("Secrets named 'zuul' or 'nodepool' "
+                                "are not allowed.")
             if not secret.source_context.isSameProject(job.source_context):
                 raise Exception(
                     "Unable to use secret %s.  Secrets must be "
@@ -623,9 +643,15 @@
         if secrets and not conf['_source_context'].trusted:
             job.post_review = True
 
-        if conf.get('timeout') and tenant.max_job_timeout != -1 and \
-           int(conf['timeout']) > tenant.max_job_timeout:
-            raise MaxTimeoutError(job, tenant)
+        if (conf.get('timeout') and
+            self.pcontext.tenant.max_job_timeout != -1 and
+            int(conf['timeout']) > self.pcontext.tenant.max_job_timeout):
+            raise MaxTimeoutError(job, self.pcontext.tenant)
+
+        if (conf.get('post-timeout') and
+            self.pcontext.tenant.max_job_timeout != -1 and
+            int(conf['post-timeout']) > self.pcontext.tenant.max_job_timeout):
+            raise MaxTimeoutError(job, self.pcontext.tenant)
 
         if 'post-review' in conf:
             if conf['post-review']:
@@ -640,13 +666,13 @@
         if 'roles' in conf:
             for role in conf.get('roles', []):
                 if 'zuul' in role:
-                    r = JobParser._makeZuulRole(tenant, job, role)
+                    r = self._makeZuulRole(job, role)
                     if r:
                         roles.append(r)
         # A job's repo should be an implicit role source for that job,
         # but not in a project-pipeline variant.
         if not project_pipeline:
-            r = JobParser._makeImplicitRole(job)
+            r = self._makeImplicitRole(job)
             roles.insert(0, r)
         job.addRoles(roles)
 
@@ -668,7 +694,7 @@
                                         job.roles, secrets)
             job.run = (run,)
 
-        for k in JobParser.simple_attributes:
+        for k in self.simple_attributes:
             a = k.replace('-', '_')
             if k in conf:
                 setattr(job, a, conf[k])
@@ -676,14 +702,15 @@
             conf_nodeset = conf['nodeset']
             if isinstance(conf_nodeset, str):
                 # This references an existing named nodeset in the layout.
-                ns = layout.nodesets.get(conf_nodeset)
+                ns = self.pcontext.layout.nodesets.get(conf_nodeset)
                 if ns is None:
                     raise NodesetNotFoundError(conf_nodeset)
             else:
-                ns = NodeSetParser.fromYaml(conf_nodeset, anonymous=True)
-            if tenant.max_nodes_per_job != -1 and \
-               len(ns) > tenant.max_nodes_per_job:
-                raise MaxNodeError(job, tenant)
+                ns = self.pcontext.nodeset_parser.fromYaml(
+                    conf_nodeset, anonymous=True)
+            if self.pcontext.tenant.max_nodes_per_job != -1 and \
+               len(ns) > self.pcontext.tenant.max_nodes_per_job:
+                raise MaxNodeError(job, self.pcontext.tenant)
             job.nodeset = ns
 
         if 'required-projects' in conf:
@@ -699,7 +726,8 @@
                     project_name = project
                     project_override_branch = None
                     project_override_checkout = None
-                (trusted, project) = tenant.getProject(project_name)
+                (trusted, project) = self.pcontext.tenant.getProject(
+                    project_name)
                 if project is None:
                     raise Exception("Unknown project %s" % (project_name,))
                 job_project = model.JobProject(project.canonical_name,
@@ -716,15 +744,30 @@
 
         variables = conf.get('vars', None)
         if variables:
-            if 'zuul' in variables:
-                raise Exception("Variables named 'zuul' are not allowed.")
+            if 'zuul' in variables or 'nodepool' in variables:
+                raise Exception("Variables named 'zuul' or 'nodepool' "
+                                "are not allowed.")
             job.variables = variables
+        host_variables = conf.get('host_vars', None)
+        if host_variables:
+            for host, hvars in host_variables.items():
+                if 'zuul' in hvars or 'nodepool' in hvars:
+                    raise Exception("Variables named 'zuul' or 'nodepool' "
+                                    "are not allowed.")
+            job.host_variables = host_variables
+        group_variables = conf.get('group_vars', None)
+        if group_variables:
+            for group, gvars in group_variables.items():
+                if 'zuul' in group_variables or 'nodepool' in gvars:
+                    raise Exception("Variables named 'zuul' or 'nodepool' "
+                                    "are not allowed.")
+            job.group_variables = group_variables
 
         allowed_projects = conf.get('allowed-projects', None)
         if allowed_projects:
             allowed = []
             for p in as_list(allowed_projects):
-                (trusted, project) = tenant.getProject(p)
+                (trusted, project) = self.pcontext.tenant.getProject(p)
                 if project is None:
                     raise Exception("Unknown project %s" % (p,))
                 allowed.append(project.name)
@@ -732,7 +775,7 @@
 
         branches = None
         if ('branches' not in conf):
-            branches = JobParser._getImpliedBranches(tenant, job)
+            branches = self._getImpliedBranches(job)
         if (not branches) and ('branches' in conf):
             branches = as_list(conf['branches'])
         if branches:
@@ -750,11 +793,10 @@
                 matchers)
         return job
 
-    @staticmethod
-    def _makeZuulRole(tenant, job, role):
+    def _makeZuulRole(self, job, role):
         name = role['zuul'].split('/')[-1]
 
-        (trusted, project) = tenant.getProject(role['zuul'])
+        (trusted, project) = self.pcontext.tenant.getProject(role['zuul'])
         if project is None:
             return None
 
@@ -762,8 +804,7 @@
                               project.connection_name,
                               project.name)
 
-    @staticmethod
-    def _makeImplicitRole(job):
+    def _makeImplicitRole(self, job):
         project = job.source_context.project
         name = project.name.split('/')[-1]
         name = JobParser.ANSIBLE_ROLE_RE.sub('', name)
@@ -774,10 +815,9 @@
 
 
 class ProjectTemplateParser(object):
-    def __init__(self, tenant, layout):
+    def __init__(self, pcontext):
         self.log = logging.getLogger("zuul.ProjectTemplateParser")
-        self.tenant = tenant
-        self.layout = layout
+        self.pcontext = pcontext
         self.schema = self.getSchema()
 
     def getSchema(self):
@@ -799,7 +839,7 @@
             'jobs': job_list,
         }
 
-        for p in self.layout.pipelines.values():
+        for p in self.pcontext.layout.pipelines.values():
             project_template[p.name] = pipeline_contents
         return vs.Schema(project_template)
 
@@ -810,7 +850,7 @@
         source_context = conf['_source_context']
         project_template = model.ProjectConfig(conf['name'], source_context)
         start_mark = conf['_start_mark']
-        for pipeline in self.layout.pipelines.values():
+        for pipeline in self.pcontext.layout.pipelines.values():
             conf_pipeline = conf.get(pipeline.name)
             if not conf_pipeline:
                 continue
@@ -839,19 +879,17 @@
             # validate that the job is existing
             with configuration_exceptions('project or project-template',
                                           attrs):
-                self.layout.getJob(jobname)
+                self.pcontext.layout.getJob(jobname)
 
-            job_list.addJob(JobParser.fromYaml(self.tenant, self.layout,
-                                               attrs, project_pipeline=True,
-                                               name=jobname, validate=False))
+            job_list.addJob(self.pcontext.job_parser.fromYaml(
+                attrs, project_pipeline=True,
+                name=jobname, validate=False))
 
 
 class ProjectParser(object):
-    def __init__(self, tenant, layout, project_template_parser):
+    def __init__(self, pcontext):
         self.log = logging.getLogger("zuul.ProjectParser")
-        self.tenant = tenant
-        self.layout = layout
-        self.project_template_parser = project_template_parser
+        self.pcontext = pcontext
         self.schema = self.getSchema()
 
     def getSchema(self):
@@ -874,7 +912,7 @@
             'jobs': job_list
         }
 
-        for p in self.layout.pipelines.values():
+        for p in self.pcontext.layout.pipelines.values():
             project[p.name] = pipeline_contents
         return vs.Schema(project)
 
@@ -885,7 +923,7 @@
 
         with configuration_exceptions('project', conf_list[0]):
             project_name = conf_list[0]['name']
-            (trusted, project) = self.tenant.getProject(project_name)
+            (trusted, project) = self.pcontext.tenant.getProject(project_name)
             if project is None:
                 raise ProjectNotFoundError(project_name)
             project_config = model.ProjectConfig(project.canonical_name)
@@ -903,16 +941,16 @@
                 # parsing the definition as a template, then applying
                 # all of the templates, including the newly parsed
                 # one, in order.
-                project_template = self.project_template_parser.fromYaml(
-                    conf, validate=False)
+                project_template = self.pcontext.project_template_parser.\
+                    fromYaml(conf, validate=False)
                 # If this project definition is in a place where it
                 # should get implied branch matchers, set it.
                 if (not conf['_source_context'].trusted):
                     implied_branch = conf['_source_context'].branch
                 for name in conf_templates:
-                    if name not in self.layout.project_templates:
+                    if name not in self.pcontext.layout.project_templates:
                         raise TemplateNotFoundError(name)
-                configs.extend([(self.layout.project_templates[name],
+                configs.extend([(self.pcontext.layout.project_templates[name],
                                  implied_branch)
                                 for name in conf_templates])
                 configs.append((project_template, implied_branch))
@@ -930,7 +968,7 @@
             project_config.merge_mode = model.MERGER_MAP['merge-resolve']
         if project_config.default_branch is None:
             project_config.default_branch = 'master'
-        for pipeline in self.layout.pipelines.values():
+        for pipeline in self.pcontext.layout.pipelines.values():
             project_pipeline = model.ProjectPipelineConfig()
             queue_name = None
             debug = False
@@ -958,8 +996,6 @@
 
 
 class PipelineParser(object):
-    log = logging.getLogger("zuul.PipelineParser")
-
     # A set of reporter configuration keys to action mapping
     reporter_actions = {
         'start': 'start_actions',
@@ -969,8 +1005,12 @@
         'disabled': 'disabled_actions',
     }
 
-    @staticmethod
-    def getDriverSchema(dtype, connections):
+    def __init__(self, pcontext):
+        self.log = logging.getLogger("zuul.PipelineParser")
+        self.pcontext = pcontext
+        self.schema = self.getSchema()
+
+    def getDriverSchema(self, dtype):
         methods = {
             'trigger': 'getTriggerSchema',
             'reporter': 'getReporterSchema',
@@ -980,15 +1020,15 @@
 
         schema = {}
         # Add the configured connections as available layout options
-        for connection_name, connection in connections.connections.items():
+        for connection_name, connection in \
+            self.pcontext.connections.connections.items():
             method = getattr(connection.driver, methods[dtype], None)
             if method:
                 schema[connection_name] = to_list(method())
 
         return schema
 
-    @staticmethod
-    def getSchema(layout, connections):
+    def getSchema(self):
         manager = vs.Any('independent',
                          'dependent')
 
@@ -1021,23 +1061,18 @@
                     '_source_context': model.SourceContext,
                     '_start_mark': ZuulMark,
                     }
-        pipeline['require'] = PipelineParser.getDriverSchema('require',
-                                                             connections)
-        pipeline['reject'] = PipelineParser.getDriverSchema('reject',
-                                                            connections)
-        pipeline['trigger'] = vs.Required(
-            PipelineParser.getDriverSchema('trigger', connections))
+        pipeline['require'] = self.getDriverSchema('require')
+        pipeline['reject'] = self.getDriverSchema('reject')
+        pipeline['trigger'] = vs.Required(self.getDriverSchema('trigger'))
         for action in ['start', 'success', 'failure', 'merge-failure',
                        'disabled']:
-            pipeline[action] = PipelineParser.getDriverSchema('reporter',
-                                                              connections)
+            pipeline[action] = self.getDriverSchema('reporter')
         return vs.Schema(pipeline)
 
-    @staticmethod
-    def fromYaml(layout, connections, scheduler, conf):
+    def fromYaml(self, conf):
         with configuration_exceptions('pipeline', conf):
-            PipelineParser.getSchema(layout, connections)(conf)
-        pipeline = model.Pipeline(conf['name'], layout)
+            self.schema(conf)
+        pipeline = model.Pipeline(conf['name'], self.pcontext.layout)
         pipeline.description = conf.get('description')
 
         precedence = model.PRECEDENCE_MAP[conf.get('precedence')]
@@ -1062,13 +1097,13 @@
         pipeline.post_review = conf.get(
             'post-review', False)
 
-        for conf_key, action in PipelineParser.reporter_actions.items():
+        for conf_key, action in self.reporter_actions.items():
             reporter_set = []
             if conf.get(conf_key):
                 for reporter_name, params \
                     in conf.get(conf_key).items():
-                    reporter = connections.getReporter(reporter_name,
-                                                       params)
+                    reporter = self.pcontext.connections.getReporter(
+                        reporter_name, params)
                     reporter.setAction(conf_key)
                     reporter_set.append(reporter)
             setattr(pipeline, action, reporter_set)
@@ -1094,26 +1129,27 @@
         manager_name = conf['manager']
         if manager_name == 'dependent':
             manager = zuul.manager.dependent.DependentPipelineManager(
-                scheduler, pipeline)
+                self.pcontext.scheduler, pipeline)
         elif manager_name == 'independent':
             manager = zuul.manager.independent.IndependentPipelineManager(
-                scheduler, pipeline)
+                self.pcontext.scheduler, pipeline)
 
         pipeline.setManager(manager)
-        layout.pipelines[conf['name']] = pipeline
+        self.pcontext.layout.pipelines[conf['name']] = pipeline
 
         for source_name, require_config in conf.get('require', {}).items():
-            source = connections.getSource(source_name)
+            source = self.pcontext.connections.getSource(source_name)
             manager.ref_filters.extend(
                 source.getRequireFilters(require_config))
 
         for source_name, reject_config in conf.get('reject', {}).items():
-            source = connections.getSource(source_name)
+            source = self.pcontext.connections.getSource(source_name)
             manager.ref_filters.extend(
                 source.getRejectFilters(reject_config))
 
         for trigger_name, trigger_config in conf.get('trigger').items():
-            trigger = connections.getTrigger(trigger_name, trigger_config)
+            trigger = self.pcontext.connections.getTrigger(
+                trigger_name, trigger_config)
             pipeline.triggers.append(trigger)
             manager.event_filters.extend(
                 trigger.getEventFilters(conf['trigger'][trigger_name]))
@@ -1122,8 +1158,12 @@
 
 
 class SemaphoreParser(object):
-    @staticmethod
-    def getSchema():
+    def __init__(self, pcontext):
+        self.log = logging.getLogger("zuul.SemaphoreParser")
+        self.pcontext = pcontext
+        self.schema = self.getSchema()
+
+    def getSchema(self):
         semaphore = {vs.Required('name'): str,
                      'max': int,
                      '_source_context': model.SourceContext,
@@ -1132,16 +1172,43 @@
 
         return vs.Schema(semaphore)
 
-    @staticmethod
-    def fromYaml(conf):
-        SemaphoreParser.getSchema()(conf)
+    def fromYaml(self, conf):
+        self.schema(conf)
         semaphore = model.Semaphore(conf['name'], conf.get('max', 1))
         semaphore.source_context = conf.get('_source_context')
         return semaphore
 
 
+class ParseContext(object):
+    """Hold information about a particular run of the parser"""
+
+    def __init__(self, connections, scheduler, tenant, layout):
+        self.connections = connections
+        self.scheduler = scheduler
+        self.tenant = tenant
+        self.layout = layout
+        self.pragma_parser = PragmaParser(self)
+        self.pipeline_parser = PipelineParser(self)
+        self.nodeset_parser = NodeSetParser(self)
+        self.secret_parser = SecretParser(self)
+        self.job_parser = JobParser(self)
+        self.semaphore_parser = SemaphoreParser(self)
+        self.project_template_parser = None
+        self.project_parser = None
+
+    def setPipelines(self):
+        # Call after pipelines are fixed in the layout to construct
+        # the project parser, which relies on them.
+        self.project_template_parser = ProjectTemplateParser(self)
+        self.project_parser = ProjectParser(self)
+
+
 class TenantParser(object):
-    log = logging.getLogger("zuul.TenantParser")
+    def __init__(self, connections, scheduler, merger):
+        self.log = logging.getLogger("zuul.TenantParser")
+        self.connections = connections
+        self.scheduler = scheduler
+        self.merger = merger
 
     classes = vs.Any('pipeline', 'job', 'semaphore', 'project',
                      'project-template', 'nodeset', 'secret')
@@ -1168,36 +1235,31 @@
         'untrusted-projects': to_list(project_or_group),
     })
 
-    @staticmethod
-    def validateTenantSources(connections):
+    def validateTenantSources(self):
         def v(value, path=[]):
             if isinstance(value, dict):
                 for k, val in value.items():
-                    connections.getSource(k)
-                    TenantParser.validateTenantSource(val, path + [k])
+                    self.connections.getSource(k)
+                    self.validateTenantSource(val, path + [k])
             else:
                 raise vs.Invalid("Invalid tenant source", path)
         return v
 
-    @staticmethod
-    def validateTenantSource(value, path=[]):
-        TenantParser.tenant_source(value)
+    def validateTenantSource(self, value, path=[]):
+        self.tenant_source(value)
 
-    @staticmethod
-    def getSchema(connections=None):
+    def getSchema(self):
         tenant = {vs.Required('name'): str,
                   'max-nodes-per-job': int,
                   'max-job-timeout': int,
-                  'source': TenantParser.validateTenantSources(connections),
+                  'source': self.validateTenantSources(),
                   'exclude-unprotected-branches': bool,
                   'default-parent': str,
                   }
         return vs.Schema(tenant)
 
-    @staticmethod
-    def fromYaml(base, project_key_dir, connections, scheduler, merger, conf,
-                 old_tenant):
-        TenantParser.getSchema(connections)(conf)
+    def fromYaml(self, base, project_key_dir, conf, old_tenant):
+        self.getSchema()(conf)
         tenant = model.Tenant(conf['name'])
         if conf.get('max-nodes-per-job') is not None:
             tenant.max_nodes_per_job = conf['max-nodes-per-job']
@@ -1212,48 +1274,41 @@
         unparsed_config = model.UnparsedTenantConfig()
         # tpcs is TenantProjectConfigs
         config_tpcs, untrusted_tpcs = \
-            TenantParser._loadTenantProjects(
-                project_key_dir, connections, conf)
+            self._loadTenantProjects(project_key_dir, conf)
         for tpc in config_tpcs:
             tenant.addConfigProject(tpc)
         for tpc in untrusted_tpcs:
             tenant.addUntrustedProject(tpc)
 
         for tpc in config_tpcs + untrusted_tpcs:
-            TenantParser._getProjectBranches(tenant, tpc, old_tenant)
-            TenantParser._resolveShadowProjects(tenant, tpc)
+            self._getProjectBranches(tenant, tpc, old_tenant)
+            self._resolveShadowProjects(tenant, tpc)
 
         if old_tenant:
             cached = True
         else:
             cached = False
         tenant.config_projects_config, tenant.untrusted_projects_config = \
-            TenantParser._loadTenantInRepoLayouts(merger, connections,
-                                                  tenant.config_projects,
-                                                  tenant.untrusted_projects,
-                                                  cached, tenant)
-        unparsed_config.extend(tenant.config_projects_config, tenant)
-        unparsed_config.extend(tenant.untrusted_projects_config, tenant)
-        tenant.layout = TenantParser._parseLayout(base, tenant,
-                                                  unparsed_config,
-                                                  scheduler,
-                                                  connections)
+            self._loadTenantInRepoLayouts(tenant.config_projects,
+                                          tenant.untrusted_projects,
+                                          cached, tenant)
+        unparsed_config.extend(tenant.config_projects_config)
+        unparsed_config.extend(tenant.untrusted_projects_config)
+        tenant.layout = self._parseLayout(base, tenant, unparsed_config)
         return tenant
 
-    @staticmethod
-    def _resolveShadowProjects(tenant, tpc):
+    def _resolveShadowProjects(self, tenant, tpc):
         shadow_projects = []
         for sp in tpc.shadow_projects:
             shadow_projects.append(tenant.getProject(sp)[1])
         tpc.shadow_projects = frozenset(shadow_projects)
 
-    @staticmethod
-    def _getProjectBranches(tenant, tpc, old_tenant):
+    def _getProjectBranches(self, tenant, tpc, old_tenant):
         # If we're performing a tenant reconfiguration, we will have
         # an old_tenant object, however, we may be doing so because of
         # a branch creation event, so if we don't have any cached
         # data, query the branches again as well.
-        if old_tenant and tpc.project.unparsed_config:
+        if old_tenant and tpc.project.unparsed_branch_config:
             branches = old_tenant.getProjectBranches(tpc.project)[:]
         else:
             branches = sorted(tpc.project.source.getProjectBranches(
@@ -1263,17 +1318,15 @@
             branches = ['master'] + branches
         tpc.branches = branches
 
-    @staticmethod
-    def _loadProjectKeys(project_key_dir, connection_name, project):
+    def _loadProjectKeys(self, project_key_dir, connection_name, project):
         project.private_key_file = (
             os.path.join(project_key_dir, connection_name,
                          project.name + '.pem'))
 
-        TenantParser._generateKeys(project)
-        TenantParser._loadKeys(project)
+        self._generateKeys(project)
+        self._loadKeys(project)
 
-    @staticmethod
-    def _generateKeys(project):
+    def _generateKeys(self, project):
         if os.path.isfile(project.private_key_file):
             return
 
@@ -1281,7 +1334,7 @@
         if not os.path.isdir(key_dir):
             os.makedirs(key_dir, 0o700)
 
-        TenantParser.log.info(
+        self.log.info(
             "Generating RSA keypair for project %s" % (project.name,)
         )
         private_key, public_key = encryption.generate_rsa_keypair()
@@ -1289,7 +1342,7 @@
 
         # Dump keys to filesystem.  We only save the private key
         # because the public key can be constructed from it.
-        TenantParser.log.info(
+        self.log.info(
             "Saving RSA keypair for project %s to %s" % (
                 project.name, project.private_key_file)
         )
@@ -1344,14 +1397,12 @@
 
         return tenant_project_config
 
-    @staticmethod
-    def _getProjects(source, conf, current_include):
+    def _getProjects(self, source, conf, current_include):
         # Return a project object whether conf is a dict or a str
         projects = []
         if isinstance(conf, str):
             # A simple project name string
-            projects.append(TenantParser._getProject(
-                source, conf, current_include))
+            projects.append(self._getProject(source, conf, current_include))
         elif len(conf.keys()) > 1 and 'projects' in conf:
             # This is a project group
             if 'include' in conf:
@@ -1362,19 +1413,18 @@
                 exclude = set(as_list(conf['exclude']))
                 current_include = current_include - exclude
             for project in conf['projects']:
-                sub_projects = TenantParser._getProjects(
+                sub_projects = self._getProjects(
                     source, project, current_include)
                 projects.extend(sub_projects)
         elif len(conf.keys()) == 1:
             # A project with overrides
-            projects.append(TenantParser._getProject(
+            projects.append(self._getProject(
                 source, conf, current_include))
         else:
             raise Exception("Unable to parse project %s", conf)
         return projects
 
-    @staticmethod
-    def _loadTenantProjects(project_key_dir, connections, conf_tenant):
+    def _loadTenantProjects(self, project_key_dir, conf_tenant):
         config_projects = []
         untrusted_projects = []
 
@@ -1382,38 +1432,32 @@
                                      'secret', 'project-template', 'nodeset'])
 
         for source_name, conf_source in conf_tenant.get('source', {}).items():
-            source = connections.getSource(source_name)
+            source = self.connections.getSource(source_name)
 
             current_include = default_include
             for conf_repo in conf_source.get('config-projects', []):
                 # tpcs = TenantProjectConfigs
-                tpcs = TenantParser._getProjects(source, conf_repo,
-                                                 current_include)
+                tpcs = self._getProjects(source, conf_repo, current_include)
                 for tpc in tpcs:
-                    TenantParser._loadProjectKeys(
+                    self._loadProjectKeys(
                         project_key_dir, source_name, tpc.project)
                     config_projects.append(tpc)
 
             current_include = frozenset(default_include - set(['pipeline']))
             for conf_repo in conf_source.get('untrusted-projects', []):
-                tpcs = TenantParser._getProjects(source, conf_repo,
-                                                 current_include)
+                tpcs = self._getProjects(source, conf_repo,
+                                         current_include)
                 for tpc in tpcs:
-                    TenantParser._loadProjectKeys(
+                    self._loadProjectKeys(
                         project_key_dir, source_name, tpc.project)
                     untrusted_projects.append(tpc)
 
         return config_projects, untrusted_projects
 
-    @staticmethod
-    def _loadTenantInRepoLayouts(merger, connections, config_projects,
-                                 untrusted_projects, cached, tenant):
+    def _loadTenantInRepoLayouts(self, config_projects, untrusted_projects,
+                                 cached, tenant):
         config_projects_config = model.UnparsedTenantConfig()
         untrusted_projects_config = model.UnparsedTenantConfig()
-        # project -> config; these will replace
-        # project.unparsed_config if this method succesfully
-        # completes
-        new_project_unparsed_config = {}
         # project -> branch -> config; these will replace
         # project.unparsed_branch_config if this method succesfully
         # completes
@@ -1426,21 +1470,28 @@
         # data and is inserted in the ordered jobs list for later
         # processing.
         class CachedDataJob(object):
-            def __init__(self, config_project, project):
+            def __init__(self, config_project, project, branch):
                 self.config_project = config_project
                 self.project = project
+                self.branch = branch
 
         for project in config_projects:
             # If we have cached data (this is a reconfiguration) use it.
-            if cached and project.unparsed_config:
-                jobs.append(CachedDataJob(True, project))
+            if cached and project.unparsed_branch_config:
+                # Note: this should only be one branch (master), as
+                # that's all we will initially load below in the
+                # un-cached case.
+                for branch in project.unparsed_branch_config.keys():
+                    jobs.append(CachedDataJob(True, project, branch))
                 continue
             # Otherwise, prepare an empty unparsed config object to
             # hold cached data later.
-            new_project_unparsed_config[project] = model.UnparsedTenantConfig()
+            new_project_unparsed_branch_config[project] = {}
+            new_project_unparsed_branch_config[project]['master'] = \
+                model.UnparsedTenantConfig()
             # Get main config files.  These files are permitted the
             # full range of configuration.
-            job = merger.getFiles(
+            job = self.merger.getFiles(
                 project.source.connection.connection_name,
                 project.name, 'master',
                 files=['zuul.yaml', '.zuul.yaml'],
@@ -1456,12 +1507,12 @@
             if not tpc.load_classes:
                 continue
             # If we have cached data (this is a reconfiguration) use it.
-            if cached and project.unparsed_config:
-                jobs.append(CachedDataJob(False, project))
+            if cached and project.unparsed_branch_config:
+                for branch in project.unparsed_branch_config.keys():
+                    jobs.append(CachedDataJob(False, project, branch))
                 continue
             # Otherwise, prepare an empty unparsed config object to
             # hold cached data later.
-            new_project_unparsed_config[project] = model.UnparsedTenantConfig()
             new_project_unparsed_branch_config[project] = {}
             # Get in-project-repo config files which have a restricted
             # set of options.
@@ -1473,7 +1524,7 @@
             for branch in branches:
                 new_project_unparsed_branch_config[project][branch] = \
                     model.UnparsedTenantConfig()
-                job = merger.getFiles(
+                job = self.merger.getFiles(
                     project.source.connection.connection_name,
                     project.name, branch,
                     files=['zuul.yaml', '.zuul.yaml'],
@@ -1488,22 +1539,22 @@
             # same order they were defined in the main config file.
             # This is important for correct inheritance.
             if isinstance(job, CachedDataJob):
-                TenantParser.log.info(
+                self.log.info(
                     "Loading previously parsed configuration from %s" %
                     (job.project,))
                 if job.config_project:
                     config_projects_config.extend(
-                        job.project.unparsed_config, tenant)
+                        job.project.unparsed_branch_config[job.branch])
                 else:
                     untrusted_projects_config.extend(
-                        job.project.unparsed_config, tenant)
+                        job.project.unparsed_branch_config[job.branch])
                 continue
-            TenantParser.log.debug("Waiting for cat job %s" % (job,))
+            self.log.debug("Waiting for cat job %s" % (job,))
             job.wait()
             if not job.updated:
                 raise Exception("Cat job %s failed" % (job,))
-            TenantParser.log.debug("Cat job %s got files %s" %
-                                   (job, job.files.keys()))
+            self.log.debug("Cat job %s got files %s" %
+                           (job, job.files.keys()))
             loaded = False
             files = sorted(job.files.keys())
             for conf_root in ['zuul.yaml', 'zuul.d', '.zuul.yaml', '.zuul.d']:
@@ -1513,114 +1564,105 @@
                         continue
                     # Don't load from more than configuration in a repo-branch
                     if loaded and loaded != conf_root:
-                        TenantParser.log.warning(
+                        self.log.warning(
                             "Multiple configuration files in %s" %
                             (job.source_context,))
                         continue
                     loaded = conf_root
                     source_context = job.source_context.copy()
                     source_context.path = fn
-                    TenantParser.log.info(
+                    self.log.info(
                         "Loading configuration from %s" %
                         (source_context,))
                     project = source_context.project
                     branch = source_context.branch
                     if source_context.trusted:
-                        incdata = TenantParser._parseConfigProjectLayout(
-                            job.files[fn], source_context, tenant)
-                        config_projects_config.extend(incdata, tenant)
+                        incdata = self.loadConfigProjectLayout(
+                            job.files[fn], source_context)
+                        config_projects_config.extend(incdata)
                     else:
-                        incdata = TenantParser._parseUntrustedProjectLayout(
-                            job.files[fn], source_context, tenant)
-                        untrusted_projects_config.extend(incdata, tenant)
-                    new_project_unparsed_config[project].extend(
-                        incdata, tenant)
-                    if branch in new_project_unparsed_branch_config.get(
-                            project, {}):
-                        new_project_unparsed_branch_config[project][branch].\
-                            extend(incdata, tenant)
+                        incdata = self.loadUntrustedProjectLayout(
+                            job.files[fn], source_context)
+                        untrusted_projects_config.extend(incdata)
+                    new_project_unparsed_branch_config[project][branch].\
+                        extend(incdata)
         # Now that we've sucessfully loaded all of the configuration,
         # cache the unparsed data on the project objects.
-        for project, data in new_project_unparsed_config.items():
-            project.unparsed_config = data
         for project, branch_config in \
             new_project_unparsed_branch_config.items():
             project.unparsed_branch_config = branch_config
         return config_projects_config, untrusted_projects_config
 
-    @staticmethod
-    def _parseConfigProjectLayout(data, source_context, tenant):
+    def loadConfigProjectLayout(self, data, source_context):
         # This is the top-level configuration for a tenant.
         config = model.UnparsedTenantConfig()
         with early_configuration_exceptions(source_context):
-            config.extend(safe_load_yaml(data, source_context), tenant)
+            config.extend(safe_load_yaml(data, source_context))
         return config
 
-    @staticmethod
-    def _parseUntrustedProjectLayout(data, source_context, tenant):
+    def loadUntrustedProjectLayout(self, data, source_context):
         config = model.UnparsedTenantConfig()
         with early_configuration_exceptions(source_context):
-            config.extend(safe_load_yaml(data, source_context), tenant)
+            config.extend(safe_load_yaml(data, source_context))
         if config.pipelines:
             with configuration_exceptions('pipeline', config.pipelines[0]):
                 raise PipelineNotPermittedError()
         return config
 
-    @staticmethod
-    def _getLoadClasses(tenant, conf_object):
+    def _getLoadClasses(self, tenant, conf_object):
         project = conf_object['_source_context'].project
         tpc = tenant.project_configs[project.canonical_name]
         return tpc.load_classes
 
-    @staticmethod
-    def _parseLayoutItems(layout, tenant, data, scheduler, connections,
+    def _parseLayoutItems(self, layout, tenant, data,
                           skip_pipelines=False, skip_semaphores=False):
+        pcontext = ParseContext(self.connections, self.scheduler,
+                                tenant, layout)
         # Handle pragma items first since they modify the source context
         # used by other classes.
-        pragma_parser = PragmaParser()
         for config_pragma in data.pragmas:
-            pragma_parser.fromYaml(config_pragma)
+            pcontext.pragma_parser.fromYaml(config_pragma)
 
         if not skip_pipelines:
             for config_pipeline in data.pipelines:
-                classes = TenantParser._getLoadClasses(
-                    tenant, config_pipeline)
+                classes = self._getLoadClasses(tenant, config_pipeline)
                 if 'pipeline' not in classes:
                     continue
-                layout.addPipeline(PipelineParser.fromYaml(
-                    layout, connections,
-                    scheduler, config_pipeline))
+                layout.addPipeline(pcontext.pipeline_parser.fromYaml(
+                    config_pipeline))
+        pcontext.setPipelines()
 
         for config_nodeset in data.nodesets:
-            classes = TenantParser._getLoadClasses(tenant, config_nodeset)
+            classes = self._getLoadClasses(tenant, config_nodeset)
             if 'nodeset' not in classes:
                 continue
             with configuration_exceptions('nodeset', config_nodeset):
-                layout.addNodeSet(NodeSetParser.fromYaml(
+                layout.addNodeSet(pcontext.nodeset_parser.fromYaml(
                     config_nodeset))
 
         for config_secret in data.secrets:
-            classes = TenantParser._getLoadClasses(tenant, config_secret)
+            classes = self._getLoadClasses(tenant, config_secret)
             if 'secret' not in classes:
                 continue
             with configuration_exceptions('secret', config_secret):
-                layout.addSecret(SecretParser.fromYaml(layout, config_secret))
+                layout.addSecret(pcontext.secret_parser.fromYaml(
+                    config_secret))
 
         for config_job in data.jobs:
-            classes = TenantParser._getLoadClasses(tenant, config_job)
+            classes = self._getLoadClasses(tenant, config_job)
             if 'job' not in classes:
                 continue
             with configuration_exceptions('job', config_job):
-                job = JobParser.fromYaml(tenant, layout, config_job)
+                job = pcontext.job_parser.fromYaml(config_job)
                 added = layout.addJob(job)
                 if not added:
-                    TenantParser.log.debug(
+                    self.log.debug(
                         "Skipped adding job %s which shadows an existing job" %
                         (job,))
 
         # Now that all the jobs are loaded, verify their parents exist
         for config_job in data.jobs:
-            classes = TenantParser._getLoadClasses(tenant, config_job)
+            classes = self._getLoadClasses(tenant, config_job)
             if 'job' not in classes:
                 continue
             with configuration_exceptions('job', config_job):
@@ -1637,25 +1679,26 @@
         else:
             semaphore_layout = layout
         for config_semaphore in data.semaphores:
-            classes = TenantParser._getLoadClasses(
+            classes = self._getLoadClasses(
                 tenant, config_semaphore)
             if 'semaphore' not in classes:
                 continue
             with configuration_exceptions('semaphore', config_semaphore):
-                semaphore = SemaphoreParser.fromYaml(config_semaphore)
+                semaphore = pcontext.semaphore_parser.fromYaml(
+                    config_semaphore)
                 semaphore_layout.addSemaphore(semaphore)
 
-        project_template_parser = ProjectTemplateParser(tenant, layout)
         for config_template in data.project_templates:
-            classes = TenantParser._getLoadClasses(tenant, config_template)
+            classes = self._getLoadClasses(tenant, config_template)
             if 'project-template' not in classes:
                 continue
             with configuration_exceptions('project-template', config_template):
-                layout.addProjectTemplate(project_template_parser.fromYaml(
-                    config_template))
+                layout.addProjectTemplate(
+                    pcontext.project_template_parser.fromYaml(
+                        config_template))
 
-        project_parser = ProjectParser(tenant, layout, project_template_parser)
-        for config_projects in data.projects.values():
+        flattened_projects = self._flattenProjects(data.projects, tenant)
+        for config_projects in flattened_projects.values():
             # Unlike other config classes, we expect multiple project
             # stanzas with the same name, so that a config repo can
             # define a project-pipeline and the project itself can
@@ -1665,25 +1708,43 @@
             # the include/exclude rules before parsing them.
             filtered_projects = []
             for config_project in config_projects:
-                classes = TenantParser._getLoadClasses(tenant, config_project)
+                classes = self._getLoadClasses(tenant, config_project)
                 if 'project' in classes:
                     filtered_projects.append(config_project)
 
             if not filtered_projects:
                 continue
 
-            layout.addProjectConfig(project_parser.fromYaml(
+            layout.addProjectConfig(pcontext.project_parser.fromYaml(
                 filtered_projects))
 
-    @staticmethod
-    def _parseLayout(base, tenant, data, scheduler, connections):
+    def _flattenProjects(self, projects, tenant):
+        # Group together all of the project stanzas for each project.
+        result_projects = {}
+        for config_project in projects:
+            with configuration_exceptions('project', config_project):
+                name = config_project.get('name')
+                if not name:
+                    # There is no name defined so implicitly add the name
+                    # of the project where it is defined.
+                    name = (config_project['_source_context'].
+                            project.canonical_name)
+                else:
+                    trusted, project = tenant.getProject(name)
+                    if project is None:
+                        raise ProjectNotFoundError(name)
+                    name = project.canonical_name
+                config_project['name'] = name
+                result_projects.setdefault(name, []).append(config_project)
+        return result_projects
+
+    def _parseLayout(self, base, tenant, data):
         # Don't call this method from dynamic reconfiguration because
         # it interacts with drivers and connections.
         layout = model.Layout(tenant)
-        TenantParser.log.debug("Created layout id %s", layout.uuid)
+        self.log.debug("Created layout id %s", layout.uuid)
 
-        TenantParser._parseLayoutItems(layout, tenant, data,
-                                       scheduler, connections)
+        self._parseLayoutItems(layout, tenant, data)
 
         for pipeline in layout.pipelines.values():
             pipeline.manager._postConfig(layout)
@@ -1694,6 +1755,12 @@
 class ConfigLoader(object):
     log = logging.getLogger("zuul.ConfigLoader")
 
+    def __init__(self, connections, scheduler, merger):
+        self.connections = connections
+        self.scheduler = scheduler
+        self.merger = merger
+        self.tenant_parser = TenantParser(connections, scheduler, merger)
+
     def expandConfigPath(self, config_path):
         if config_path:
             config_path = os.path.expanduser(config_path)
@@ -1702,28 +1769,27 @@
                             config_path)
         return config_path
 
-    def loadConfig(self, config_path, project_key_dir, scheduler, merger,
-                   connections):
-        abide = model.Abide()
-
+    def readConfig(self, config_path):
         config_path = self.expandConfigPath(config_path)
         with open(config_path) as config_file:
             self.log.info("Loading configuration from %s" % (config_path,))
             data = yaml.safe_load(config_file)
-        config = model.UnparsedAbideConfig()
-        config.extend(data)
         base = os.path.dirname(os.path.realpath(config_path))
+        unparsed_abide = model.UnparsedAbideConfig(base)
+        unparsed_abide.extend(data)
+        return unparsed_abide
 
-        for conf_tenant in config.tenants:
+    def loadConfig(self, unparsed_abide, project_key_dir):
+        abide = model.Abide()
+        for conf_tenant in unparsed_abide.tenants:
             # When performing a full reload, do not use cached data.
-            tenant = TenantParser.fromYaml(
-                base, project_key_dir, connections, scheduler, merger,
-                conf_tenant, old_tenant=None)
+            tenant = self.tenant_parser.fromYaml(unparsed_abide.base,
+                                                 project_key_dir,
+                                                 conf_tenant, old_tenant=None)
             abide.tenants[tenant.name] = tenant
         return abide
 
-    def reloadTenant(self, config_path, project_key_dir, scheduler,
-                     merger, connections, abide, tenant):
+    def reloadTenant(self, config_path, project_key_dir, abide, tenant):
         new_abide = model.Abide()
         new_abide.tenants = abide.tenants.copy()
 
@@ -1731,13 +1797,14 @@
         base = os.path.dirname(os.path.realpath(config_path))
 
         # When reloading a tenant only, use cached data if available.
-        new_tenant = TenantParser.fromYaml(
-            base, project_key_dir, connections, scheduler, merger,
+        new_tenant = self.tenant_parser.fromYaml(
+            base, project_key_dir,
             tenant.unparsed_config, old_tenant=tenant)
         new_abide.tenants[tenant.name] = new_tenant
         return new_abide
 
-    def _loadDynamicProjectData(self, config, project, files, trusted, tenant):
+    def _loadDynamicProjectData(self, config, project,
+                                files, trusted, tenant):
         if trusted:
             branches = ['master']
         else:
@@ -1757,12 +1824,9 @@
             # If there is no files entry at all for this
             # project-branch, then use the cached config.
             if files_entry is None:
-                if trusted:
-                    incdata = project.unparsed_config
-                else:
-                    incdata = project.unparsed_branch_config.get(branch)
+                incdata = project.unparsed_branch_config.get(branch)
                 if incdata:
-                    config.extend(incdata, tenant)
+                    config.extend(incdata)
                 continue
             # Otherwise, do not use the cached config (even if the
             # files are empty as that likely means they were deleted).
@@ -1784,19 +1848,21 @@
                     # Prevent mixing configuration source
                     conf_root = fn.split('/')[0]
                     if loaded and loaded != conf_root:
-                        TenantParser.log.warning(
+                        self.log.warning(
                             "Multiple configuration in %s" % source_context)
                         continue
                     loaded = conf_root
 
                     if trusted:
-                        incdata = TenantParser._parseConfigProjectLayout(
-                            data, source_context, tenant)
+                        incdata = (self.tenant_parser.
+                                   loadConfigProjectLayout(
+                                       data, source_context))
                     else:
-                        incdata = TenantParser._parseUntrustedProjectLayout(
-                            data, source_context, tenant)
+                        incdata = (self.tenant_parser.
+                                   loadUntrustedProjectLayout(
+                                       data, source_context))
 
-                    config.extend(incdata, tenant)
+                    config.extend(incdata)
 
     def createDynamicLayout(self, tenant, files,
                             include_config_projects=False,
@@ -1808,8 +1874,10 @@
                     config, project, files, True, tenant)
         else:
             config = tenant.config_projects_config.copy()
+
         for project in tenant.untrusted_projects:
-            self._loadDynamicProjectData(config, project, files, False, tenant)
+            self._loadDynamicProjectData(config, project, files,
+                                         False, tenant)
 
         layout = model.Layout(tenant)
         self.log.debug("Created layout id %s", layout.uuid)
@@ -1833,9 +1901,8 @@
         else:
             skip_pipelines = skip_semaphores = False
 
-        TenantParser._parseLayoutItems(layout, tenant, config,
-                                       scheduler, connections,
-                                       skip_pipelines=skip_pipelines,
-                                       skip_semaphores=skip_semaphores)
+        self.tenant_parser._parseLayoutItems(layout, tenant, config,
+                                             skip_pipelines=skip_pipelines,
+                                             skip_semaphores=skip_semaphores)
 
         return layout
diff --git a/zuul/connection/__init__.py b/zuul/connection/__init__.py
index 86f14d6..1c62f4d 100644
--- a/zuul/connection/__init__.py
+++ b/zuul/connection/__init__.py
@@ -75,11 +75,14 @@
         still in use.  Anything in our cache that isn't in the supplied
         list should be safe to remove from the cache."""
 
-    def getWebHandlers(self, zuul_web):
+    def getWebHandlers(self, zuul_web, info):
         """Return a list of web handlers to register with zuul-web.
 
         :param zuul.web.ZuulWeb zuul_web:
             Zuul Web instance.
+        :param zuul.model.WebInfo info:
+            The WebInfo object for the Zuul Web instance. Can be used by
+            plugins to toggle API capabilities.
         :returns: List of `zuul.web.handler.BaseWebHandler` instances.
         """
         return []
diff --git a/zuul/driver/github/githubconnection.py b/zuul/driver/github/githubconnection.py
index 6dfcdd3..772ba9b 100644
--- a/zuul/driver/github/githubconnection.py
+++ b/zuul/driver/github/githubconnection.py
@@ -1141,7 +1141,7 @@
 
         return statuses
 
-    def getWebHandlers(self, zuul_web):
+    def getWebHandlers(self, zuul_web, info):
         return [GithubWebhookHandler(self, zuul_web, 'POST', 'payload')]
 
     def validateWebConfig(self, config, connections):
diff --git a/zuul/driver/sql/sqlconnection.py b/zuul/driver/sql/sqlconnection.py
index 501a2c5..e931301 100644
--- a/zuul/driver/sql/sqlconnection.py
+++ b/zuul/driver/sql/sqlconnection.py
@@ -125,9 +125,10 @@
 
         return zuul_buildset_table, zuul_build_table
 
-    def getWebHandlers(self, zuul_web):
+    def getWebHandlers(self, zuul_web, info):
+        info.capabilities.job_history = True
         return [
-            SqlWebHandler(self, zuul_web, 'GET', '/{tenant}/builds.json'),
+            SqlWebHandler(self, zuul_web, 'GET', '/{tenant}/builds'),
             StaticHandler(zuul_web, '/{tenant}/builds.html'),
         ]
 
diff --git a/zuul/executor/client.py b/zuul/executor/client.py
index d561232..fe0f28d 100644
--- a/zuul/executor/client.py
+++ b/zuul/executor/client.py
@@ -12,7 +12,6 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
-import copy
 import gear
 import json
 import logging
@@ -186,6 +185,7 @@
         params = dict()
         params['job'] = job.name
         params['timeout'] = job.timeout
+        params['post_timeout'] = job.post_timeout
         params['items'] = merger_items
         params['projects'] = []
         if hasattr(item.change, 'branch'):
@@ -208,7 +208,9 @@
             nodes.append(n)
         params['nodes'] = nodes
         params['groups'] = [group.toDict() for group in nodeset.getGroups()]
-        params['vars'] = copy.deepcopy(job.variables)
+        params['vars'] = job.variables
+        params['host_vars'] = job.host_variables
+        params['group_vars'] = job.group_variables
         params['zuul'] = zuul_params
         projects = set()
         required_projects = set()
diff --git a/zuul/executor/server.py b/zuul/executor/server.py
index 8de6fe0..d140a00 100644
--- a/zuul/executor/server.py
+++ b/zuul/executor/server.py
@@ -497,16 +497,22 @@
                 shutil.copy(os.path.join(library_path, fn), target_dir)
 
 
-def make_setup_inventory_dict(nodes):
+def check_varnames(var):
+    # We block these in configloader, but block it here too to make
+    # sure that a job doesn't pass variables named zuul or nodepool.
+    if 'zuul' in var:
+        raise Exception("Defining variables named 'zuul' is not allowed")
+    if 'nodepool' in var:
+        raise Exception("Defining variables named 'nodepool' is not allowed")
 
+
+def make_setup_inventory_dict(nodes):
     hosts = {}
     for node in nodes:
         if (node['host_vars']['ansible_connection'] in
             BLACKLISTED_ANSIBLE_CONNECTION_TYPES):
             continue
-
-        for name in node['name']:
-            hosts[name] = node['host_vars']
+        hosts[node['name']] = node['host_vars']
 
     inventory = {
         'all': {
@@ -517,12 +523,10 @@
     return inventory
 
 
-def make_inventory_dict(nodes, groups, all_vars):
-
+def make_inventory_dict(nodes, args, all_vars):
     hosts = {}
     for node in nodes:
-        for name in node['name']:
-            hosts[name] = node['host_vars']
+        hosts[node['name']] = node['host_vars']
 
     inventory = {
         'all': {
@@ -531,14 +535,16 @@
         }
     }
 
-    for group in groups:
+    for group in args['groups']:
         group_hosts = {}
         for node_name in group['nodes']:
-            # children is a dict with None as values because we don't have
-            # and per-group variables. If we did, None would be a dict
-            # with the per-group variables
             group_hosts[node_name] = None
-        inventory[group['name']] = {'hosts': group_hosts}
+        group_vars = args['group_vars'].get(group['name'], {}).copy()
+        check_varnames(group_vars)
+        inventory[group['name']] = {
+            'hosts': group_hosts,
+            'vars': group_vars,
+        }
 
     return inventory
 
@@ -878,8 +884,10 @@
         success = False
         self.started = True
         time_started = time.time()
-        # timeout value is total job timeout or put another way
-        # the cummulative time that pre, run, and post can consume.
+        # timeout value is "total" job timeout which accounts for
+        # pre-run and run playbooks. post-run is different because
+        # it is used to copy out job logs and we want to do our best
+        # to copy logs even when the job has timed out.
         job_timeout = args['timeout']
         for index, playbook in enumerate(self.jobdir.pre_playbooks):
             # TODOv3(pabelanger): Implement pre-run timeout setting.
@@ -914,11 +922,15 @@
                 # run it again.
                 return None
 
+        post_timeout = args['post_timeout']
         for index, playbook in enumerate(self.jobdir.post_playbooks):
-            # TODOv3(pabelanger): Implement post-run timeout setting.
-            ansible_timeout = self.getAnsibleTimeout(time_started, job_timeout)
+            # Post timeout operates a little differently to the main job
+            # timeout. We give each post playbook the full post timeout to
+            # do its job because post is where you'll often record job logs
+            # which are vital to understanding why timeouts have happened in
+            # the first place.
             post_status, post_code = self.runAnsiblePlaybook(
-                playbook, ansible_timeout, success, phase='post', index=index)
+                playbook, post_timeout, success, phase='post', index=index)
             if post_status == self.RESULT_ABORTED:
                 return 'ABORTED'
             if post_status != self.RESULT_NORMAL or post_code != 0:
@@ -968,42 +980,45 @@
             # set to True in the clouds.yaml for a cloud if this
             # results in the wrong thing being in interface_ip
             # TODO(jeblair): Move this notice to the docs.
-            ip = node.get('interface_ip')
-            port = node.get('connection_port', node.get('ssh_port', 22))
-            host_vars = dict(
-                ansible_host=ip,
-                ansible_user=self.executor_server.default_username,
-                ansible_port=port,
-                nodepool=dict(
-                    label=node.get('label'),
-                    az=node.get('az'),
-                    cloud=node.get('cloud'),
-                    provider=node.get('provider'),
-                    region=node.get('region'),
-                    interface_ip=node.get('interface_ip'),
-                    public_ipv4=node.get('public_ipv4'),
-                    private_ipv4=node.get('private_ipv4'),
-                    public_ipv6=node.get('public_ipv6')))
+            for name in node['name']:
+                ip = node.get('interface_ip')
+                port = node.get('connection_port', node.get('ssh_port', 22))
+                host_vars = args['host_vars'].get(name, {}).copy()
+                check_varnames(host_vars)
+                host_vars.update(dict(
+                    ansible_host=ip,
+                    ansible_user=self.executor_server.default_username,
+                    ansible_port=port,
+                    nodepool=dict(
+                        label=node.get('label'),
+                        az=node.get('az'),
+                        cloud=node.get('cloud'),
+                        provider=node.get('provider'),
+                        region=node.get('region'),
+                        interface_ip=node.get('interface_ip'),
+                        public_ipv4=node.get('public_ipv4'),
+                        private_ipv4=node.get('private_ipv4'),
+                        public_ipv6=node.get('public_ipv6'))))
 
-            username = node.get('username')
-            if username:
-                host_vars['ansible_user'] = username
+                username = node.get('username')
+                if username:
+                    host_vars['ansible_user'] = username
 
-            connection_type = node.get('connection_type')
-            if connection_type:
-                host_vars['ansible_connection'] = connection_type
+                connection_type = node.get('connection_type')
+                if connection_type:
+                    host_vars['ansible_connection'] = connection_type
 
-            host_keys = []
-            for key in node.get('host_keys'):
-                if port != 22:
-                    host_keys.append("[%s]:%s %s" % (ip, port, key))
-                else:
-                    host_keys.append("%s %s" % (ip, key))
+                host_keys = []
+                for key in node.get('host_keys'):
+                    if port != 22:
+                        host_keys.append("[%s]:%s %s" % (ip, port, key))
+                    else:
+                        host_keys.append("%s %s" % (ip, key))
 
-            hosts.append(dict(
-                name=node['name'],
-                host_vars=host_vars,
-                host_keys=host_keys))
+                hosts.append(dict(
+                    name=name,
+                    host_vars=host_vars,
+                    host_keys=host_keys))
         return hosts
 
     def _blockPluginDirs(self, path):
@@ -1096,10 +1111,7 @@
 
         secrets = playbook['secrets']
         if secrets:
-            if 'zuul' in secrets:
-                # We block this in configloader, but block it here too to make
-                # sure that a job doesn't pass secrets named zuul.
-                raise Exception("Defining secrets named 'zuul' is not allowed")
+            check_varnames(secrets)
             jobdir_playbook.secrets_content = yaml.safe_dump(
                 secrets, default_flow_style=False)
 
@@ -1200,12 +1212,9 @@
 
     def prepareAnsibleFiles(self, args):
         all_vars = args['vars'].copy()
+        check_varnames(all_vars)
         # TODO(mordred) Hack to work around running things with python3
         all_vars['ansible_python_interpreter'] = '/usr/bin/python2'
-        if 'zuul' in all_vars:
-            # We block this in configloader, but block it here too to make
-            # sure that a job doesn't pass variables named zuul.
-            raise Exception("Defining vars named 'zuul' is not allowed")
         all_vars['zuul'] = args['zuul'].copy()
         all_vars['zuul']['executor'] = dict(
             hostname=self.executor_server.hostname,
@@ -1216,7 +1225,7 @@
 
         nodes = self.getHostList(args)
         setup_inventory = make_setup_inventory_dict(nodes)
-        inventory = make_inventory_dict(nodes, args['groups'], all_vars)
+        inventory = make_inventory_dict(nodes, args, all_vars)
 
         with open(self.jobdir.setup_inventory, 'w') as setup_inventory_yaml:
             setup_inventory_yaml.write(
diff --git a/zuul/manager/__init__.py b/zuul/manager/__init__.py
index 88ddf7d..506b94f 100644
--- a/zuul/manager/__init__.py
+++ b/zuul/manager/__init__.py
@@ -460,7 +460,8 @@
         # Load layout
         # Late import to break an import loop
         import zuul.configloader
-        loader = zuul.configloader.ConfigLoader()
+        loader = zuul.configloader.ConfigLoader(
+            self.sched.connections, self.sched, None)
 
         self.log.debug("Loading dynamic layout")
         (trusted_updates, untrusted_updates) = item.includesConfigUpdates()
@@ -476,9 +477,7 @@
                 loader.createDynamicLayout(
                     item.pipeline.layout.tenant,
                     build_set.files,
-                    include_config_projects=True,
-                    scheduler=self.sched,
-                    connections=self.sched.connections)
+                    include_config_projects=True)
                 trusted_layout_verified = True
 
             # Then create the config a second time but without changes
diff --git a/zuul/model.py b/zuul/model.py
index 45fc1a8..44e8d06 100644
--- a/zuul/model.py
+++ b/zuul/model.py
@@ -24,6 +24,7 @@
 import textwrap
 
 from zuul import change_matcher
+from zuul.lib.config import get_default
 
 MERGER_MERGE = 1          # "git merge"
 MERGER_MERGE_RESOLVE = 2  # "git merge -s resolve"
@@ -349,7 +350,6 @@
         # when deciding whether to enqueue their changes
         # TODOv3 (jeblair): re-add support for foreign projects if needed
         self.foreign = foreign
-        self.unparsed_config = None
         self.unparsed_branch_config = {}  # branch -> UnparsedTenantConfig
 
     def __str__(self):
@@ -839,7 +839,10 @@
         self.execution_attributes = dict(
             parent=None,
             timeout=None,
+            post_timeout=None,
             variables={},
+            host_variables={},
+            group_variables={},
             nodeset=NodeSet(),
             workspace=None,
             pre_run=(),
@@ -981,10 +984,19 @@
             matchers.append(self.branch_matcher)
         self.branch_matcher = change_matcher.MatchAll(matchers)
 
-    def updateVariables(self, other_vars):
-        v = copy.deepcopy(self.variables)
-        Job._deepUpdate(v, other_vars)
-        self.variables = v
+    def updateVariables(self, other_vars, other_host_vars, other_group_vars):
+        if other_vars is not None:
+            v = copy.deepcopy(self.variables)
+            Job._deepUpdate(v, other_vars)
+            self.variables = v
+        if other_host_vars is not None:
+            v = copy.deepcopy(self.host_variables)
+            Job._deepUpdate(v, other_host_vars)
+            self.host_variables = v
+        if other_group_vars is not None:
+            v = copy.deepcopy(self.group_variables)
+            Job._deepUpdate(v, other_group_vars)
+            self.group_variables = v
 
     def updateParentData(self, other_vars):
         # Update variables, but give the current values priority (used
@@ -1061,7 +1073,8 @@
                                         "from other projects."
                                         % (repr(self), this_origin))
                 if k not in set(['pre_run', 'run', 'post_run', 'roles',
-                                 'variables', 'required_projects',
+                                 'variables', 'host_variables',
+                                 'group_variables', 'required_projects',
                                  'allowed_projects']):
                     # TODO(jeblair): determine if deepcopy is required
                     setattr(self, k, copy.deepcopy(other._get(k)))
@@ -1102,8 +1115,8 @@
         if other._get('post_run') is not None:
             other_post_run = self.freezePlaybooks(other.post_run)
             self.post_run = other_post_run + self.post_run
-        if other._get('variables') is not None:
-            self.updateVariables(other.variables)
+        self.updateVariables(other.variables, other.host_variables,
+                             other.group_variables)
         if other._get('required_projects') is not None:
             self.updateProjects(other.required_projects)
         if (other._get('allowed_projects') is not None and
@@ -2434,8 +2447,10 @@
     An Abide is a collection of tenants.
     """
 
-    def __init__(self):
+    def __init__(self, base=None):
         self.tenants = []
+        self.known_tenants = set()
+        self.base = base
 
     def extend(self, conf):
         if isinstance(conf, UnparsedAbideConfig):
@@ -2453,6 +2468,8 @@
             key, value = list(item.items())[0]
             if key == 'tenant':
                 self.tenants.append(value)
+                if 'name' in value:
+                    self.known_tenants.add(value['name'])
             else:
                 raise ConfigItemUnknownError()
 
@@ -2465,7 +2482,7 @@
         self.pipelines = []
         self.jobs = []
         self.project_templates = []
-        self.projects = {}
+        self.projects = []
         self.nodesets = []
         self.secrets = []
         self.semaphores = []
@@ -2482,23 +2499,13 @@
         r.semaphores = copy.deepcopy(self.semaphores)
         return r
 
-    def extend(self, conf, tenant):
+    def extend(self, conf):
         if isinstance(conf, UnparsedTenantConfig):
             self.pragmas.extend(conf.pragmas)
             self.pipelines.extend(conf.pipelines)
             self.jobs.extend(conf.jobs)
             self.project_templates.extend(conf.project_templates)
-            for k, v in conf.projects.items():
-                name = k
-                # Add the projects to the according canonical name instead of
-                # the given project name. If it is not found, it's ok to add
-                # this to the given name. We also don't need to throw the
-                # ProjectNotFoundException here as semantic validation occurs
-                # later where it will fail then.
-                trusted, project = tenant.getProject(k)
-                if project is not None:
-                    name = project.canonical_name
-                self.projects.setdefault(name, []).extend(v)
+            self.projects.extend(conf.projects)
             self.nodesets.extend(conf.nodesets)
             self.secrets.extend(conf.secrets)
             self.semaphores.extend(conf.semaphores)
@@ -2514,13 +2521,7 @@
                 raise ConfigItemMultipleKeysError()
             key, value = list(item.items())[0]
             if key == 'project':
-                name = value.get('name')
-                if not name:
-                    # There is no name defined so implicitly add the name
-                    # of the project where it is defined.
-                    name = value['_source_context'].project.canonical_name
-                    value['name'] = name
-                self.projects.setdefault(name, []).append(value)
+                self.projects.append(value)
             elif key == 'job':
                 self.jobs.append(value)
             elif key == 'project-template':
@@ -3182,3 +3183,80 @@
         td = self._getTD(build)
         td.add(elapsed, result)
         td.save()
+
+
+class Capabilities(object):
+    """The set of capabilities this Zuul installation has.
+
+    Some plugins add elements to the external API. In order to
+    facilitate consumers knowing if functionality is available
+    or not, keep track of distinct capability flags.
+    """
+    def __init__(self, job_history=False):
+        self.job_history = job_history
+
+    def __repr__(self):
+        return '<Capabilities 0x%x %s>' % (id(self), self._renderFlags())
+
+    def _renderFlags(self):
+        d = self.toDict()
+        return " ".join(['{k}={v}'.format(k=k, v=v) for (k, v) in d.items()])
+
+    def copy(self):
+        return Capabilities(**self.toDict())
+
+    def toDict(self):
+        d = dict()
+        d['job_history'] = self.job_history
+        return d
+
+
+class WebInfo(object):
+    """Information about the system needed by zuul-web /info."""
+
+    def __init__(self, websocket_url=None, endpoint=None,
+                 capabilities=None, stats_url=None,
+                 stats_prefix=None, stats_type=None):
+        self.capabilities = capabilities or Capabilities()
+        self.websocket_url = websocket_url
+        self.stats_url = stats_url
+        self.stats_prefix = stats_prefix
+        self.stats_type = stats_type
+        self.endpoint = endpoint
+        self.tenant = None
+
+    def __repr__(self):
+        return '<WebInfo 0x%x capabilities=%s>' % (
+            id(self), str(self.capabilities))
+
+    def copy(self):
+        return WebInfo(
+            websocket_url=self.websocket_url,
+            endpoint=self.endpoint,
+            stats_url=self.stats_url,
+            stats_prefix=self.stats_prefix,
+            stats_type=self.stats_type,
+            capabilities=self.capabilities.copy())
+
+    @staticmethod
+    def fromConfig(config):
+        return WebInfo(
+            websocket_url=get_default(config, 'web', 'websocket_url', None),
+            stats_url=get_default(config, 'web', 'stats_url', None),
+            stats_prefix=get_default(config, 'statsd', 'prefix'),
+            stats_type=get_default(config, 'web', 'stats_type', 'graphite'),
+        )
+
+    def toDict(self):
+        d = dict()
+        d['websocket_url'] = self.websocket_url
+        stats = dict()
+        stats['url'] = self.stats_url
+        stats['prefix'] = self.stats_prefix
+        stats['type'] = self.stats_type
+        d['stats'] = stats
+        d['endpoint'] = self.endpoint
+        d['capabilities'] = self.capabilities.toDict()
+        if self.tenant:
+            d['tenant'] = self.tenant
+        return d
diff --git a/zuul/scheduler.py b/zuul/scheduler.py
index 7a0e28c..c58bfc7 100644
--- a/zuul/scheduler.py
+++ b/zuul/scheduler.py
@@ -246,6 +246,7 @@
         self.result_event_queue = queue.Queue()
         self.management_event_queue = zuul.lib.queue.MergedQueue()
         self.abide = model.Abide()
+        self.unparsed_abide = model.UnparsedAbideConfig()
 
         if not testonly:
             time_dir = self._get_time_database_dir()
@@ -548,11 +549,13 @@
         self.config = event.config
         try:
             self.log.info("Full reconfiguration beginning")
-            loader = configloader.ConfigLoader()
+            loader = configloader.ConfigLoader(
+                self.connections, self, self.merger)
+            self.unparsed_abide = loader.readConfig(
+                self.config.get('scheduler', 'tenant_config'))
             abide = loader.loadConfig(
-                self.config.get('scheduler', 'tenant_config'),
-                self._get_project_key_dir(),
-                self, self.merger, self.connections)
+                self.unparsed_abide,
+                self._get_project_key_dir())
             for tenant in abide.tenants.values():
                 self._reconfigureTenant(tenant)
             self.abide = abide
@@ -569,14 +572,13 @@
             # If a change landed to a project, clear out the cached
             # config before reconfiguring.
             for project in event.projects:
-                project.unparsed_config = None
                 project.unparsed_branch_config = {}
             old_tenant = self.abide.tenants[event.tenant_name]
-            loader = configloader.ConfigLoader()
+            loader = configloader.ConfigLoader(
+                self.connections, self, self.merger)
             abide = loader.reloadTenant(
                 self.config.get('scheduler', 'tenant_config'),
                 self._get_project_key_dir(),
-                self, self.merger, self.connections,
                 self.abide, old_tenant)
             tenant = abide.tenants[event.tenant_name]
             self._reconfigureTenant(tenant)
@@ -1150,9 +1152,16 @@
         data['pipelines'] = pipelines
         tenant = self.abide.tenants.get(tenant_name)
         if not tenant:
+            if tenant_name not in self.unparsed_abide.known_tenants:
+                return json.dumps({
+                    "message": "Unknown tenant",
+                    "code": 404
+                })
             self.log.warning("Tenant %s isn't loaded" % tenant_name)
-            return json.dumps(
-                {"message": "Tenant %s isn't ready" % tenant_name})
+            return json.dumps({
+                "message": "Tenant %s isn't ready" % tenant_name,
+                "code": 204
+            })
         for pipeline in tenant.layout.pipelines.values():
             pipelines.append(pipeline.formatStatusJSON(websocket_url))
         return json.dumps(data)
diff --git a/zuul/web/__init__.py b/zuul/web/__init__.py
index e962738..31eac7d 100755
--- a/zuul/web/__init__.py
+++ b/zuul/web/__init__.py
@@ -16,6 +16,7 @@
 
 
 import asyncio
+import copy
 import json
 import logging
 import os
@@ -25,6 +26,7 @@
 import aiohttp
 from aiohttp import web
 
+import zuul.model
 import zuul.rpcclient
 from zuul.web.handler import StaticHandler
 
@@ -158,41 +160,47 @@
             'key_get': self.key_get,
         }
 
-    async def tenant_list(self, request):
+    async def tenant_list(self, request, result_filter=None):
         job = self.rpc.submitJob('zuul:tenant_list', {})
         return web.json_response(json.loads(job.data[0]))
 
-    async def status_get(self, request):
+    async def status_get(self, request, result_filter=None):
         tenant = request.match_info["tenant"]
         if tenant not in self.cache or \
            (time.time() - self.cache_time[tenant]) > self.cache_expiry:
             job = self.rpc.submitJob('zuul:status_get', {'tenant': tenant})
             self.cache[tenant] = json.loads(job.data[0])
             self.cache_time[tenant] = time.time()
-        resp = web.json_response(self.cache[tenant])
+        payload = self.cache[tenant]
+        if payload.get('code') == 404:
+            return web.HTTPNotFound(reason=payload['message'])
+        if result_filter:
+            payload = result_filter.filterPayload(payload)
+        resp = web.json_response(payload)
         resp.headers['Access-Control-Allow-Origin'] = '*'
         resp.headers["Cache-Control"] = "public, max-age=%d" % \
                                         self.cache_expiry
         resp.last_modified = self.cache_time[tenant]
         return resp
 
-    async def job_list(self, request):
+    async def job_list(self, request, result_filter=None):
         tenant = request.match_info["tenant"]
         job = self.rpc.submitJob('zuul:job_list', {'tenant': tenant})
         resp = web.json_response(json.loads(job.data[0]))
         resp.headers['Access-Control-Allow-Origin'] = '*'
         return resp
 
-    async def key_get(self, request):
+    async def key_get(self, request, result_filter=None):
         tenant = request.match_info["tenant"]
         project = request.match_info["project"]
         job = self.rpc.submitJob('zuul:key_get', {'tenant': tenant,
                                                   'project': project})
         return web.Response(body=job.data[0])
 
-    async def processRequest(self, request, action):
+    async def processRequest(self, request, action, result_filter=None):
+        resp = None
         try:
-            resp = await self.controllers[action](request)
+            resp = await self.controllers[action](request, result_filter)
         except asyncio.CancelledError:
             self.log.debug("request handling cancelled")
         except Exception as e:
@@ -202,6 +210,24 @@
         return resp
 
 
+class ChangeFilter(object):
+    def __init__(self, desired):
+        self.desired = desired
+
+    def filterPayload(self, payload):
+        status = []
+        for pipeline in payload['pipelines']:
+            for change_queue in pipeline['change_queues']:
+                for head in change_queue['heads']:
+                    for change in head:
+                        if self.wantChange(change):
+                            status.append(copy.deepcopy(change))
+        return status
+
+    def wantChange(self, change):
+        return change['id'] == self.desired
+
+
 class ZuulWeb(object):
 
     log = logging.getLogger("zuul.web.ZuulWeb")
@@ -210,13 +236,16 @@
                  gear_server, gear_port,
                  ssl_key=None, ssl_cert=None, ssl_ca=None,
                  static_cache_expiry=3600,
-                 connections=None):
+                 connections=None,
+                 info=None):
+        self.start_time = time.time()
         self.listen_address = listen_address
         self.listen_port = listen_port
         self.event_loop = None
         self.term = None
         self.server = None
         self.static_cache_expiry = static_cache_expiry
+        self.info = info
         # instanciate handlers
         self.rpc = zuul.rpcclient.RPCClient(gear_server, gear_port,
                                             ssl_key, ssl_cert, ssl_ca)
@@ -225,12 +254,37 @@
         self._plugin_routes = []  # type: List[zuul.web.handler.BaseWebHandler]
         connections = connections or []
         for connection in connections:
-            self._plugin_routes.extend(connection.getWebHandlers(self))
+            self._plugin_routes.extend(
+                connection.getWebHandlers(self, self.info))
 
     async def _handleWebsocket(self, request):
         return await self.log_streaming_handler.processRequest(
             request)
 
+    async def _handleRootInfo(self, request):
+        info = self.info.copy()
+        info.endpoint = str(request.url.parent)
+        return self._handleInfo(info)
+
+    def _handleTenantInfo(self, request):
+        info = self.info.copy()
+        info.tenant = request.match_info["tenant"]
+        # yarl.URL.parent on a root url returns the root url, so this is
+        # both safe and accurate for white-labeled tenants like OpenStack,
+        # zuul-web running on / and zuul-web running on a sub-url like
+        # softwarefactory-project.io
+        info.endpoint = str(request.url.parent.parent.parent)
+        return self._handleInfo(info)
+
+    def _handleInfo(self, info):
+        resp = web.json_response({'info': info.toDict()}, status=200)
+        resp.headers['Access-Control-Allow-Origin'] = '*'
+        if self.static_cache_expiry:
+            resp.headers['Cache-Control'] = "public, max-age=%d" % \
+                self.static_cache_expiry
+        resp.last_modified = self.start_time
+        return resp
+
     async def _handleTenantsRequest(self, request):
         return await self.gearman_handler.processRequest(request,
                                                          'tenant_list')
@@ -238,6 +292,11 @@
     async def _handleStatusRequest(self, request):
         return await self.gearman_handler.processRequest(request, 'status_get')
 
+    async def _handleStatusChangeRequest(self, request):
+        change = request.match_info["change"]
+        return await self.gearman_handler.processRequest(
+            request, 'status_get', ChangeFilter(change))
+
     async def _handleJobsRequest(self, request):
         return await self.gearman_handler.processRequest(request, 'job_list')
 
@@ -256,9 +315,13 @@
             is run within a separate (non-main) thread.
         """
         routes = [
-            ('GET', '/tenants.json', self._handleTenantsRequest),
-            ('GET', '/{tenant}/status.json', self._handleStatusRequest),
-            ('GET', '/{tenant}/jobs.json', self._handleJobsRequest),
+            ('GET', '/info', self._handleRootInfo),
+            ('GET', '/{tenant}/info', self._handleTenantInfo),
+            ('GET', '/tenants', self._handleTenantsRequest),
+            ('GET', '/{tenant}/status', self._handleStatusRequest),
+            ('GET', '/{tenant}/jobs', self._handleJobsRequest),
+            ('GET', '/{tenant}/status/change/{change}',
+             self._handleStatusChangeRequest),
             ('GET', '/{tenant}/console-stream', self._handleWebsocket),
             ('GET', '/{tenant}/{project:.*}.pub', self._handleKeyRequest),
         ]
diff --git a/zuul/web/static/javascripts/jquery.zuul.js b/zuul/web/static/javascripts/jquery.zuul.js
index 7e6788b..7da81dc 100644
--- a/zuul/web/static/javascripts/jquery.zuul.js
+++ b/zuul/web/static/javascripts/jquery.zuul.js
@@ -49,7 +49,7 @@
         options = $.extend({
             'enabled': true,
             'graphite_url': '',
-            'source': 'status.json',
+            'source': 'status',
             'msg_id': '#zuul_msg',
             'pipelines_id': '#zuul_pipelines',
             'queue_events_num': '#zuul_queue_events_num',
diff --git a/zuul/web/static/javascripts/zuul.angular.js b/zuul/web/static/javascripts/zuul.angular.js
index 87cbbdd..49f2518 100644
--- a/zuul/web/static/javascripts/zuul.angular.js
+++ b/zuul/web/static/javascripts/zuul.angular.js
@@ -23,7 +23,7 @@
 {
     $scope.tenants = undefined;
     $scope.tenants_fetch = function() {
-        $http.get("tenants.json")
+        $http.get("tenants")
             .then(function success(result) {
                 $scope.tenants = result.data;
             });
@@ -36,7 +36,7 @@
 {
     $scope.jobs = undefined;
     $scope.jobs_fetch = function() {
-        $http.get("jobs.json")
+        $http.get("jobs")
             .then(function success(result) {
                 $scope.jobs = result.data;
             });
@@ -78,7 +78,7 @@
         if ($scope.job_name) {query_string += "&job_name="+$scope.job_name;}
         if ($scope.project) {query_string += "&project="+$scope.project;}
         if (query_string != "") {query_string = "?" + query_string.substr(1);}
-        $http.get("builds.json" + query_string)
+        $http.get("builds" + query_string)
             .then(function success(result) {
                 for (build_pos = 0;
                      build_pos < result.data.length;
diff --git a/zuul/web/static/javascripts/zuul.app.js b/zuul/web/static/javascripts/zuul.app.js
index bf90a4d..6e35eb3 100644
--- a/zuul/web/static/javascripts/zuul.app.js
+++ b/zuul/web/static/javascripts/zuul.app.js
@@ -55,7 +55,7 @@
     var demo = location.search.match(/[?&]demo=([^?&]*)/),
         source_url = location.search.match(/[?&]source_url=([^?&]*)/),
         source = demo ? './status-' + (demo[1] || 'basic') + '.json-sample' :
-            'status.json';
+            'status';
     source = source_url ? source_url[1] : source;
 
     var zuul = $.zuul({
