ara-infra/roles/ara_server/tasks/pre-requirements.yaml

64 lines
2.2 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/>.
# 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.6
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.6
fail:
msg: "Python >=3.6 is required to run ara-server"
when: python_version.stdout is version('3.6', '<') or python_version.rc != 0
- name: Include OS family/distribution specific variables
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
- become: true
block:
- name: Install required packages
package:
name: "{{ ara_server_required_packages }}"
state: present
- name: Create user for ara-server
user:
name: "{{ ara_server_user }}"
comment: User for ARA Records Ansible
shell: /sbin/nologin
home: "{{ ara_server_home_dir }}"
- name: Ensure required directories are created with the right permissions
file:
path: "{{ item }}"
state: directory
owner: "{{ ara_server_user }}"
group: "{{ ara_server_group }}"
mode: 0750
loop:
- "{{ ara_server_home_dir }}"
- "{{ ara_server_base_dir }}"
- "{{ ara_server_config_dir }}"
- "{{ ara_server_log_dir }}"