
This adds support for deploying the ARA API server with an optional nginx frontend on EL8. It also sets up integration test jobs to make sure we test it. Change-Id: I7ce026667ea85d8c59e4910572a34d29f78a8dca
85 lines
3.0 KiB
YAML
85 lines
3.0 KiB
YAML
---
|
|
# Copyright (c) 2019 Red Hat, Inc.
|
|
#
|
|
# This file is part of ARA Records Ansible.
|
|
#
|
|
# ARA Records Ansible is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# ARA Records Ansible is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with ARA Records Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# EL8 doesn't install a python3 interpreter by default.
|
|
# System packages rely on /usr/libexec/platform-python and Ansible will use it
|
|
# but we want to use the non-system one. Install it if it's missing.
|
|
- name: Ensure python3 is installed for EL8
|
|
package:
|
|
name: python3
|
|
state: present
|
|
become: yes
|
|
when:
|
|
- ansible_distribution | lower in ["redhat", "centos"]
|
|
- ansible_distribution_major_version == "8"
|
|
|
|
# The ansible_python_version fact might end up retrieving the version of
|
|
# python2 so we need to explicitely get the version of python 3 available.
|
|
- name: Validate availability of Python 3.5
|
|
command: /usr/bin/python3 -c 'import sys; print(".".join(map(str, sys.version_info[:2])))'
|
|
changed_when: false
|
|
failed_when: false
|
|
register: python_version
|
|
|
|
- name: Fail pre-emptively if running Python <3.5
|
|
fail:
|
|
msg: "Python >=3.5 is required to run ARA"
|
|
when: python_version.stdout is version('3.5', '<') or python_version.rc != 0
|
|
|
|
- name: Get list of installed packages
|
|
package_facts:
|
|
manager: "auto"
|
|
no_log: "{{ ara_api_secure_logging }}"
|
|
|
|
- name: Retrieve list of missing required packages
|
|
set_fact:
|
|
ara_api_missing_packages: "{{ ara_api_required_packages | difference(ansible_facts.packages.keys()) }}"
|
|
|
|
# Only attempt to elevate privileges if there are any missing packages
|
|
- when: ara_api_missing_packages | length > 0
|
|
block:
|
|
- name: Install required packages
|
|
become: yes
|
|
package:
|
|
name: "{{ ara_api_required_packages }}"
|
|
state: present
|
|
rescue:
|
|
- name: Fail due to missing packages
|
|
fail:
|
|
msg: "Failed to elevate privileges and install missing required packages. Install the following packages before running this role again: {{ ara_missing_packages | join(' ') }}"
|
|
|
|
# The following tasks dynamically enable escalated privileges only when the
|
|
# directory to create is not located in the user's home directory.
|
|
- name: Ensure ara_api_root_dir exists
|
|
file:
|
|
path: "{{ ara_api_root_dir }}"
|
|
state: directory
|
|
mode: 0755
|
|
|
|
- name: Ensure ara_api_base_dir exists
|
|
file:
|
|
path: "{{ ara_api_base_dir }}"
|
|
state: directory
|
|
mode: 0750
|
|
|
|
- name: Ensure ara_api_log_dir exists
|
|
file:
|
|
path: "{{ ara_api_log_dir }}"
|
|
state: directory
|
|
mode: 0750
|