diff --git a/Vagrantfile b/Vagrantfile index f989614..a73fe52 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,5 +1,9 @@ Vagrant.configure(2) do |config| config.vm.box = "ubuntu/trusty64" + config.vm.provider "virtualbox" do |v| + v.memory = 2048 + v.cpus = 2 + end config.vm.provision "shell", inline: <<-SHELL sudo su - cd /vagrant diff --git a/defaults/main.yml b/defaults/main.yml index e007330..2233f05 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -63,6 +63,12 @@ barbican_developer_mode: false barbican_developer_constraints: - "git+{{ barbican_git_repo }}@{{ barbican_git_install_branch }}#egg=barbican" +# Name of the virtual env to deploy into +barbican_venv_tag: untagged +barbican_bin: "/openstack/venvs/barbican-{{ barbican_venv_tag }}/bin" + +barbican_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/barbican.tgz + # Database vars barbican_galera_database: barbican barbican_galera_user: barbican @@ -103,6 +109,11 @@ barbican_ssl_self_signed_subject: "/C=US/ST=Texas/L=San Antonio/O=IT/CN={{ inter #barbican_user_ssl_key: #barbican_user_ssl_ca_cert: +barbican_requires_pip_packages: + - virtualenv + - virtualenv-tools + - python-keystoneclient # Keystoneclient needed by OSA keystone lib + barbican_pip_packages: - alembic - Babel diff --git a/handlers/main.yml b/handlers/main.yml index 08d6da9..ab27482 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -22,3 +22,8 @@ until: apache_restart|success retries: 5 delay: 2 + +- name: Restart barbican services + service: + name: "{{ barbican_uwsgi_program_name }}" + state: "restarted" \ No newline at end of file diff --git a/run_tests.sh b/run_tests.sh index 6a711cf..0362a71 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -19,7 +19,7 @@ FUNCTIONAL_TEST=${FUNCTIONAL_TEST:-true} # prep the host if [ "$(which apt-get)" ]; then - apt-get install -y build-essential python2.7 python-dev git-core + apt-get install -y build-essential python2.7 python-dev git-core libssl-dev fi # get pip, if necessary diff --git a/tasks/database-setup.yml b/tasks/database-setup.yml index dc4f643..bc39b1a 100644 --- a/tasks/database-setup.yml +++ b/tasks/database-setup.yml @@ -14,6 +14,6 @@ # limitations under the License. - name: Perform a synchronization of the Barbican database - command: "barbican-db-manage upgrade" + command: "{{ barbican_bin }}/barbican-db-manage upgrade" become: yes become_user: "{{ barbican_system_user_name }}" diff --git a/tasks/install.yml b/tasks/install.yml index 67f68e1..1001533 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -49,13 +49,98 @@ when: - not barbican_developer_mode | bool -- name: Install pip packages for Barbican +- name: Install requires pip packages pip: name: "{{ item }}" - state: "latest" + state: latest extra_args: "{{ pip_install_options_fact }}" - register: install_barbican_pip_packages - until: install_barbican_pip_packages |success + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: "{{ barbican_requires_pip_packages }}" + +- name: Get local venv checksum + stat: + path: "/var/cache/{{ barbican_venv_download_url | basename }}" + get_md5: False + when: + - not barbican_developer_mode | bool + register: local_venv_stat + +- name: Get remote venv checksum + uri: + url: "{{ barbican_venv_download_url | replace('tgz', 'checksum') }}" + return_content: True + when: + - not barbican_developer_mode | bool + register: remote_venv_checksum + +# TODO: When project moves to ansible 2 we can pass this a sha256sum which will: +# a) allow us to remove force: yes +# b) allow the module to calculate the checksum of dest file which would +# result in file being downloaded only if provided and dest sha256sum +# checksums differ +- name: Attempt venv download + get_url: + url: "{{ barbican_venv_download_url }}" + dest: "/var/cache/{{ barbican_venv_download_url | basename }}" + force: yes + ignore_errors: true + register: get_venv + when: + - not barbican_developer_mode | bool + - (local_venv_stat.stat.exists == False or + {{ local_venv_stat.stat.checksum is defined and local_venv_stat.stat.checksum != remote_venv_checksum.content | trim }}) + +- name: Set barbican get_venv fact + set_fact: + barbican_get_venv: "{{ get_venv }}" + +- name: Remove existing venv + file: + path: "{{ barbican_bin | dirname }}" + state: absent + when: + - barbican_get_venv | changed + +- name: Create barbican venv dir + file: + path: "{{ barbican_bin | dirname }}" + state: directory + register: barbican_venv_dir + when: + - not barbican_developer_mode | bool + +- name: Unarchive pre-built venv + unarchive: + src: "/var/cache/{{ barbican_venv_download_url | basename }}" + dest: "{{ barbican_bin | dirname }}" + copy: "no" + when: + - not barbican_developer_mode | bool + - barbican_get_venv | changed or barbican_venv_dir | changed + notify: Restart barbican services + +- name: Install pip packages + pip: + name: "{{ item }}" + state: latest + virtualenv: "{{ barbican_bin | dirname }}" + virtualenv_site_packages: "no" + extra_args: "{{ pip_install_options_fact }}" + register: install_packages + until: install_packages|success retries: 5 delay: 2 with_items: "{{ barbican_pip_packages }}" + when: + - barbican_get_venv | failed or barbican_developer_mode | bool + notify: Restart barbican services + +- name: Update virtualenv path + command: > + virtualenv-tools --update-path=auto {{ barbican_bin | dirname }} + when: + - not barbican_developer_mode | bool + - barbican_get_venv | success diff --git a/tasks/main.yml b/tasks/main.yml index ab49571..5321a4e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -56,10 +56,5 @@ tags: - barbican-install -- name: Restart Barbican Services - service: - name: "{{ barbican_uwsgi_program_name }}" - state: "restarted" - - name: Flush handlers meta: flush_handlers diff --git a/templates/upstart-init.j2 b/templates/upstart-init.j2 index ccf4142..ea8a303 100644 --- a/templates/upstart-init.j2 +++ b/templates/upstart-init.j2 @@ -12,7 +12,7 @@ respawn respawn limit 10 5 # Set the RUNBIN environment variable -env RUNBIN="/usr/local/bin/{{ program_name }}" +env RUNBIN="{{ barbican_bin }}/{{ program_name }}" # Change directory to service users home chdir "{{ service_home }}"