From 808407db83910b7da77efb10fc4c2865da5fc5c2 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Fri, 2 Oct 2015 16:47:46 -0500 Subject: [PATCH] Updated the repo-build process This commit changes the repo build play such that it no longer requires "yaprt". The intention here is to make the build process less of a blackbox, simpler, and faster. With recent improvements in OpenStack and PIP we're now able to do a lot more without the use of the "yaprt" tool. Repo building is now its own standalone role. This PR now reintroduces the repo-clone ability which is now made smarter. The repo-build process creates a manifest file which is used to provide the ability to sync exactly the contents of the tagged release. This will make repeatable deployments faster for downstream consumers. The repo-store-source.yml play was removed because it hasn't been used as the repo clone process is part of the main repo build process. DocImpact UpgradeImpact Change-Id: Icb0a4e3443491eb0242125ea59f8d5b50f89410b Signed-off-by: Kevin Carter --- CONTRIBUTING.rst | 102 +++++++++ LICENSE | 202 ++++++++++++++++++ README.rst | 17 ++ defaults/main.yml | 32 +++ meta/main.yml | 33 +++ tasks/main.yml | 20 ++ tasks/repo_build.yml | 50 +++++ tasks/repo_clone_git.yml | 25 +++ tasks/repo_post_build.yml | 116 ++++++++++ tasks/repo_pre_build.yml | 66 ++++++ tasks/repo_set_facts.yml | 64 ++++++ templates/global_indexed_links.html.j2 | 12 ++ templates/manifest.in.j2 | 4 + templates/release_index_links.html.j2 | 12 ++ .../requirements_absolute_requirements.txt.j2 | 3 + templates/requirements_constraints.txt.j2 | 19 ++ .../requirements_global_requirements.txt.j2 | 3 + templates/requirements_local_filtered.txt.j2 | 3 + 18 files changed, 783 insertions(+) create mode 100644 CONTRIBUTING.rst create mode 100644 LICENSE create mode 100644 README.rst create mode 100644 defaults/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/main.yml create mode 100644 tasks/repo_build.yml create mode 100644 tasks/repo_clone_git.yml create mode 100644 tasks/repo_post_build.yml create mode 100644 tasks/repo_pre_build.yml create mode 100644 tasks/repo_set_facts.yml create mode 100644 templates/global_indexed_links.html.j2 create mode 100644 templates/manifest.in.j2 create mode 100644 templates/release_index_links.html.j2 create mode 100644 templates/requirements_absolute_requirements.txt.j2 create mode 100644 templates/requirements_constraints.txt.j2 create mode 100644 templates/requirements_global_requirements.txt.j2 create mode 100644 templates/requirements_local_filtered.txt.j2 diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 0000000..4835816 --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,102 @@ +OpenStack repo build +#################### +:tags: openstack, repo, build, cloud, ansible +:category: \*nix + +contributor guidelines +^^^^^^^^^^^^^^^^^^^^^^ + +Filing Bugs +----------- + +Bugs should be filed on Launchpad, not GitHub: "https://bugs.launchpad.net/openstack-ansible" + + +When submitting a bug, or working on a bug, please ensure the following +criteria are met: + +* The description clearly states or describes the original problem or root + cause of the problem. +* Include historical information on how the problem was identified. +* Any relevant logs are included. +* The provided information should be totally self-contained. External access to + web services/sites should not be needed. +* Steps to reproduce the problem if possible. + + +Submitting Code +--------------- + +Changes to the project should be submitted for review via the Gerrit tool, +following the workflow documented at: +"http://docs.openstack.org/infra/manual/developers.html#development-workflow" + +Pull requests submitted through GitHub will be ignored and closed without +regard. + + +Extra +----- + +Tags: + If it's a bug that needs fixing in a branch in addition to Master, add a + '\-backport-potential' tag (eg ``juno-backport-potential``). + There are predefined tags that will autocomplete. + +Status: + Please leave this alone, it should be New till someone triages the issue. + +Importance: + Should only be touched if it is a Blocker/Gating issue. If it is, please + set to High, and only use Critical if you have found a bug that can take + down whole infrastructures. + + +Style guide +----------- + +When creating tasks and other roles for use in Ansible please create then using +the YAML dictionary format. + +Example YAML dictionary format: + .. code-block:: yaml + + - name: The name of the tasks + module_name: + thing1: "some-stuff" + thing2: "some-other-stuff" + tags: + - some-tag + - some-other-tag + + +Example **NOT** in YAML dictionary format: + .. code-block:: yaml + + - name: The name of the tasks + module_name: thing1="some-stuff" thing2="some-other-stuff" + tags: + - some-tag + - some-other-tag + + +Usage of the ">" and "|" operators should be limited to Ansible conditionals +and command modules such as the ansible ``shell`` module. + + +Issues +------ + +When submitting an issue, or working on an issue please ensure the following +criteria are met: + +* The description clearly states or describes the original problem or root + cause of the problem. +* Include historical information on how the problem was identified. +* Any relevant logs are included. +* If the issue is a bug that needs fixing in a branch other than Master, add + the ‘backport potential’ tag TO THE ISSUE (not the PR). +* The provided information should be totally self-contained. External access to + web services/sites should not be needed. +* If the issue is needed for a hotfix release, add the 'expedite' label. +* Steps to reproduce the problem if possible. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e06d208 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..eb2a8f6 --- /dev/null +++ b/README.rst @@ -0,0 +1,17 @@ +OpenStack repo build +##################### +:tags: openstack, repo, build, cloud, ansible +:category: \*nix + +Role to deploy a repository build for both python packages and git sources. + +.. code-block:: yaml + + - name: Setup repo builds + hosts: repo_all + user: root + roles: + - { role: "repo_build", tags: [ "repo-build" ] } + vars: + memcached_builds: 127.0.0.1:11211 + memcached_encryption_key: secrete diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..8b86d1d --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,32 @@ +--- +# Copyright 2015, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +repo_build_use_upper_constraints: true + +repo_build_service_user_name: "nginx" + +repo_build_global_links_path: "/var/www/repo/links" +repo_build_release_path: "/var/www/repo/os-releases" +repo_build_dir: "/tmp/openstack-builder" +repo_build_output: "/tmp/openstack-wheel-output" +repo_build_git_dir: "/var/www/repo/openstackgit" +repo_build_pool_dir: "/var/www/repo/pools" + +repo_build_release_tag: "untagged" + +repo_build_pip_default_index: "https://pypi.python.org/simple" +repo_build_pip_extra_index: "https://pypi.python.org/simple" + +repo_build_timeout: 120 diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..45f6aef --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,33 @@ +--- +# Copyright 2015, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +galaxy_info: + author: rcbops + description: Install package repo build + company: Rackspace + license: Apache2 + min_ansible_version: 1.9.3 + platforms: + - name: Ubuntu + versions: + - trusty + categories: + - cloud + - python + - development + - openstack +dependencies: + - apt_package_pinning + - pip_install diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..f713c52 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,20 @@ +--- +# Copyright 2015, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- include: repo_clone_git.yml +- include: repo_set_facts.yml +- include: repo_pre_build.yml +- include: repo_build.yml +- include: repo_post_build.yml diff --git a/tasks/repo_build.yml b/tasks/repo_build.yml new file mode 100644 index 0000000..f6230ce --- /dev/null +++ b/tasks/repo_build.yml @@ -0,0 +1,50 @@ +--- +# Copyright 2015, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Create OpenStack global requirements wheels + shell: | + pip wheel --timeout {{ repo_build_timeout }} \ + --wheel-dir {{ repo_build_output }} \ + --allow-all-external \ + --find-links {{ repo_build_global_links_path }} \ + --constraint {{ repo_build_release_path }}/{{ repo_build_release_tag }}/requirements_constraints.txt \ + --index-url {{ repo_build_pip_default_index }} \ + --trusted-host {{ repo_build_pip_default_index | netloc_no_port }} \ + --extra-index-url {{ repo_build_pip_extra_index }} \ + --trusted-host {{ repo_build_pip_extra_index | netloc_no_port }} \ + --build {{ repo_build_dir }} \ + --verbose \ + --log /var/log/repo/repo_builder.log \ + --requirement {{ repo_build_release_path }}/{{ repo_build_release_tag }}/requirements_global_requirements.txt + tags: + - repo-build-global-requirement-wheels + +- name: Create OpenStack-Ansible requirement wheels + shell: | + pip wheel --timeout {{ repo_build_timeout }} \ + --wheel-dir {{ repo_build_output }} \ + --allow-all-external \ + --find-links {{ repo_build_output }} \ + --constraint {{ repo_build_release_path }}/{{ repo_build_release_tag }}/requirements_constraints.txt \ + --index-url {{ repo_build_pip_default_index }} \ + --trusted-host {{ repo_build_pip_default_index | netloc_no_port }} \ + --extra-index-url {{ repo_build_pip_extra_index }} \ + --trusted-host {{ repo_build_pip_extra_index | netloc_no_port }} \ + --build {{ repo_build_dir }} \ + --verbose \ + --log /var/log/repo/repo_builder.log \ + --requirement {{ repo_build_release_path }}/{{ repo_build_release_tag }}/requirements_local_filtered.txt + tags: + - repo-build-openstack-ansible-requirement-wheels diff --git a/tasks/repo_clone_git.yml b/tasks/repo_clone_git.yml new file mode 100644 index 0000000..eb5ab63 --- /dev/null +++ b/tasks/repo_clone_git.yml @@ -0,0 +1,25 @@ +--- +# Copyright 2015, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Clone all upstream git repositories + git: + repo: "{{ item['url'] }}" + dest: "{{ repo_build_git_dir }}/{{ item['name'] }}" + clone: yes + update: yes + version: "{{ item['version'] }}" + with_items: local_packages.results.0.item.remote_package_parts + tags: + - repo-clone-repos diff --git a/tasks/repo_post_build.yml b/tasks/repo_post_build.yml new file mode 100644 index 0000000..7dc2cce --- /dev/null +++ b/tasks/repo_post_build.yml @@ -0,0 +1,116 @@ +--- +# Copyright 2015, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Index built wheels + command: "ls -1 {{ repo_build_output }}" + register: built_wheels + tags: + - repo-build-index-wheels + - repo-create-pool + - repo-copy-wheels-to-pool + - repo-create-release-links + - repo-create-links-index + - repo-create-release-manifest + +- name: Create wheel pool structure + file: + path: "{{ repo_build_pool_dir }}/{{ item.split('-')[0] | lower }}" + state: directory + owner: "{{ repo_build_service_user_name }}" + with_items: built_wheels.stdout_lines + tags: + - repo-create-pool + +- name: Remove pool indexes if found + file: + path: "{{ repo_build_pool_dir }}/{{ item.split('-')[0] | lower }}/index.html" + state: absent + with_items: built_wheels.stdout_lines + tags: + - repo-create-pool + +- name: Move wheels into place and ensure permissions + shell: | + if [ ! -f "{{ repo_build_pool_dir }}/{{ item.split('-')[0] | lower }}/{{ item | lower }}" ];then + mv {{ repo_build_output }}/{{ item }} {{ repo_build_pool_dir }}/{{ item.split('-')[0] | lower }}/{{ item | lower }} + elif ! diff {{ repo_build_output }}/{{ item }} {{ repo_build_pool_dir }}/{{ item.split('-')[0] | lower }}/{{ item | lower }} > /dev/null;then + mv {{ repo_build_output }}/{{ item }} {{ repo_build_pool_dir }}/{{ item.split('-')[0] | lower }}/{{ item | lower }} + fi + chown {{ repo_build_service_user_name }} {{ repo_build_pool_dir }}/{{ item.split('-')[0] | lower }}/{{ item | lower }} + with_items: built_wheels.stdout_lines + tags: + - repo-copy-wheels-to-pool + +- name: Create release pool links + file: + dest: "{{ repo_build_release_path }}/{{ repo_build_release_tag }}/{{ item | lower }}" + src: "{{ repo_build_pool_dir }}/{{ item.split('-')[0] | lower }}/{{ item | lower }}" + state: link + owner: "{{ repo_build_service_user_name }}" + with_items: built_wheels.stdout_lines + tags: + - repo-create-release-links + +- name: Create release manifest + template: + src: "manifest.in.j2" + dest: "{{ repo_build_release_path }}/{{ repo_build_release_tag }}/MANIFEST.in" + tags: + - repo-create-release-manifest + +- name: Create absolute requirements + template: + src: "requirements_absolute_requirements.txt.j2" + dest: "{{ repo_build_release_path }}/{{ repo_build_release_tag }}/requirements_absolute_requirements.txt" + tags: + - repo-create-absolute-requirements + +- name: Index built wheels + command: "ls -1 {{ repo_build_release_path }}/{{ repo_build_release_tag }}" + register: indexed_links + tags: + - repo-index-links + - repo-create-release-index + +- name: Create release index + template: + src: "release_index_links.html.j2" + dest: "{{ repo_build_release_path }}/{{ repo_build_release_tag }}/index.html" + tags: + - repo-create-release-index + +- name: Create general index links + file: + dest: "{{ repo_build_global_links_path }}/{{ item | lower }}" + src: "../pools/{{ item.split('-')[0] | lower }}/{{ item | lower }}" + state: link + owner: "{{ repo_build_service_user_name }}" + with_items: built_wheels.stdout_lines + tags: + - repo-create-links-index + +- name: Index general links + command: "ls -1 {{ repo_build_global_links_path }}" + register: global_indexed_links + tags: + - repo-index-links + - repo-create-global-release-index + +- name: Create release index + template: + src: "global_indexed_links.html.j2" + dest: "{{ repo_build_global_links_path }}/index.html" + tags: + - repo-create-global-release-index diff --git a/tasks/repo_pre_build.yml b/tasks/repo_pre_build.yml new file mode 100644 index 0000000..2ae1ad4 --- /dev/null +++ b/tasks/repo_pre_build.yml @@ -0,0 +1,66 @@ +--- +# Copyright 2015, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Ensure workspace files are cleaned up + file: + path: "{{ item }}" + state: "absent" + with_items: + - "{{ repo_build_dir }}" + - "{{ repo_build_output }}" + - "{{ repo_build_release_path }}/{{ repo_build_release_tag }}" + - "{{ repo_build_pool_dir }}/index.html" # pool directory index is removed because its no longer used + tags: + - repo-clean-workspace + +- name: Create release directory + file: + path: "{{ item }}" + state: directory + owner: "{{ repo_build_service_user_name }}" + with_items: + - "{{ repo_build_release_path }}/{{ repo_build_release_tag }}" + - "{{ repo_build_global_links_path }}" + tags: + - repo-create-release-links-location + +- name: Build global package requirements file + template: + src: "requirements_global_requirements.txt.j2" + dest: "{{ repo_build_release_path }}/{{ repo_build_release_tag }}/requirements_global_requirements.txt" + tags: + - repo-build-global-package-files + +- name: Build filtered package requirements file + template: + src: "requirements_local_filtered.txt.j2" + dest: "{{ repo_build_release_path }}/{{ repo_build_release_tag }}/requirements_local_filtered.txt" + tags: + - repo-build-filtered-package-files + +- name: Index cloned repos + shell: "find {{ repo_build_git_dir }}/* -maxdepth 0 -type d" + register: cloned_repos + tags: + - repo-index-cloned-repos + - repo-build-constraints-file + - repo-create-release-manifest + +- name: Build package constraints file + template: + src: "requirements_constraints.txt.j2" + dest: "{{ repo_build_release_path }}/{{ repo_build_release_tag }}/requirements_constraints.txt" + tags: + - repo-build-constraints-file diff --git a/tasks/repo_set_facts.yml b/tasks/repo_set_facts.yml new file mode 100644 index 0000000..fc7e5cd --- /dev/null +++ b/tasks/repo_set_facts.yml @@ -0,0 +1,64 @@ +--- +# Copyright 2015, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Retrieve global requirements content + slurp: + src: "{{ repo_build_git_dir }}/requirements/global-requirements.txt" + register: slurp_global_requirements + tags: + - repo-set-requirement-names-filtered + - repo-set-requirement-names + - repo-set-requirements + - repo-get-global-requirements + +- name: Set requirements + set_fact: + global_requirement: "{{ slurp_global_requirements.content | b64decode | splitlines }}" + tags: + - repo-set-requirement-names-filtered + - repo-set-requirement-names + - repo-set-requirements + +- name: Set requirement names + set_fact: + global_requirement_names: "{{ global_requirement | pip_requirement_names }}" + tags: + - repo-set-requirement-names-filtered + - repo-set-requirement-names + - repo-set-requirements + +- name: Set filtered requirement names + set_fact: + global_requirement_names_filtered: "{{ local_packages.results.0.item.packages | filtered_list(global_requirement_names) }}" + tags: + - repo-set-requirement-names-filtered + - repo-set-requirements + +- name: Retrieve upper constraints content + slurp: + src: "{{ repo_build_git_dir }}/requirements/upper-constraints.txt" + register: slurp_upper_constraints + tags: + - repo-set-constraints + - repo-get-upper-constraints + - repo-build-constraints-file + +- name: Set upper constraints + set_fact: + upper_constraints: "{{ slurp_upper_constraints.content | b64decode | splitlines }}" + when: slurp_upper_constraints | success + tags: + - repo-set-constraints + - repo-build-constraints-file diff --git a/templates/global_indexed_links.html.j2 b/templates/global_indexed_links.html.j2 new file mode 100644 index 0000000..efb0bd6 --- /dev/null +++ b/templates/global_indexed_links.html.j2 @@ -0,0 +1,12 @@ + + + +links for "{{ repo_build_release_tag }}" + + + +{% for item in global_indexed_links.stdout_lines %} +{{ item }}
+{% endfor %} + + diff --git a/templates/manifest.in.j2 b/templates/manifest.in.j2 new file mode 100644 index 0000000..29b1fc1 --- /dev/null +++ b/templates/manifest.in.j2 @@ -0,0 +1,4 @@ +{% for item in built_wheels.stdout_lines %} +{{ repo_build_pool_dir | basename }}/{{ item.split('-')[0] | lower }}/{{ item }} +{{ repo_build_release_path | basename }}/{{ repo_build_release_tag }}/{{ item }} +{% endfor %} \ No newline at end of file diff --git a/templates/release_index_links.html.j2 b/templates/release_index_links.html.j2 new file mode 100644 index 0000000..36b7fc8 --- /dev/null +++ b/templates/release_index_links.html.j2 @@ -0,0 +1,12 @@ + + + +links for "{{ repo_build_release_tag }}" + + + +{% for item in indexed_links.stdout_lines %} +{{ item }}
+{% endfor %} + + \ No newline at end of file diff --git a/templates/requirements_absolute_requirements.txt.j2 b/templates/requirements_absolute_requirements.txt.j2 new file mode 100644 index 0000000..9183186 --- /dev/null +++ b/templates/requirements_absolute_requirements.txt.j2 @@ -0,0 +1,3 @@ +{% for item in built_wheels.stdout_lines %} +{{ item.split('-')[0] | lower }}=={{ item.split('-')[1] | lower }} +{% endfor %} \ No newline at end of file diff --git a/templates/requirements_constraints.txt.j2 b/templates/requirements_constraints.txt.j2 new file mode 100644 index 0000000..d9f9712 --- /dev/null +++ b/templates/requirements_constraints.txt.j2 @@ -0,0 +1,19 @@ +# Computed constraints +{% set constraint_pkgs = [] -%} +{% for clone_item in cloned_repos.stdout_lines -%} +git+file://{{ clone_item }}#egg={{ clone_item | git_link_parse_name | replace('-', '_') | lower }} +{% if constraint_pkgs.append(clone_item | git_link_parse_name | replace('-', '_') | lower) %}{% endif %} +{% endfor %} +# upper boundry constraints from requirements repo. +{% for constraint_item in upper_constraints %} +{%- set constraint_split = constraint_item.split('===') %} +{%- set constraint_name = constraint_split[0] %} +{%- set constraint_name_normalized = constraint_name | replace('-', '_') | lower %} +{% if constraint_name_normalized not in constraint_pkgs %} +{% if repo_build_use_upper_constraints | bool %} +{{ constraint_split[0] | replace('-', '_') | lower }}<={{ constraint_split[1] }} +{% else %} +# {{ constraint_split[0] | replace('-', '_') | lower }}<={{ constraint_split[1] }} +{% endif %} +{% endif %} +{% endfor %} diff --git a/templates/requirements_global_requirements.txt.j2 b/templates/requirements_global_requirements.txt.j2 new file mode 100644 index 0000000..c11cfd4 --- /dev/null +++ b/templates/requirements_global_requirements.txt.j2 @@ -0,0 +1,3 @@ +{% for item in global_requirement %} +{{ item }} +{% endfor %} \ No newline at end of file diff --git a/templates/requirements_local_filtered.txt.j2 b/templates/requirements_local_filtered.txt.j2 new file mode 100644 index 0000000..846c539 --- /dev/null +++ b/templates/requirements_local_filtered.txt.j2 @@ -0,0 +1,3 @@ +{% for item in global_requirement_names_filtered %} +{{ item }} +{% endfor %} \ No newline at end of file