From 69eb16d9ae30ae00b5e34f53b4ad1d1ea87ee9f6 Mon Sep 17 00:00:00 2001 From: Taseer Ahmed Date: Thu, 21 Sep 2017 13:26:57 +0500 Subject: [PATCH] Follow the general workflow of PIP --- defaults/main.yml | 3 ++ tasks/congress_install.yml | 107 ++++++++++++++++++++++--------------- 2 files changed, 67 insertions(+), 43 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index e9e1ca5..aa682be 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -14,8 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +congress_package_state: "latest" + congress_git_repo: https://git.openstack.org/openstack/congress congress_git_install_branch: master +congress_developer_mode: false congress_requirements_git_repo: https://git.openstack.org/openstack/requirements congress_requirements_git_install_branch: master congress_developer_mode: false diff --git a/tasks/congress_install.yml b/tasks/congress_install.yml index 4e33191..55560cf 100644 --- a/tasks/congress_install.yml +++ b/tasks/congress_install.yml @@ -14,53 +14,74 @@ # See the License for the specific language governing permissions and # limitations under the License. -- debug: - msg: "This script will install Congress" - -- name: clone requirements repository - git: - repo: "{{ congress_requirements_git_repo }}" - dest: /opt/requirements - clone: yes - update: yes - -- name: create venv directory - file: - path: /openstack/venvs/congress/bin - state: directory - -- name: install pip packages +- name: Install required pip packages pip: - name: "{{ congress_requires_pip_packages }}" - state: present - virtualenv: "/openstack/venvs/congress/" + name: "{{ congress_requires_pip_packages | join(' ') }}" + state: "{{ congress_package_state }}" + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 -- name: get venv checksum - stat: - path: "/var/cache/{{ congress_venv_download_url | basename }}" - get_md5: False - register: local_venv_stat +- name: Retrieve checksum for venv download + uri: + url: "{{ congress_venv_download_url | replace('tgz', 'checksum') }}" + return_content: yes + register: congress_venv_checksum + when: not congress_developer_mode | bool -#- name: get remote venv checksum -# uri: -# url: "{{ congress_venv_download_url | replace('tgz', 'checksum')}}" -# return_content: True +- name: Attempt venv download + get_url: + url: "{{ congress_venv_download_url }}" + dest: "/var/cache/{{ congress_venv_download_url | basename }}" + checksum: "sha1:{{ congress_venv_checksum.content | trim }}" + register: congress_get_venv + when: not congress_developer_mode | bool -- name: clone congress repo - git: - repo: "{{ congress_git_repo }}" - dest: /opt/congress - clone: yes +- name: Remove existing venv + file: + path: "{{ congress_bin | dirname }}" + state: absent + when: congress_get_venv | changed -- name: install congress packages - shell: cd /opt/congress && pip install . +- name: Create congress venv dir + file: + path: "{{ congress_bin | dirname }}" + state: directory + register: congress_venv_dir + when: not congress_developer_mode | bool -#- name: attempt venv download -# get_url: -# url: "{{ congress_venv_download_url }}" -# dest: "/var/cache/{{ congress_venv_download_url | basename }}" -# ignore_errors: true -# register: tacker_get_venv +- name: Unarchive pre-built venv + unarchive: + src: "/var/cache/{{ congress_venv_download_url | basename }}" + dest: "{{ congress_bin | dirname }}" + copy: "no" + when: + - not congress_developer_mode | bool + - congress_get_venv | changed or congress_venv_dir | changed -- name: generating the configuration - shell: tox -egenconfig \ No newline at end of file +- name: Install pip packages + pip: + name: "{{ congress_pip_packages | join(' ') }}" + state: "{{ congress_package_state }}" + virtualenv: "{{ congress_bin | dirname }}" + virtualenv_site_packages: "no" + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + when: congress_developer_mode | bool + +- name: Update virtualenv path + command: > + virtualenv-tools --update-path=auto --reinitialize {{ congress_bin | dirname }} + when: + - not congress_developer_mode | bool + - congress_get_venv | changed or congress_venv_dir | changed + +- name: Record the venv tag deployed + ini_file: + dest: "/etc/ansible/facts.d/openstack_ansible.fact" + section: congress +option: venv_tag + value: "{{ congress_venv_tag }}" \ No newline at end of file