Update Zaqar image

Follow Zaqar installation documentation [1]

[1] https://docs.openstack.org/zaqar/latest/install/

Change-Id: Ic356fb81c19ebbc78aa3c7e871c4946d1f712a45
Implements: blueprint ansible-zaqar
This commit is contained in:
Kien Nguyen 2018-10-16 17:40:51 +07:00
parent f16e410542
commit cf2b2b55b6
8 changed files with 141 additions and 85 deletions

View File

@ -1,77 +0,0 @@
FROM {{ namespace }}/{{ image_prefix }}openstack-base:{{ tag }}
LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"
{% block zaqar_header %}{% endblock %}
{% import "macros.j2" as macros with context %}
{{ macros.configure_user(name='zaqar') }}
{% if install_type == 'binary' %}
{% if base_distro in ['centos', 'oraclelinux', 'rhel'] %}
{% set zaqar_packages = [
'httpd',
'mod_ssl',
'mod_wsgi',
'openstack-zaqar'
] %}
{{ macros.install_packages(zaqar_packages | customizable("packages")) }}
RUN sed -i -r 's,^(Listen 80),#\1,' /etc/httpd/conf/httpd.conf \
&& sed -i -r 's,^(Listen 443),#\1,' /etc/httpd/conf.d/ssl.conf
{% elif base_distro in ['debian', 'ubuntu'] %}
{% set zaqar_packages = [
'apache2',
'libapache2-mod-wsgi',
'zaqar-common',
'zaqar-server'
] %}
{{ macros.install_packages(zaqar_packages | customizable("packages")) }}
RUN echo > /etc/apache2/ports.conf
{% endif %}
{% elif install_type == 'source' %}
{% if base_distro in ['centos', 'oraclelinux', 'rhel'] %}
{% set zaqar_packages = [
'httpd',
'mod_ssl',
'mod_wsgi'
] %}
{{ macros.install_packages(zaqar_packages | customizable("packages")) }}
RUN sed -i -r 's,^(Listen 80),#\1,' /etc/httpd/conf/httpd.conf \
&& sed -i -r 's,^(Listen 443),#\1,' /etc/httpd/conf.d/ssl.conf
{% elif base_distro in ['debian', 'ubuntu'] %}
{% set zaqar_packages = [
'apache2',
'libapache2-mod-wsgi'
] %}
{{ macros.install_packages(zaqar_packages | customizable("packages")) }}
RUN echo > /etc/apache2/ports.conf
{% endif %}
ADD zaqar-archive /zaqar-source
{% set zaqar_pip_packages = [
'pymongo',
'/zaqar'
] %}
RUN ln -s zaqar-source/* zaqar \
&& {{ macros.install_pip(zaqar_pip_packages | customizable("pip_packages")) }} \
&& mkdir -p /etc/zaqar \
&& cp -r /zaqar/etc/* /etc/zaqar/ \
&& chown -R zaqar: /etc/zaqar
{% endif %}
COPY extend_start.sh /usr/local/bin/kolla_extend_start
RUN chmod 755 /usr/local/bin/kolla_extend_start
{% block zaqar_footer %}{% endblock %}
{% block footer %}{% endblock %}
USER zaqar

View File

@ -0,0 +1,90 @@
FROM {{ namespace }}/{{ image_prefix }}openstack-base:{{ tag }}
LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"
{% block zaqar_base_header %}{% endblock %}
{% import "macros.j2" as macros with context %}
{{ macros.configure_user(name='zaqar') }}
{% if install_type == 'binary' %}
{% if base_distro in ['centos', 'oraclelinux', 'rhel'] %}
{% set zaqar_base_packages = [
'openstack-zaqar',
'httpd',
'mod_ssl',
'mod_wsgi',
'python2-ldappool'
] %}
{{ macros.install_packages(zaqar_base_packages | customizable("packages")) }} \
&& mkdir -p /var/www/cgi-bin/zaqar \
&& chown -R zaqar: /var/www/cgi-bin/zaqar \
&& cp -a /usr/lib/python2.7/site-packages/zaqar/transport/wsgi/app.py /var/www/cgi-bin/zaqar/ \
&& sed -i -r 's,^(Listen 80),#\1,' /etc/httpd/conf/httpd.conf \
&& sed -i -r 's,^(Listen 443),#\1,' /etc/httpd/conf.d/ssl.conf
{% elif base_distro in ['debian', 'ubuntu'] %}
{% set zaqar_base_packages = [
'zaqar-common',
'apache2',
'libapache2-mod-wsgi',
'python-ldappool'
] %}
{{ macros.install_packages(zaqar_base_packages | customizable("packages")) }} \
&& mkdir -p /var/www/cgi-bin/zaqar \
&& chown -R zaqar: /var/www/cgi-bin/zaqar \
&& cp -a /usr/lib/python2.7/dist-packages/zaqar/transport/wsgi/app.py /var/www/cgi-bin/zaqar/ \
&& echo > /etc/apache2/ports.conf
{% endif %}
{% elif install_type == 'source' %}
{% if base_distro in ['centos', 'oraclelinux', 'rhel'] %}
{% set zaqar_base_packages = [
'httpd',
'mod_ssl',
'mod_wsgi',
'python2-ldappool'
] %}
{{ macros.install_packages(zaqar_base_packages | customizable("packages")) }} \
&& sed -i -r 's,^(Listen 80),#\1,' /etc/httpd/conf/httpd.conf \
&& sed -i -r 's,^(Listen 443),#\1,' /etc/httpd/conf.d/ssl.conf
{% elif base_distro in ['debian', 'ubuntu'] %}
{% set zaqar_base_packages = [
'apache2',
'libapache2-mod-wsgi',
'python-ldappool'
] %}
{{ macros.install_packages(zaqar_base_packages | customizable("packages")) }} \
&& echo > /etc/apache2/ports.conf
{% endif %}
{% set zaqar_base_pip_packages = [
'pymongo',
'/zaqar',
'gevent'
] %}
ADD zaqar-base-archive /zaqar-base-source
RUN ln -s zaqar-base-source/* zaqar \
&& {{ macros.install_pip(zaqar_base_pip_packages | customizable("pip_packages")) }} \
&& mkdir -p /etc/zaqar /var/lib/zaqar /var/www/cgi-bin/zaqar \
&& cp -r /zaqar/etc/* /etc/zaqar/ \
&& cp /zaqar/zaqar/transport/wsgi/app.py /var/www/cgi-bin/zaqar \
&& chown -R zaqar: /etc/zaqar /var/lib/zaqar /var/www/cgi-bin/zaqar
{% endif %}
COPY extend_start.sh /usr/local/bin/kolla_extend_start
RUN touch /usr/local/bin/kolla_zaqar_extend_start \
&& chmod 755 /var/www/cgi-bin/zaqar \
&& chmod 755 /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_zaqar_extend_start
{% block zaqar_base_footer %}{% endblock %}

View File

@ -0,0 +1,15 @@
#!/bin/bash
# Create log dir for Zaqar logs
LOG_DIR="/var/log/kolla/zaqar"
if [[ ! -d "${LOG_DIR}" ]]; then
mkdir -p ${LOG_DIR}
fi
if [[ $(stat -c %U:%G ${LOG_DIR}) != "zaqar:kolla" ]]; then
chown zaqar:kolla ${LOG_DIR}
fi
if [[ $(stat -c %a ${LOG_DIR}) != "755" ]]; then
chmod 755 ${LOG_DIR}
fi
. /usr/local/bin/kolla_zaqar_extend_start

View File

@ -0,0 +1,18 @@
FROM {{ namespace }}/{{ image_prefix }}zaqar-base:{{ tag }}
LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"
{% block zaqar_server_header %}{% endblock %}
{% import "macros.j2" as macros with context %}
{% if install_type == 'binary' %}
{% if base_distro in ['debian', 'ubuntu'] %}
{% set zaqar_server_packages = ['zaqar-server'] %}
{{ macros.install_packages(zaqar_server_packages | customizable("packages")) }}
{% endif %}
{% endif %}
{% block zaqar_server_footer %}{% endblock %}
{% block footer %}{% endblock %}

View File

@ -0,0 +1,12 @@
FROM {{ namespace }}/{{ image_prefix }}zaqar-base:{{ tag }}
LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"
{% block zaqar_wsgi_header %}{% endblock %}
{% import "macros.j2" as macros with context %}
COPY extend_start.sh /usr/local/bin/kolla_zaqar_extend_start
RUN chmod 755 /usr/local/bin/kolla_zaqar_extend_start
{% block zaqar_wsgi_footer %}{% endblock %}
{% block footer %}{% endblock %}

View File

@ -1,12 +1,5 @@
#!/bin/bash
if [[ ! -d "/var/log/kolla/zaqar" ]]; then
mkdir -p /var/log/kolla/zaqar
fi
if [[ $(stat -c %a /var/log/kolla/zaqar) != "755" ]]; then
chmod 755 /var/log/kolla/zaqar
fi
# Assume the service runs on top of Apache when user is root
if [[ "$(whoami)" == 'root' ]]; then
# NOTE(pbourke): httpd will not clean up after itself in some cases which

View File

@ -805,7 +805,7 @@ SOURCES = {
'type': 'url',
'location': ('$tarballs_base/watcher/'
'watcher-master.tar.gz')},
'zaqar': {
'zaqar-base': {
'type': 'url',
'location': ('$tarballs_base/zaqar/'
'zaqar-master.tar.gz')},

View File

@ -0,0 +1,5 @@
---
upgrade:
- |
Update a single zaqar image to zaqar-server and zaqar-wsgi
images.