Merge "[Zuul] Adding periodic layout.yaml update"

This commit is contained in:
Jenkins 2016-06-27 12:29:00 +00:00 committed by Gerrit Code Review
commit ff3e80b1a8
4 changed files with 61 additions and 0 deletions

View File

@ -75,6 +75,8 @@ Methods:
- $linux.runCommand($.instance.agent, 'service zuul start')
- $linux.runCommand($.instance.agent, 'service zuul-merger restart')
- $._switchProjectConfig()
- $._createPeriodicLayoutUpdate()
- $._environment.reporter.report($this, 'Zuul is available at http://{0}:80'.format($host))
- $.setAttr(deployed, true)
@ -91,6 +93,31 @@ Methods:
- $.instance.setHieraValue('gerrit_user', 'zuul')
- $.instance.setHieraValue('gerrit_ssh_host_key', $.gerrit.instance.getHieraValue('gerrit_ssh_rsa_pubkey_contents'))
_switchProjectConfig:
Body:
- $resources: new(sys:Resources)
- $linux: new(conf:Linux)
- $script: $resources.string('switch_to_local_project_config.sh')
- $._environment.reporter.report($this, '[Zuul] Switching to project-config from installed Gerrit...')
- $projectConfigURL: format(
'ssh://{0}@{1}:29418/open-paas/project-config',
$.instance.getHieraValue('gerrit_user'),
$.instance.getHieraValue('gerrit_server')
)
- $.instance.setHieraValue('project_config_repo', $projectConfigURL)
- $linux.runCommand($.instance.agent, $script)
_createPeriodicLayoutUpdate:
Body:
- $resources: new(sys:Resources)
- $linux: new(conf:Linux)
- $script: $resources.string('update_layout.sh')
- $._environment.reporter.report($this, '[Zuul] Creating autoupdating layout.yaml file...')
- $linux.putFile($.instance.agent, $script, '/usr/local/bin/update_layout.sh')
- $manifest: $resources.string('update_layout.pp')
- $linux.putFile($.instance.agent, $manifest, '/usr/local/bin/update_layout.pp')
- $linux.runCommand($.instance.agent, 'puppet apply /usr/local/bin/update_layout.pp')
destroy:
Body:
- $.reportDestroyed()

View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
REPO_URL=$(hiera -c /etc/puppet/hiera.yaml project_config_repo)
cp /var/lib/zuul/ssh/id_rsa /home/zuul/.ssh/id_rsa && chown zuul:zuul /home/zuul/.ssh/id_rsa
cd /etc/project-config
git remote set-url origin "$REPO_URL"
git config --global user.email "zuul@example.com"
git config --global user.name "Zuul"
chown -R zuul:zuul /etc/project-config

View File

@ -0,0 +1,7 @@
cron { "update_layout":
user => 'root',
ensure => present,
command => "bash /usr/local/bin/update_layout.sh",
hour => '*',
minute => '*/5',
}

View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
cd /etc/project-config
# Check for new changes.
su zuul -c "git pull"
sha_from_repo=$(sha1sum zuul/layout.yaml | awk '{print $1}')
sha_local=$(sha1sum /etc/zuul/layout/layout.yaml | awk '{print $1}')
# Determine whether a change is made.
if [ "$sha_local" != "$sha_from_repo" ]; then
cp zuul/layout.yaml /etc/zuul/layout/layout.yaml
service zuul force-reload
fi