Update installation mechanism

The following adjustments are made in order to modernise
bring the role into line with the other mainline roles:

1. Simplify the constraints mechanism.

2. Add the developer mode constraints functionality.

3. Clean up developer mode logic to allow pip installs
   into an existing venv if the deployer chooses to do so.

4. Normalise the distro package install task to make it
   use the same name, to add retries and ensure that the
   cache updates appropriately.

5. Clean up some commented vars and tasks which were not
   used.

6. Simplify the use of checksums for the venv downloads
   to use modern Ansible functionality.

7. Add additional python venv prep for SuSE/CentOS.

8. Add the recording of the current venv tag deployed.

Change-Id: I9daa4352aa818db03f682eb0d1a65eefff9bb6f6
This commit is contained in:
Jesse Pretorius 2018-02-15 15:13:51 +00:00
parent f093af0173
commit 50515b6995
3 changed files with 44 additions and 71 deletions

View File

@ -27,18 +27,13 @@ tacker_pip_package_state: "latest"
tacker_git_repo: https://git.openstack.org/openstack/tacker tacker_git_repo: https://git.openstack.org/openstack/tacker
tacker_git_install_branch: master tacker_git_install_branch: master
tacker_requirements_git_repo: https://git.openstack.org/openstack/requirements
tacker_requirements_git_install_branch: master
tacker_developer_mode: false tacker_developer_mode: false
tacker_developer_constraints: tacker_developer_constraints:
- "git+{{ tacker_git_repo }}@{{ tacker_git_install_branch }}#egg=tacker" - "git+{{ tacker_git_repo }}@{{ tacker_git_install_branch }}#egg=tacker"
#tacker_venv_enabled: true
# Name of the virtual env to deploy into # Name of the virtual env to deploy into
tacker_venv_tag: untagged tacker_venv_tag: untagged
tacker_bin: "/openstack/venvs/tacker-{{ tacker_venv_tag }}/bin" tacker_bin: "/openstack/venvs/tacker-{{ tacker_venv_tag }}/bin"
#tacker_venv_bin: "/openstack/venvs/tacker-{{ tacker_venv_tag }}/bin"
# Set the etc dir path where tacker is installed. # Set the etc dir path where tacker is installed.
# This is used for role access to the db migrations. # This is used for role access to the db migrations.
@ -46,6 +41,9 @@ tacker_bin: "/openstack/venvs/tacker-{{ tacker_venv_tag }}/bin"
# tacker_etc_dir: "/usr/local/etc/tacker" # tacker_etc_dir: "/usr/local/etc/tacker"
tacker_etc_dir: "/etc/tacker" tacker_etc_dir: "/etc/tacker"
# venv_download, even when true, will use the fallback method of building the
# venv from scratch if the venv download fails.
tacker_venv_download: "{{ not tacker_developer_mode | bool }}"
tacker_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/tacker.tgz tacker_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/tacker.tgz

View File

