From c82ef96e1d8b2f63e18015ba9620bcc43e92a953 Mon Sep 17 00:00:00 2001 From: Travis Truman Date: Fri, 20 May 2016 14:56:11 -0400 Subject: [PATCH] Updating os_horizon to use the Multi-Distro framework Debian-specific vars and logic have been moved to tasks that will execute only on those distributions. Change-Id: I16664a9c4364938a065bf07472e25e93ba1b828c Implements: blueprint multi-platform-host --- defaults/main.yml | 13 ------------ meta/main.yml | 4 +++- tasks/horizon_install.yml | 32 ++++------------------------ tasks/install-apt.yml | 44 +++++++++++++++++++++++++++++++++++++++ tasks/main.yml | 9 ++++++++ vars/debian.yml | 27 ++++++++++++++++++++++++ 6 files changed, 87 insertions(+), 42 deletions(-) create mode 100644 tasks/install-apt.yml create mode 100644 vars/debian.yml diff --git a/defaults/main.yml b/defaults/main.yml index e0c0dc68..8090fc6b 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -24,9 +24,6 @@ horizon_requirements_git_install_branch: master horizon_developer_constraints: - "git+{{ horizon_git_repo }}@{{ horizon_git_install_branch }}#egg=horizon" -## APT Cache options -cache_timeout: 600 - # Name of the virtual env to deploy into horizon_venv_tag: untagged horizon_venv_bin: "/openstack/venvs/horizon-{{ horizon_venv_tag }}/bin" @@ -167,16 +164,6 @@ horizon_listen_ports: - "80" - "443" -horizon_apt_packages: - - apache2 - - apache2-utils - - cron # required by the Ansible cron module - - libapache2-mod-wsgi - - libssl-dev - - libxslt1.1 - - openssl - - python-mysqldb # required by the Ansible mysql_db module - # horizon packages that must be installed before anything else horizon_requires_pip_packages: - virtualenv diff --git a/meta/main.yml b/meta/main.yml index 9b1d2162..6a55128f 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -36,6 +36,8 @@ dependencies: - role: pip_install when: - horizon_developer_mode | bool - - apt_package_pinning + - role: apt_package_pinning + when: + - ansible_pkg_mgr == 'apt' - galera_client - openstack_openrc diff --git a/tasks/horizon_install.yml b/tasks/horizon_install.yml index ea6eace6..92e1a4ab 100644 --- a/tasks/horizon_install.yml +++ b/tasks/horizon_install.yml @@ -13,22 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -#TODO(evrardjp): Replace the next 2 tasks by a standard apt with cache -#when https://github.com/ansible/ansible-modules-core/pull/1517 is merged -#in 1.9.x or we move to 2.0 (if tested working) -- name: Check apt last update file - stat: - path: /var/cache/apt - register: apt_cache_stat +- include: install-apt.yml + when: + - ansible_pkg_mgr == 'apt' tags: - - horizon-apt-packages - -- name: Update apt if needed - apt: - update_cache: yes - when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" - tags: - - horizon-apt-packages + - install-apt - name: Create developer mode constraint file copy: @@ -74,19 +63,6 @@ - horizon-install - horizon-pip-packages -- name: Install apt packages - apt: - pkg: "{{ item }}" - state: latest - register: install_packages - until: install_packages|success - retries: 5 - delay: 2 - with_items: "{{ horizon_apt_packages }}" - tags: - - horizon-install - - horizon-apt-packages - - name: Install requires pip packages pip: name: "{{ item }}" diff --git a/tasks/install-apt.yml b/tasks/install-apt.yml new file mode 100644 index 00000000..98aea006 --- /dev/null +++ b/tasks/install-apt.yml @@ -0,0 +1,44 @@ +--- +# 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. + +#TODO(evrardjp): Replace the next 2 tasks by a standard apt with cache +#when https://github.com/ansible/ansible-modules-core/pull/1517 is merged +#in 1.9.x or we move to 2.0 (if tested working) +- name: Check apt last update file + stat: + path: /var/cache/apt + register: apt_cache_stat + tags: + - horizon-apt-packages + +- name: Update apt if needed + apt: + update_cache: yes + when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" + tags: + - horizon-apt-packages + +- name: Install apt packages + apt: + pkg: "{{ item }}" + state: latest + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: "{{ horizon_apt_packages }}" + tags: + - horizon-install + - horizon-apt-packages \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index 8ae921e1..6e366ba0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -13,6 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Gather variables for each operating system + include_vars: "{{ item }}" + with_first_found: + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" + - "{{ ansible_distribution | lower }}.yml" + - "{{ ansible_os_family | lower }}.yml" + tags: + - always + - include: horizon_pre_install.yml - include: horizon_install.yml - include: horizon_post_install.yml diff --git a/vars/debian.yml b/vars/debian.yml new file mode 100644 index 00000000..837f71b7 --- /dev/null +++ b/vars/debian.yml @@ -0,0 +1,27 @@ +--- +# 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. + +## APT Cache options +cache_timeout: 600 + +horizon_apt_packages: + - apache2 + - apache2-utils + - cron # required by the Ansible cron module + - libapache2-mod-wsgi + - libssl-dev + - libxslt1.1 + - openssl + - python-mysqldb # required by the Ansible mysql_db module