Skip to content

Commit

Permalink
Cleanup ARS httpd config
Browse files Browse the repository at this point in the history
  • Loading branch information
mnecas committed Apr 14, 2022
1 parent fd94179 commit 478a053
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packaging/setup/ovirt_engine_setup/engine/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ class FileLocations(object):
'www',
)

HTTPD_RUNNER_WSGI_SCRIPT = os.path.join(
DIR_WWW,
'runnner',
'runner.wsgi',
HTTPD_CONF_ANSIBLE_RUNNER_SERVICE = os.path.join(
DIR_HTTPD,
'conf.d',
'zz-ansible-runner-service.conf',
)

HTTPD_CONF_OVIRT_ENGINE = os.path.join(
Expand Down Expand Up @@ -345,8 +345,6 @@ class Defaults(object):

DEFAULT_CLEAR_TASKS_WAIT_PERIOD = 20

DEFAULT_ANSIBLE_RUNNER_SERVICE_PORT = '50001'

DEFAULT_DB_HOST = 'localhost'
DEFAULT_DB_PORT = 5432
DEFAULT_DB_DATABASE = 'engine'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@

from . import engine
from . import root
from . import runner


@util.export
def createPlugins(context):
engine.Plugin(context=context)
root.Plugin(context=context)
runner.Plugin(context=context)


# vim: expandtab tabstop=4 shiftwidth=4
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#
# ovirt-engine-setup -- ovirt engine setup
#
# Copyright oVirt Authors
# SPDX-License-Identifier: Apache-2.0
#
#


"""Apache ansible-runner plugin."""


import gettext
import os
import textwrap

from otopi import constants as otopicons
from otopi import filetransaction
from otopi import plugin
from otopi import util

from ovirt_engine_setup import constants as osetupcons
from ovirt_engine_setup.engine import constants as oenginecons
from ovirt_engine_setup.engine_common import constants as oengcommcons
from ovirt_engine_setup.transactions import RemoveFileTransaction


def _(m):
return gettext.dgettext(message=m, domain='ovirt-engine-setup')


@util.export
class Plugin(plugin.PluginBase):
"""Cleanup of the ansible-runner plugin."""

def __init__(self, context):
super(Plugin, self).__init__(context=context)

@plugin.event(
stage=plugin.Stages.STAGE_MISC,
condition=lambda self: self.environment[
oenginecons.CoreEnv.ENABLE
] and not self.environment[
osetupcons.CoreEnv.DEVELOPER_MODE
] and os.path.exists(oenginecons.FileLocations.HTTPD_CONF_ANSIBLE_RUNNER_SERVICE),
)
def _misc(self):
if not self._can_remove(oenginecons.FileLocations.HTTPD_CONF_ANSIBLE_RUNNER_SERVICE):
return

self.environment[oengcommcons.ApacheEnv.NEED_RESTART] = True

self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
RemoveFileTransaction(oenginecons.FileLocations.HTTPD_CONF_ANSIBLE_RUNNER_SERVICE)
)

def _can_remove(self, installed_file):
"""
Return True if installed_file can be removed safely. Return False if
the file was not installed by previous setup, or was changed.
"""
uninstall_info = self.environment[
osetupcons.CoreEnv.UNINSTALL_FILES_INFO
].get(installed_file)

# Did we install this file?
if not uninstall_info:
return False

# Did it change since we installed it?
if uninstall_info.get("changed"):
self.logger.warn(
_(
"Cannot remove {}, file was changed"
).format(installed_file)
)
return False

return True


# vim: expandtab tabstop=4 shiftwidth=4

0 comments on commit 478a053

Please sign in to comment.