Skip to content
Snippets Groups Projects
Commit c5d5fc7f authored by Anders Harrisson's avatar Anders Harrisson
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
[flake8]
ignore = E501
.molecule
.vagrant
.cache
*.swp
.DS_Store
__pycache__
*.pyc
.vault_pass
---
include: 'https://gitlab.esss.lu.se/ics-infrastructure/gitlab-ci-yml/raw/master/Molecule.gitlab-ci.yml'
extends: default
rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
line-length: disable
# NOTE(retr0h): Templates no longer fail this lint rule.
# Uncomment if running old Molecule templates.
# truthy: disable
LICENSE 0 → 100644
BSD 2-Clause License
Copyright (c) 2019, European Spallation Source ERIC
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ics-ans-role-phoebus
Ansible role to install phoebus.
## Role Variables
```yaml
phoebus_installation_dir: /opt
phoebus_installations_keep: 2
phoebus_version: 4.6.0-SNAPSHOT
phoebus_archive: "http://artifactory.esss.lu.se/artifactory/libs-snapshot-local/se/europeanspallationsource/ics/ess-phoebus/{{ phoebus_version }}/ess-phoebus-{{ phoebus_version }}-bin.tar.gz"
```
## Example Playbook
```yaml
- hosts: servers
roles:
- role: ics-ans-role-phoebus
```
## License
BSD 2-clause
---
phoebus_installation_dir: /opt
phoebus_installations_keep: 2
phoebus_version: 4.6.0-SNAPSHOT
phoebus_archive: "http://artifactory.esss.lu.se/artifactory/libs-snapshot-local/se/europeanspallationsource/ics/ess-phoebus/{{ phoebus_version }}/ess-phoebus-{{ phoebus_version }}-bin.tar.gz"
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/pvtable">
<comment>PV Table</comment>
<glob pattern="*.pvs"/>
</mime-type>
<mime-type type="application/pvtable">
<comment>PV Table</comment>
<glob pattern="*.sav"/>
</mime-type>
</mime-info>
---
- name: Update MIME database
command: update-mime-database /usr/share/mime
---
galaxy_info:
author: Anders Harrisson
company: European Spallation Source ERIC
description: Ansible role to install phoebus.
license: BSD
min_ansible_version: 2.7
platforms:
- name: CentOS
versions:
- 7
dependencies:
- role: ics-ans-role-java
# 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
---
dependency:
name: galaxy
lint:
name: yamllint
provisioner:
name: ansible
config_options:
defaults:
gather_timeout: 20
lint:
name: ansible-lint
inventory:
group_vars:
molecule_group:
scenario:
name: default
verifier:
name: testinfra
lint:
name: flake8
driver:
name: docker
platforms:
- name: ics-ans-role-phoebus-default
image: centos:7
groups:
- molecule_group
---
- name: Converge
hosts: all
become: true
roles:
- role: ics-ans-role-phoebus
---
- name: Prepare
hosts: all
gather_facts: false
tasks: []
---
- src: git+https://gitlab.esss.lu.se/ics-ansible-galaxy/ics-ans-role-java.git
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
PHOEBUS_VERSION = '4.6.0-SNAPSHOT'
def test_default(host):
cmd = host.run("/opt/ess-phoebus-{}/phoebus.sh -help".format(PHOEBUS_VERSION))
assert cmd.rc == 0
assert " _______ _______ _______ ______ _______ \n" + \
"( ____ )|\\ /|( ___ )( ____ \\( ___ \\ |\\ /|( ____ \\\n" + \
"| ( )|| ) ( || ( ) || ( \\/| ( ) )| ) ( || ( \\/\n" + \
"| (____)|| (___) || | | || (__ | (__/ / | | | || (_____ \n" + \
"| _____)| ___ || | | || __) | __ ( | | | |(_____ )\n" + \
"| ( | ( ) || | | || ( | ( \\ \\ | | | | ) |\n" + \
"| ) | ) ( || (___) || (____/\\| )___) )| (___) |/\\____) |\n" + \
"|/ |/ \\|(_______)(_______/|/ \\___/ (_______)\\_______)" in cmd.stdout
---
- name: install required dependencies
yum:
name:
- tar
- gzip
state: present
- name: create installation directory
file:
path: "{{ phoebus_installation_dir }}"
state: directory
owner: root
group: root
mode: 0755
- name: install Phoebus
unarchive:
src: "{{ phoebus_archive }}"
dest: "{{ phoebus_installation_dir }}"
remote_src: true
owner: root
group: root
creates: "{{ phoebus_home }}"
- name: add MIME types
copy:
src: phoebus.xml
dest: /usr/share/mime/packages
owner: root
group: root
mode: 0644
notify: Update MIME database
- name: add Phoebus to desktop menu
template:
src: phoebus.desktop.j2
dest: /usr/share/applications/phoebus.desktop
owner: root
group: root
mode: 0644
- name: Get all installations
find:
paths: "{{ phoebus_installation_dir }}"
pattern: "ess-phoebus-*"
file_type: directory
register: phoebus_installations
- name: Remove obsolete installations
file:
path: "{{ item.path }}"
state: absent
loop: "{{ (phoebus_installations.files | sort(attribute='ctime', reverse=True))[phoebus_installations_keep:] }}"
[Desktop Entry]
Type=Application
Terminal=false
Name=Phoebus
Exec="{{ phoebus_home }}/phoebus.sh" -resource %f
---
phoebus_home: "{{ phoebus_installation_dir }}/ess-phoebus-{{ phoebus_version }}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment