ara_api role: add support for installing from fedora packages
This patch is self tested by the addition of a new job that exercises the role with the packages but it does not test the current source yet. In order to test the current source, we'll need to set up a job that builds a package from the current source and then configure the job to install from these built packages. Change-Id: Ic326a5243b55b415cd31b8a5702fe92d5dfe0651
This commit is contained in:
parent
2feed6d7d1
commit
b1f23c766a
@ -12,6 +12,8 @@
|
||||
- ansible-role-ara-api-ubuntu-postgresql
|
||||
- ansible-role-ara-api-ubuntu-mysql
|
||||
- ansible-role-ara-api-fedora-distributed-sqlite
|
||||
- ansible-role-ara-api-fedora-packages:
|
||||
voting: false
|
||||
- ansible-role-ara-web-ubuntu
|
||||
- ansible-role-ara-web-fedora
|
||||
- ara-basic-ansible-integration
|
||||
|
@ -98,6 +98,13 @@
|
||||
- zuul: zuul/zuul-jobs
|
||||
run: tests/with_distributed_sqlite.yaml
|
||||
|
||||
# Distribution package tests
|
||||
|
||||
- job:
|
||||
name: ansible-role-ara-api-fedora-packages
|
||||
parent: ansible-role-ara-api-fedora
|
||||
run: tests/with_fedora_packages.yaml
|
||||
|
||||
# ara-web jobs
|
||||
- job:
|
||||
name: ansible-role-ara-web-base
|
||||
|
@ -32,6 +32,7 @@ ara_api_venv_path: "{{ ara_api_root_dir }}/virtualenv"
|
||||
|
||||
# How ARA will be installed
|
||||
# - source [default]: installs from a local or remote git repository
|
||||
# - distribution: installs from distribution packages, if available
|
||||
# - pypi [planned]: installs from pypi
|
||||
ara_api_install_method: source
|
||||
|
||||
|
29
roles/ara_api/tasks/install/distribution.yaml
Normal file
29
roles/ara_api/tasks/install/distribution.yaml
Normal file
@ -0,0 +1,29 @@
|
||||
---
|
||||
# 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/>.
|
||||
|
||||
- name: Validate if the distribution is supported
|
||||
fail:
|
||||
msg: |
|
||||
{{ ansible_distribution }} does not support installation from distribution packages yet.
|
||||
when: ara_distribution_packages | length == 0
|
||||
|
||||
- name: Install ara from distribution packages
|
||||
become: yes
|
||||
package:
|
||||
name: "{{ ara_distribution_packages }}"
|
||||
state: present
|
@ -16,6 +16,10 @@
|
||||
# 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/>.
|
||||
|
||||
ara_distribution_packages:
|
||||
- ara
|
||||
- ara-server
|
||||
|
||||
ara_api_required_packages:
|
||||
- git
|
||||
- python3-virtualenv
|
||||
|
@ -16,6 +16,9 @@
|
||||
# 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/>.
|
||||
|
||||
# ARA has not been packaged for Ubuntu yet
|
||||
ara_distribution_packages: []
|
||||
|
||||
ara_api_required_packages:
|
||||
- git
|
||||
- python3-venv
|
||||
|
@ -19,33 +19,42 @@
|
||||
# as post_tasks inside the same play context as our roles so they have access
|
||||
# to the play and role variables.
|
||||
|
||||
- name: Set defaults for Ansible package name and version
|
||||
set_fact:
|
||||
ara_tests_ansible_name: "{{ ara_tests_ansible_name | default('ansible') }}"
|
||||
ara_tests_ansible_version: "{{ ara_tests_ansible_version | default('latest') }}"
|
||||
- when: ara_api_install_method == "source"
|
||||
block:
|
||||
- name: Set defaults for Ansible package name and version
|
||||
set_fact:
|
||||
ara_tests_ansible_name: "{{ ara_tests_ansible_name | default('ansible') }}"
|
||||
ara_tests_ansible_version: "{{ ara_tests_ansible_version | default('latest') }}"
|
||||
|
||||
# If a version is not explicitly set we want to make sure to
|
||||
# completely omit the version argument to pip, as it will be coming
|
||||
# from the long-form integration_ansible_name variable. Additionally, if
|
||||
# the version is the special value "latest", then we also want to omit
|
||||
# any version number, but also set the package state to "latest".
|
||||
- name: Set Ansible version for installation
|
||||
set_fact:
|
||||
_install_ansible_version: "{{ ara_tests_ansible_version }}"
|
||||
when: ara_tests_ansible_version not in ("", "latest")
|
||||
# If a version is not explicitly set we want to make sure to
|
||||
# completely omit the version argument to pip, as it will be coming
|
||||
# from the long-form integration_ansible_name variable. Additionally, if
|
||||
# the version is the special value "latest", then we also want to omit
|
||||
# any version number, but also set the package state to "latest".
|
||||
- name: Set Ansible version for installation
|
||||
set_fact:
|
||||
_install_ansible_version: "{{ ara_tests_ansible_version }}"
|
||||
when: ara_tests_ansible_version not in ("", "latest")
|
||||
|
||||
- name: Set Ansible package state for installation
|
||||
set_fact:
|
||||
_install_ansible_state: latest
|
||||
when: ara_tests_ansible_version == "latest"
|
||||
- name: Set Ansible package state for installation
|
||||
set_fact:
|
||||
_install_ansible_state: latest
|
||||
when: ara_tests_ansible_version == "latest"
|
||||
|
||||
- name: Install Ansible alongside ARA
|
||||
pip:
|
||||
name: "{{ ara_tests_ansible_name }}"
|
||||
version: "{{ _install_ansible_version | default(omit, True) }}"
|
||||
state: "{{ _install_ansible_state | default(omit, True) }}"
|
||||
virtualenv: "{{ ara_api_venv | bool | ternary(ara_api_venv_path, omit) }}"
|
||||
virtualenv_command: /usr/bin/python3 -m venv
|
||||
- name: Install Ansible alongside ARA
|
||||
pip:
|
||||
name: "{{ ara_tests_ansible_name }}"
|
||||
version: "{{ _install_ansible_version | default(omit, True) }}"
|
||||
state: "{{ _install_ansible_state | default(omit, True) }}"
|
||||
virtualenv: "{{ ara_api_venv | bool | ternary(ara_api_venv_path, omit) }}"
|
||||
virtualenv_command: /usr/bin/python3 -m venv
|
||||
|
||||
- name: Install Ansible from distribution packages
|
||||
become: yes
|
||||
package:
|
||||
name: ansible
|
||||
state: present
|
||||
when: ara_api_install_method == "distribution"
|
||||
|
||||
- name: Get ARA plugins directory
|
||||
environment:
|
||||
@ -62,29 +71,29 @@
|
||||
ARA_SETTINGS: "{{ ara_api_settings }}"
|
||||
ARA_API_CLIENT: "{{ ara_api_client | default('offline') }}"
|
||||
ARA_API_SERVER: "{{ ara_api_server | default('http://127.0.0.1:8000') }}"
|
||||
PATH: "{{ path_with_virtualenv | default('/usr/bin:/usr/local/bin') }}"
|
||||
vars:
|
||||
_ansible_playbook: "{{ ara_api_venv_path }}/bin/ansible-playbook -vvv"
|
||||
_test_root: "{{ ara_api_source_checkout }}/tests/integration"
|
||||
block:
|
||||
# smoke.yaml tests setting ara_playbook_name in one of three plays
|
||||
- name: Run smoke.yaml integration test
|
||||
command: "{{ _ansible_playbook }} {{ _test_root }}/smoke.yaml"
|
||||
command: "ansible-playbook -vvv {{ _test_root }}/smoke.yaml"
|
||||
|
||||
- name: Run hosts.yaml integration test
|
||||
command: "{{ _ansible_playbook }} {{ _test_root }}/hosts.yaml"
|
||||
command: "ansible-playbook -vvv {{ _test_root }}/hosts.yaml"
|
||||
|
||||
- name: Run import.yaml integration test
|
||||
command: "{{ _ansible_playbook }} {{ _test_root }}/import.yaml"
|
||||
command: "ansible-playbook -vvv {{ _test_root }}/import.yaml"
|
||||
|
||||
# Tests setting ara_playbook_name as an extra var
|
||||
- name: Run failed.yaml integration test
|
||||
command: >
|
||||
{{ _ansible_playbook }} {{ _test_root }}/failed.yaml -e ara_playbook_name="Failed playbook"
|
||||
ansible-playbook -vvv {{ _test_root }}/failed.yaml -e ara_playbook_name="Failed playbook"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Run incomplete.yaml integration test
|
||||
shell: |
|
||||
{{ _ansible_playbook }} {{ _test_root }}/incomplete.yaml &
|
||||
ansible-playbook -vvv {{ _test_root }}/incomplete.yaml &
|
||||
sleep 5
|
||||
kill $!
|
||||
args:
|
||||
@ -92,8 +101,7 @@
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Generate static report
|
||||
command: >
|
||||
{{ ara_api_venv_path }}/bin/ara-manage generate {{ ara_api_root_dir }}/static
|
||||
command: ara-manage generate {{ ara_api_root_dir }}/static
|
||||
|
||||
- name: List static report files
|
||||
command: ls -alR {{ ara_api_root_dir }}/static
|
||||
|
45
tests/with_fedora_packages.yaml
Normal file
45
tests/with_fedora_packages.yaml
Normal file
@ -0,0 +1,45 @@
|
||||
# Copyright (c) 2019 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of ARA Records Ansible.
|
||||
#
|
||||
# ARA 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 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
- name: Test the ARA API with fedora packages
|
||||
hosts: all
|
||||
gather_facts: yes
|
||||
vars:
|
||||
ara_api_install_method: distribution
|
||||
ara_api_version: latest
|
||||
ara_api_root_dir: "{{ ansible_user_dir }}/.ara-tests"
|
||||
ara_api_secret_key: testing
|
||||
ara_api_debug: true
|
||||
ara_api_log_level: DEBUG
|
||||
tasks:
|
||||
- block:
|
||||
- name: Set up the API with the ara_api role
|
||||
include_role:
|
||||
name: ara_api
|
||||
public: yes
|
||||
|
||||
# Despite installing from packages, we need access to the source for
|
||||
# running tests
|
||||
- name: Prepare git repository for ara
|
||||
git:
|
||||
repo: "{{ ara_api_source }}"
|
||||
dest: "{{ ara_api_source_checkout }}"
|
||||
version: "{{ (ara_api_version == 'latest') | ternary('HEAD', ara_api_version) }}"
|
||||
|
||||
# These are tasks rather than a standalone playbook to give us an easy
|
||||
# access to all the variables within the same play.
|
||||
- include_tasks: test_tasks.yaml
|
Loading…
x
Reference in New Issue
Block a user