@ -15,10 +15,16 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
- name: Install tacker packages - name: Install distro packages
package: package:
name: "{{ tacker_distro_packages }}" name: "{{ tacker_distro_packages }}"
state: "{{ tacker_package_state }}" state: "{{ tacker_package_state }}"
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
- name: Create developer mode constraint file - name: Create developer mode constraint file
copy: copy:
@ -30,65 +36,34 @@
when: when:
- tacker_developer_mode | bool - tacker_developer_mode | bool
- name: Clone requirements git repository
git:
repo: "{{ tacker_requirements_git_repo }}"
dest: "/opt/requirements"
clone: yes
update: yes
version: "{{ tacker_requirements_git_install_branch }}"
when:
- tacker_developer_mode | bool
- name: Add constraints to pip_install_options fact for developer mode
set_fact:
pip_install_options_fact: "{{ pip_install_options|default('') }} --constraint /opt/developer-pip-constraints.txt --constraint /opt/requirements/upper-constraints.txt"
when:
- tacker_developer_mode | bool
- name: Set pip_install_options_fact when not in developer mode
set_fact:
pip_install_options_fact: "{{ pip_install_options|default('') }}"
when:
- not tacker_developer_mode | bool
- name: Install requires pip packages - name: Install requires pip packages
pip: pip:
name: "{{ tacker_requires_pip_packages | join(' ') }}" name: "{{ tacker_requires_pip_packages }}"
state: "{{ tacker_pip_package_state }}" state: "{{ tacker_pip_package_state }}"
extra_args: "{{ pip_install_options_fact }}" extra_args: >-
{{ tacker_developer_mode | ternary(pip_install_developer_constraints | default('--constraint /opt/developer-pip-constraints.txt'), '') }}
{{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }}
{{ pip_install_options | default('') }}
register: install_packages register: install_packages
until: install_packages|success until: install_packages|success
retries: 5 retries: 5
delay: 2 delay: 2
tags:
- skip_ansible_lint
- name: Get local venv checksum - name: Retrieve checksum for venv download
stat:
path: "/var/cache/{{ tacker_venv_download_url | basename }}"
get_md5: False
when:
- not tacker_developer_mode | bool
register: local_venv_stat
- name: Get remote venv checksum
uri: uri:
url: "{{ tacker_venv_download_url | replace('tgz', 'checksum') }}" url: "{{ tacker_venv_download_url | replace('tgz', 'checksum') }}"
return_content: True return_content: yes
when:
- not tacker_developer_mode | bool
register: tacker_venv_checksum register: tacker_venv_checksum
when: tacker_venv_download | bool
- name: Attempt venv download - name: Attempt venv download
get_url: get_url:
url: "{{ tacker_venv_download_url }}" url: "{{ tacker_venv_download_url }}"
dest: "/var/cache/{{ tacker_venv_download_url | basename }}" dest: "/var/cache/{{ tacker_venv_download_url | basename }}"
checksum: "sha1:{{ tacker_venv_checksum.content | trim }}" checksum: "sha1:{{ tacker_venv_checksum.content | trim }}"
ignore_errors: true
register: tacker_get_venv register: tacker_get_venv
when: when:
- not tacker_developer_mode | bool - tacker_venv_download | bool
- name: Remove existing venv - name: Remove existing venv
file: file:
@ -102,6 +77,8 @@
path: "{{ tacker_bin | dirname }}" path: "{{ tacker_bin | dirname }}"
state: directory state: directory
register: tacker_venv_dir register: tacker_venv_dir
when:
- tacker_get_venv | changed
- name: Unarchive pre-built venv - name: Unarchive pre-built venv
unarchive: unarchive:
@ -109,28 +86,36 @@
dest: "{{ tacker_bin | dirname }}" dest: "{{ tacker_bin | dirname }}"
copy: "no" copy: "no"
when: when:
- not tacker_developer_mode | bool - tacker_get_venv | changed
- tacker_get_venv | changed or tacker_venv_dir | changed
notify: notify:
- Restart tacker services - Restart tacker services
- name: Install pip packages - name: Install pip packages
pip: pip:
name: "{{ tacker_pip_packages | join(' ') }}" name: "{{ tacker_pip_packages }}"
state: "{{ tacker_pip_package_state }}" state: "{{ tacker_pip_package_state }}"
virtualenv: "{{ tacker_bin | dirname }}" virtualenv: "{{ tacker_bin | dirname }}"
virtualenv_site_packages: "no" virtualenv_site_packages: "no"
extra_args: "{{ pip_install_options_fact }}" extra_args: >-
{{ tacker_developer_mode | ternary(pip_install_developer_constraints | default('--constraint /opt/developer-pip-constraints.txt'), '') }}
{{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }}
{{ pip_install_options | default('') }}
register: install_packages register: install_packages
until: install_packages|success until: install_packages|success
retries: 5 retries: 5
delay: 2 delay: 2
when: when:
- tacker_get_venv | failed or tacker_developer_mode | bool - tacker_get_venv | failed or tacker_get_venv | skipped
notify: notify:
- Restart tacker services - Restart tacker services
tags:
- skip_ansible_lint - name: Remove python from path first (CentOS, openSUSE)
file:
path: "{{ tacker_bin | dirname }}/bin/python2.7"
state: "absent"
when:
- ansible_pkg_mgr in ['yum', 'dnf', 'zypper']
- tacker_get_venv | changed
- name: Update virtualenv path - name: Update virtualenv path
shell: | shell: |
@ -140,5 +125,11 @@
tags: tags:
- skip_ansible_lint - skip_ansible_lint
when: when:
- not tacker_developer_mode | bool - tacker_get_venv | changed
- tacker_get_venv | success
- name: Record the venv tag deployed
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: tacker
option: venv_tag
value: "{{ tacker_venv_tag }}"

View File

@ -15,22 +15,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
#- name: Get tacker command path
#command: which {{ tacker_program_name }}
#register: tacker_command_path
#when:
#- not tacker_venv_enabled | bool
#tags:
#- tacker-command-bin
#- name: Set tacker command path
#set_fact:
#tacker_bin: "{{ tacker_command_path.stdout | dirname }}"
#when:
#- not tacker_venv_enabled | bool
#tags:
#- tacker-command-bin
- name: Drop tacker Config(s) - name: Drop tacker Config(s)
config_template: config_template:
src: "{{ item.src }}" src: "{{ item.src }}"