diff --git a/roles/bodhi2/backend/tasks/main.yml b/roles/bodhi2/backend/tasks/main.yml index c7f27644bf..47bafd419c 100644 --- a/roles/bodhi2/backend/tasks/main.yml +++ b/roles/bodhi2/backend/tasks/main.yml @@ -24,6 +24,7 @@ - mash - fedmsg-hub - fedmsg-relay + - fedmsg-atomic-composer tags: - packages - bodhi @@ -330,3 +331,14 @@ tags: - fedmsgmonitor - bodhi + +- name: install our atomic composer config + template: > + src=atomic-config.py.j2 + dest=/usr/lib/python2.7/site-packages/fedmsg_atomic_composer/config.py + owner=masher + mode=0644 + tags: + - config + - bodhi + - atomic diff --git a/roles/bodhi2/backend/templates/atomic-config.py.j2 b/roles/bodhi2/backend/templates/atomic-config.py.j2 new file mode 100644 index 0000000000..7d1f3de480 --- /dev/null +++ b/roles/bodhi2/backend/templates/atomic-config.py.j2 @@ -0,0 +1,242 @@ +# Check if we're running on RHEL6 and disable +# `mock --new-chroot` and `rpm-ostree --workdir-tmpfs` +import platform +dist = platform.dist() +rhel6 = dist[0] == 'redhat' and int(float(dist[1])) == 6 + +config = dict( + releases={ + 'f23-updates': { + 'name': 'f23-updates', + 'repo': 'updates', + 'version': '23', + 'arch': 'x86_64', + + # OSTree treefile configuration + # https://github.com/projectatomic/rpm-ostree/blob/master/doc/treefile.md + 'tree': 'docker-host', + 'treefile': { + 'include': 'fedora-atomic-docker-host.json', + 'ref': 'fedora-atomic/f23/x86_64/docker-host', + 'repos': ['fedora-23', 'updates'], + 'packages': [], + }, + + # The name of the mock container to build and maintain + 'mock': 'fedora-23-updates-x86_64', + + # The git branch to use in the `git_repo` for the parent + # treefile & repo configurations + 'git_branch': 'f23', + + # Add or overwrite yum repository name:urls. This lets you + # compose trees against your own repositories. + 'repos': {}, + }, + 'f23-updates-testing': { + 'name': 'f23-updates-testing', + 'repo': 'updates-testing', + 'version': '23', + 'arch': 'x86_64', + + # OSTree treefile configuration + # https://github.com/projectatomic/rpm-ostree/blob/master/doc/treefile.md + 'tree': 'docker-host', + 'treefile': { + 'include': 'fedora-atomic-docker-host.json', + 'ref': 'fedora-atomic/f23/x86_64/testing/docker-host', + 'repos': ['fedora-23', 'updates', 'updates-testing'], + 'packages': [], + }, + + # The name of the mock container to build and maintain + 'mock': 'fedora-23-updates-testing-x86_64', + + # The git branch to use in the `git_repo` for the parent + # treefile & repo configurations + 'git_branch': 'f23', + + # Add or overwrite yum repository name:urls. This lets you + # compose trees against your own repositories. + 'repos': {}, + }, + + 'f22-updates': { + 'name': 'f22-updates', + 'repo': 'updates', + 'version': '22', + 'arch': 'x86_64', + + # OSTree treefile configuration + # https://github.com/projectatomic/rpm-ostree/blob/master/doc/treefile.md + 'tree': 'docker-host', + 'treefile': { + 'include': 'fedora-atomic-docker-host.json', + 'ref': 'fedora-atomic/f22/x86_64/docker-host', + 'repos': ['fedora-22', 'updates'], + 'packages': [], + }, + + # The name of the mock container to build and maintain + 'mock': 'fedora-22-updates-x86_64', + + # The git branch to use in the `git_repo` for the parent + # treefile & repo configurations + 'git_branch': 'f22', + + # Add or overwrite yum repository name:urls. This lets you + # compose trees against your own repositories. + 'repos': {}, + }, + 'f22-updates-testing': { + 'name': 'f22-updates-testing', + 'repo': 'updates-testing', + 'version': '22', + 'arch': 'x86_64', + + # OSTree treefile configuration + # https://github.com/projectatomic/rpm-ostree/blob/master/doc/treefile.md + 'tree': 'docker-host', + 'treefile': { + 'include': 'fedora-atomic-docker-host.json', + 'ref': 'fedora-atomic/f22/x86_64/testing/docker-host', + 'repos': ['fedora-22', 'updates', 'updates-testing', 'f22-temprepo'], + 'packages': [], + }, + + # The name of the mock container to build and maintain + 'mock': 'fedora-22-updates-testing-x86_64', + + # The git branch to use in the `git_repo` for the parent + # treefile & repo configurations + 'git_branch': 'f22', + + # Add or overwrite yum repository name:urls. This lets you + # compose trees against your own repositories. + 'repos': {}, + }, + + 'f21-updates': { + 'name': 'f21-updates', + 'repo': 'updates', + 'version': '21', + 'arch': 'x86_64', + + # OSTree treefile configuration + # https://github.com/projectatomic/rpm-ostree/blob/master/doc/treefile.md + 'tree': 'docker-host', + 'treefile': { + 'include': 'fedora-atomic-docker-host.json', + 'ref': 'fedora-atomic/f21/x86_64/docker-host', + 'repos': ['fedora-21', 'updates'], + }, + + # The name of the mock container to build and maintain + 'mock': 'fedora-21-updates-x86_64', + + # The git branch to use in the `git_repo` for the parent + # treefile & repo configurations + 'git_branch': 'f21', + + # Add or overwrite yum repository name:urls. This lets you + # compose trees against your own repositories. + 'repos': {}, + }, + + 'f21-updates-testing': { + 'name': 'f21-updates-testing', + 'repo': 'updates-testing', + 'version': '21', + 'arch': 'x86_64', + 'tree': 'docker-host', + 'treefile': { + 'include': 'fedora-atomic-docker-host.json', + 'ref': 'fedora-atomic/f21/x86_64/updates-testing/docker-host', + 'repos': ['fedora-21', 'updates', 'updates-testing'], + }, + 'git_branch': 'f21', + 'mock': 'fedora-21-updates-testing-x86_64', + 'repos': {}, + }, + }, + + # Package repositories to use in the mock container and ostree compose + repos={ +{% if env == 'production' %} + 'fedora-{version}': 'file:///pub/fedora/linux/releases/{version}/Everything/{arch}/os', + 'updates': 'file:///pub/fedora/linux/updates/{version}/{arch}/', + 'updates-testing': 'file:///pub/fedora/linux/updates/testing/{version}/{arch}/', +{% else %} + 'fedora-{version}': 'http://download01.phx2.fedoraproject.org/pub/fedora/linux/releases/{version}/Everything/{arch}/os', + 'updates': 'http://download01.phx2.fedoraproject.org/pub/fedora/linux/updates/{version}/{arch}/', + 'updates-testing': 'http://download01.phx2.fedoraproject.org/pub/fedora/linux/updates/testing/{version}/{arch}/', +{% endif %} + }, + + # Output directories +{% if env == 'production' %} + prod_dir='/mnt/koji/mash/atomic', +{% else %} + prod_dir='/var/cache/bodhi/atomic', +{% endif %} + canonical_dir='{prod_dir}/{version}', + work_dir='/srv/fedora-atomic', + output_dir='{work_dir}/{version}/{arch}/{tree}', + log_dir='{work_dir}/logs/{version}/{arch}/{repo}/{tree}', + +{% if env == 'production' %} + mount_dirs=['/pub/fedora', '/mnt/koji/mash/updates'], +{% else %} + mount_dirs=[], +{% endif %} + + # The git repo containing our parent treefiles and yum repos + git_repo='https://git.fedorahosted.org/git/fedora-atomic.git', + git_cache='{work_dir}/fedora-atomic.git', + + # Mock command + mock_cmd='/usr/bin/mock%s-r {mock}' % (rhel6 and ' ' or ' --new-chroot '), + mock_clean=True, + + # OSTree commands + ostree_init='/usr/bin/ostree --repo={output_dir} init --mode=archive-z2', + ostree_compose='/usr/bin/rpm-ostree compose tree' + + (rhel6 and ' ' or ' --workdir-tmpfs ') + '--repo={output_dir} %s', + ostree_summary='/usr/bin/ostree --repo={output_dir} summary --update', + + # rsync commands +{% if env == 'production' %} + rsync_in_objs='/usr/bin/rsync -rvp --ignore-existing {canonical_dir}/objects/ {output_dir}/objects/', + rsync_in_rest='/usr/bin/rsync -rvp --exclude=objects/ {canonical_dir}/ {output_dir}/', + rsync_out_objs='/usr/bin/rsync -rvp --ignore-existing {output_dir}/objects/ {canonical_dir}/objects/', + rsync_out_rest='/usr/bin/rsync -rvp --exclude=objects/ {output_dir}/ {canonical_dir}/', +{% else %} + rsync_in_objs='', + rsync_in_rest='', + rsync_out_objs='', + rsync_out_rest='', +{% endif %} + + map_to_release=('work_dir', 'prod_dir', 'output_dir', 'log_dir', + 'git_repo', 'git_cache', 'mock_cmd', 'ostree_init', + 'ostree_compose', 'ostree_summary', 'canonical_dir', + 'repos', 'rsync_in_objs', 'rsync_in_rest', 'rsync_out_objs', + 'rsync_out_rest', 'mount_dirs', 'mock_clean'), +) + +# Map and expand certain variables to each release +for key in config.get('map_to_release', []): + for name, release in config['releases'].items(): + if isinstance(config[key], dict): + release[key] = {} + for k, v in config[key].items(): + k = k.format(**release) + release[key][k] = v.format(**release) + elif isinstance(config[key], (list, tuple)): + release[key] = [] + for item in config[key]: + release[key].append(item.format(**release)) + elif isinstance(config[key], bool): + release[key] = config[key] + else: + release[key] = config[key].format(**release)