Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Commit

Permalink
Add source installation + requirements installation
Browse files Browse the repository at this point in the history
  • Loading branch information
JGoutin committed Nov 4, 2019
1 parent 056b9a0 commit 43b7772
Show file tree
Hide file tree
Showing 9 changed files with 397 additions and 58 deletions.
2 changes: 2 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
skip_list:
- '304' # Detect CMake option "-DPYTHON3=ON" and environment variable.
11 changes: 0 additions & 11 deletions .yamllint

This file was deleted.

35 changes: 28 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,43 @@ The role requires to be run as root on the target host.
Role Variables
--------------

Installation:
Accelize DRM installation.
* **accelize_drm_python**: If `true`, install the Python library and systemd service. Default to `true`.
* **accelize_drm_devel**: If `true`, install the development C/C++ headers. Default to `false`.
* **accelize_repository_channel**: Accelize Repository channel to use: `stable` or `prerelease`. Default to `stable`.
* **accelize_drm_from_source**: If `true`, install from sources instead of from package. Default to `false`.

DRM Service:
Accelize DRM systemd service configuration.
* **accelize_drm_service_started**: If `true`, start the DRM service and enable it at boot (Require *accelize_drm_python* to `true`). Default to `true`.
* **accelize_drm_disabled**: If `true`, do not license the FPGA, only program FPGA at service start. Default to `false`.
* **fpga_slots**: List of FPGA slots to manage. Default to `[0]`.
* **fpga_image**: List of image to program on FPGA slots. Default to `[]`.
* **accelize_drm_service_started**: If `true`, start the DRM service and enable it at boot. Default to `true`.
* **accelize_drm_disabled**: If `true`, do not license the FPGA, only program FPGA at service start. Default to `false`.
* **accelize_drm_driver_name**: FPGA driver name to use with the Accelize DRM service. Default to `aws_f1`.

DRM Configuration:
Accelize DRM configuration files.
* **accelize_drm_cred_src**: Path to the local `cred.json` file to transfer to the host. Default to `cred.json`.
* **accelize_drm_cred_dst**: Destination path og the `cred.json` file on the target host. Default to `/root/.accelize_drm/cred.json`.
* **accelize_drm_cred_dst**: Destination path of the `cred.json` file on the target host. Default to `/root/.accelize_drm/cred.json`.
* **accelize_drm_conf_src**: Path to the local `conf.json` file to transfer to the host. Default to `conf.json`.
* **accelize_drm_conf_dst**: Destination path og the `conf.json` file on the target host. Default to `/etc/accelize_drm/conf.json`.
* **accelize_repository_channel**: Accelize Repository channel to use: `stable` or `prerelease`. Default to `stable`.
* **accelize_drm_conf_dst**: Destination path of the `conf.json` file on the target host. Default to `/etc/accelize_drm/conf.json`.

Source installation, test & build requirements:
Installation of Accelize DRM build and testing dependencies. Mainly intended to DRM library developers.
* **accelize_drm_git_clone**: If specified, Git clone Accelize DRM to the specified path. Default to `''`.
* **accelize_drm_git_ref**: branch, tag or commit ID to use for source installation and git clone. Default to `master`.
* **accelize_drm_test**: If `true`, install tests dependencies. Default to `false`.
* **accelize_drm_coverage**: If `true`, install coverage dependencies. Default to `false`.
* **accelize_drm_abi_check**: If `true`, install ABI check dependencies. Default to `false`.
* **accelize_drm_build**: If `true`, install build dependencies. Default to `false`.
* **accelize_drm_build_doc**: If `true`, install documentation build dependencies. Default to `false`.
* **accelize_drm_build_package**: If `true`, install packages build & signature dependencies. Default to `false`.
* **accelize_drm_no_install**: If `true`, does not install Accelize DRM, only prepare the environment. Default to `false`.

Example Playbook
----------------

Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:

