openstack-ansible-os_ceilom.../tasks/ceilometer_install.yml
Jesse Pretorius 983f2fa402 Add venv_tag local fact
In order to make it easier to detect the currently deployed
venv for a service, and therefore allow smarter decisions
for things like upgrading, we implement the venv tag as a
local fact.

The file used to store facts will be the same for all
OpenStack services, with each service using its own section.

Example:

"ansible_local": {
    "openstack_ansible": {
        "ceilometer": {
            "venv_tag": "14.2.1"
        }
    }
}

Change-Id: I52edede590813edf22db2a2c99c99d8fe2610dc0
(cherry picked from commit c53f12e041)
2017-05-22 18:19:48 +00:00

148 lines
4.8 KiB
YAML

---
# Copyright 2014, 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: Install distro packages
package:
name: "{{ item }}"
state: "{{ ceilometer_package_state }}"
update_cache: "{{ (ansible_pkg_mgr == 'apt') | 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
with_items: "{{ ceilometer_distro_packages }}"
- name: Install distro packages required in Developer Mode
package:
name: "{{ item }}"
state: "{{ ceilometer_package_state }}"
update_cache: "{{ (ansible_pkg_mgr == 'apt') | 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
with_items: "{{ ceilometer_developer_mode_distro_packages }}"
when:
- ceilometer_developer_mode | bool
- name: Install distro packages for Apache
package:
name: "{{ item }}"
state: "{{ ceilometer_package_state }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items: "{{ ceilometer_apache_distro_packages }}"
when:
- inventory_hostname in groups['ceilometer_api']
- name: Create developer mode constraint file
copy:
dest: "/opt/developer-pip-constraints.txt"
content: |
{% for item in ceilometer_developer_constraints %}
{{ item }}
{% endfor %}
when:
- ceilometer_developer_mode | bool
- name: Install requires pip packages
pip:
name: "{{ ceilometer_requires_pip_packages }}"
state: "{{ ceilometer_pip_package_state }}"
extra_args: >-
{{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }}
{{ pip_install_options | default('') }}
register: install_packages
until: install_packages|success
retries: 5
delay: 2
- name: Retrieve checksum for venv download
uri:
url: "{{ ceilometer_venv_download_url | replace('tgz', 'checksum') }}"
return_content: yes
register: ceilometer_venv_checksum
when: ceilometer_venv_download | bool
- name: Attempt venv download
get_url:
url: "{{ ceilometer_venv_download_url }}"
dest: "/var/cache/{{ ceilometer_venv_download_url | basename }}"
checksum: "sha1:{{ ceilometer_venv_checksum.content | trim }}"
register: ceilometer_get_venv
when: ceilometer_venv_download | bool
- name: Remove existing venv
file:
path: "{{ ceilometer_bin | dirname }}"
state: absent
when: ceilometer_get_venv | changed
- name: Create ceilometer venv dir
file:
path: "{{ ceilometer_bin | dirname }}"
state: directory
register: ceilometer_venv_dir
when: ceilometer_get_venv | changed
- name: Unarchive pre-built venv
unarchive:
src: "/var/cache/{{ ceilometer_venv_download_url | basename }}"
dest: "{{ ceilometer_bin | dirname }}"
copy: "no"
when: ceilometer_get_venv | changed
notify: Restart ceilometer services
- name: Install pip packages
pip:
name: "{{ ceilometer_pip_packages }}"
state: "{{ ceilometer_pip_package_state }}"
virtualenv: "{{ ceilometer_bin | dirname }}"
virtualenv_site_packages: "no"
extra_args: >-
{{ ceilometer_developer_mode | ternary('--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
until: install_packages|success
retries: 5
delay: 2
when: ceilometer_get_venv | failed or ceilometer_get_venv | skipped
notify: Restart ceilometer services
- name: CentOS remove python from path first
file:
path: "{{ ceilometer_bin | dirname }}/bin/python2.7"
state: "absent"
when:
- ansible_pkg_mgr == 'yum'
- ceilometer_get_venv | changed
- name: Update virtualenv path
command: >
virtualenv-tools --update-path=auto --reinitialize {{ ceilometer_bin | dirname }}
when: ceilometer_get_venv | changed
- name: Record the venv tag deployed
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: ceilometer
option: venv_tag
value: "{{ ceilometer_venv_tag }}"