```yaml
- hosts: servers
become: true
Expand Down
26 changes: 25 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
---
# Accelize repository configuration
# Accelize DRM packages
accelize_drm_python: true
accelize_drm_devel: false

# Accelize repository or source configuration
accelize_repository_channel: stable
accelize_drm_from_source: false

# Accelize DRM credential and configuration files
accelize_drm_cred_src: cred.json
Expand All @@ -20,3 +25,22 @@ accelize_drm_disabled: false
# FPGA configuration:
fpga_image: []
fpga_slots: [0]

# Accelize DRM build configuration
accelize_drm_git_ref: 'master'
accelize_drm_no_install: false
accelize_drm_test: false
accelize_drm_build: false
accelize_drm_build_doc: false
accelize_drm_build_package: false
accelize_drm_coverage: false
accelize_drm_abi_check: false

# Internal variables
_python3: "{{ (ansible_os_family == 'RedHat' and
ansible_distribution_major_version == '7' ) |
ternary('python36', 'python3') }}"
_devel: "{{ (ansible_os_family == 'RedHat') | ternary('devel', 'dev') }}"
_pip_args: "--no-cache-dir --disable-pip-version-check{{
(ansible_distribution_major_version == '7' ) |
ternary(' --prefix /usr', '') }}"
3 changes: 2 additions & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ galaxy_info:
- name: EL
versions:
- 7
- 8
- name: Ubuntu
versions:
- xenial
Expand All @@ -20,8 +21,8 @@ galaxy_info:
- buster
- name: Fedora
versions:
- 29
- 30
- 31
galaxy_tags:
- system
- fpga
Expand Down
12 changes: 4 additions & 8 deletions molecule/default/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# Molecule managed

{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}

RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python python-setuptools sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python3 python3-setuptools sudo python3-devel python3-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python python-setuptools sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
fi
46 changes: 36 additions & 10 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,54 @@ platforms:
- name: ubuntu_bionic
image: ubuntu:bionic
privileged: true
- name: ubuntu_xenial
image: ubuntu:xenial
privileged: true
- name: debian_stretch
image: debian:stretch
privileged: true
- name: debian_buster
image: debian:buster
- name: ubuntu_bionic_deps
image: ubuntu:bionic
privileged: true
- name: ubuntu_latest
image: ubuntu:latest
privileged: true
- name: centos_7
image: centos:7
privileged: true
- name: fedora_29
image: fedora:29
- name: centos_7_from_src
image: centos:7
privileged: true
- name: centos_7_deps
image: centos:7
privileged: true
- name: fedora_30
image: fedora:30
privileged: true

provisioner:
name: ansible
lint:
name: ansible-lint
inventory:
host_vars:
centos_7:
accelize_drm_devel: true
centos_7_from_src:
accelize_drm_from_source: true
accelize_drm_git_clone: /opt
centos_7_deps:
accelize_drm_no_install: true
accelize_drm_test: true
accelize_drm_build: true
accelize_drm_build_doc: true
accelize_drm_build_package: true
accelize_drm_coverage: true
accelize_drm_abi_check: true
ubuntu_bionic:
accelize_drm_devel: true
ubuntu_bionic_deps:
accelize_drm_no_install: true
accelize_drm_test: true
accelize_drm_build: true
accelize_drm_build_doc: true
accelize_drm_build_package: true
accelize_drm_coverage: true
accelize_drm_abi_check: true
verifier:
name: testinfra
lint:
Expand Down
21 changes: 20 additions & 1 deletion molecule/default/tests/test_default.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Test Ansible"""
import os

import pytest
import testinfra.utils.ansible_runner

testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
Expand All @@ -10,15 +11,33 @@ def test_packages_installed(host):
"""
Test that packages are installed
"""
if (host.ansible.get_variables().get('accelize_drm_no_install') or
host.ansible.get_variables().get('accelize_drm_from_source')):
pytest.skip('No packages installed')

assert host.package("libaccelize-drm").is_installed
assert (host.package("python3-accelize-drm").is_installed or
host.package("python36-accelize-drm").is_installed)


def test_include_installed(host):
"""
Test that includes are installed
"""
if (not host.ansible.get_variables().get('accelize_drm_devel') and
not host.ansible.get_variables().get('accelize_drm_from_source')):
pytest.skip('No headers installed')

assert host.file("/usr/include/accelize/drm.h").exists


def test_service_configuration_installed(host):
"""
Test that service configuration file is installed
"""
if not host.ansible.get_variables().get('accelize_drm_python'):
pytest.skip('No service installed')

conf = host.file(
'/etc/systemd/system/accelize_drm.service.d/accelize_drm.conf')
assert conf.exists
Expand Down
Loading

0 comments on commit 43b7772

Please sign in to comment.