|
|
@ -10,12 +10,21 @@ from ....config import (
|
|
|
|
|
|
|
|
|
|
|
|
from ....docker_util import (
|
|
|
|
from ....docker_util import (
|
|
|
|
docker_cp_to,
|
|
|
|
docker_cp_to,
|
|
|
|
|
|
|
|
docker_exec,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
from ....containers import (
|
|
|
|
from ....containers import (
|
|
|
|
run_support_container,
|
|
|
|
run_support_container,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from ....encoding import (
|
|
|
|
|
|
|
|
to_text,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from ....util import (
|
|
|
|
|
|
|
|
display,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
from . import (
|
|
|
|
from . import (
|
|
|
|
CloudEnvironment,
|
|
|
|
CloudEnvironment,
|
|
|
|
CloudEnvironmentConfig,
|
|
|
|
CloudEnvironmentConfig,
|
|
|
@ -23,53 +32,59 @@ from . import (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# We add BasicAuthentication, to make the tasks that deal with
|
|
|
|
GALAXY_HOST_NAME = 'galaxy-pulp'
|
|
|
|
# direct API access easier to deal with across galaxy_ng and pulp
|
|
|
|
SETTINGS = {
|
|
|
|
SETTINGS = '''
|
|
|
|
'PULP_CONTENT_ORIGIN': f'http://{GALAXY_HOST_NAME}',
|
|
|
|
CONTENT_ORIGIN = 'http://{host}:80'
|
|
|
|
'PULP_ANSIBLE_API_HOSTNAME': f'http://{GALAXY_HOST_NAME}',
|
|
|
|
ANSIBLE_API_HOSTNAME = 'http://{host}:80'
|
|
|
|
'PULP_GALAXY_API_PATH_PREFIX': '/api/galaxy/',
|
|
|
|
ANSIBLE_CONTENT_HOSTNAME = 'http://{host}:80/pulp/content'
|
|
|
|
# These paths are unique to the container image which has an nginx location for /pulp/content to route
|
|
|
|
TOKEN_AUTH_DISABLED = True
|
|
|
|
# requests to the content backend
|
|
|
|
GALAXY_REQUIRE_CONTENT_APPROVAL = False
|
|
|
|
'PULP_ANSIBLE_CONTENT_HOSTNAME': f'http://{GALAXY_HOST_NAME}/pulp/content/api/galaxy/v3/artifacts/collections/',
|
|
|
|
GALAXY_AUTHENTICATION_CLASSES = [
|
|
|
|
'PULP_CONTENT_PATH_PREFIX': '/pulp/content/api/galaxy/v3/artifacts/collections/',
|
|
|
|
"rest_framework.authentication.SessionAuthentication",
|
|
|
|
'PULP_GALAXY_AUTHENTICATION_CLASSES': [
|
|
|
|
"rest_framework.authentication.TokenAuthentication",
|
|
|
|
'rest_framework.authentication.SessionAuthentication',
|
|
|
|
"rest_framework.authentication.BasicAuthentication",
|
|
|
|
'rest_framework.authentication.TokenAuthentication',
|
|
|
|
]
|
|
|
|
'rest_framework.authentication.BasicAuthentication',
|
|
|
|
'''
|
|
|
|
'django.contrib.auth.backends.ModelBackend',
|
|
|
|
|
|
|
|
],
|
|
|
|
SET_ADMIN_PASSWORD = b'''#!/usr/bin/execlineb -S0
|
|
|
|
# This should probably be false see https://issues.redhat.com/browse/AAH-2328
|
|
|
|
foreground {
|
|
|
|
'PULP_GALAXY_REQUIRE_CONTENT_APPROVAL': 'true',
|
|
|
|
redirfd -w 1 /dev/null
|
|
|
|
'PULP_GALAXY_DEPLOYMENT_MODE': 'standalone',
|
|
|
|
redirfd -w 2 /dev/null
|
|
|
|
'PULP_GALAXY_AUTO_SIGN_COLLECTIONS': 'false',
|
|
|
|
export DJANGO_SETTINGS_MODULE pulpcore.app.settings
|
|
|
|
'PULP_GALAXY_COLLECTION_SIGNING_SERVICE': 'ansible-default',
|
|
|
|
export PULP_CONTENT_ORIGIN localhost
|
|
|
|
'PULP_RH_ENTITLEMENT_REQUIRED': 'insights',
|
|
|
|
s6-setuidgid postgres
|
|
|
|
'PULP_TOKEN_AUTH_DISABLED': 'false',
|
|
|
|
if { /usr/local/bin/django-admin reset-admin-password --password password }
|
|
|
|
'PULP_TOKEN_SERVER': f'http://{GALAXY_HOST_NAME}/token/',
|
|
|
|
if { /usr/local/bin/pulpcore-manager create-group system:partner-engineers --users admin }
|
|
|
|
'PULP_TOKEN_SIGNATURE_ALGORITHM': 'ES256',
|
|
|
|
}
|
|
|
|
'PULP_PUBLIC_KEY_PATH': '/src/galaxy_ng/dev/common/container_auth_public_key.pem',
|
|
|
|
'''
|
|
|
|
'PULP_PRIVATE_KEY_PATH': '/src/galaxy_ng/dev/common/container_auth_private_key.pem',
|
|
|
|
|
|
|
|
'PULP_ANALYTICS': 'false',
|
|
|
|
# There are 2 overrides here:
|
|
|
|
'PULP_GALAXY_ENABLE_UNAUTHENTICATED_COLLECTION_ACCESS': 'true',
|
|
|
|
# 1. Change the gunicorn bind address from 127.0.0.1 to 0.0.0.0 now that Galaxy NG does not allow us to access the
|
|
|
|
'PULP_GALAXY_ENABLE_UNAUTHENTICATED_COLLECTION_DOWNLOAD': 'true',
|
|
|
|
# Pulp API through it.
|
|
|
|
'PULP_GALAXY_ENABLE_LEGACY_ROLES': 'true',
|
|
|
|
# 2. Grant access allowing us to DELETE a namespace in Galaxy NG. This is as CI deletes and recreates repos and
|
|
|
|
'PULP_GALAXY_FEATURE_FLAGS__execution_environments': 'false',
|
|
|
|
# distributions in Pulp which now breaks the namespace in Galaxy NG. Recreating it is the "simple" fix to get it
|
|
|
|
'PULP_SOCIAL_AUTH_LOGIN_REDIRECT_URL': '/',
|
|
|
|
# working again.
|
|
|
|
'PULP_GALAXY_FEATURE_FLAGS__ai_deny_index': 'true',
|
|
|
|
# These may not be needed in the future, especially if 1 becomes configurable by an env var but for now they must be
|
|
|
|
'PULP_DEFAULT_ADMIN_PASSWORD': 'password'
|
|
|
|
# done.
|
|
|
|
|
|
|
|
OVERRIDES = b'''#!/usr/bin/execlineb -S0
|
|
|
|
|
|
|
|
foreground {
|
|
|
|
|
|
|
|
sed -i "0,/\\"127.0.0.1:24817\\"/s//\\"0.0.0.0:24817\\"/" /etc/services.d/pulpcore-api/run
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# This sed calls changes the first occurrence to "allow" which is conveniently the delete operation for a namespace.
|
|
|
|
|
|
|
|
# https://github.com/ansible/galaxy_ng/blob/master/galaxy_ng/app/access_control/statements/standalone.py#L9-L11.
|
|
|
|
GALAXY_IMPORTER = b'''
|
|
|
|
backtick NG_PREFIX { python -c "import galaxy_ng; print(galaxy_ng.__path__[0], end='')" }
|
|
|
|
[galaxy-importer]
|
|
|
|
importas ng_prefix NG_PREFIX
|
|
|
|
ansible_local_tmp=~/.ansible/tmp
|
|
|
|
foreground {
|
|
|
|
ansible_test_local_image=false
|
|
|
|
sed -i "0,/\\"effect\\": \\"deny\\"/s//\\"effect\\": \\"allow\\"/" ${ng_prefix}/app/access_control/statements/standalone.py
|
|
|
|
check_required_tags=false
|
|
|
|
}'''
|
|
|
|
check_runtime_yaml=false
|
|
|
|
|
|
|
|
check_changelog=false
|
|
|
|
|
|
|
|
infra_osd=false
|
|
|
|
|
|
|
|
local_image_docker=false
|
|
|
|
|
|
|
|
log_level_main=INFO
|
|
|
|
|
|
|
|
require_v1_or_greater=false
|
|
|
|
|
|
|
|
run_ansible_doc=false
|
|
|
|
|
|
|
|
run_ansible_lint=false
|
|
|
|
|
|
|
|
run_ansible_test=false
|
|
|
|
|
|
|
|
run_flake8=false
|
|
|
|
|
|
|
|
'''.strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GalaxyProvider(CloudProvider):
|
|
|
|
class GalaxyProvider(CloudProvider):
|
|
|
@ -81,13 +96,9 @@ class GalaxyProvider(CloudProvider):
|
|
|
|
def __init__(self, args: IntegrationConfig) -> None:
|
|
|
|
def __init__(self, args: IntegrationConfig) -> None:
|
|
|
|
super().__init__(args)
|
|
|
|
super().__init__(args)
|
|
|
|
|
|
|
|
|
|
|
|
# Cannot use the latest container image as either galaxy_ng 4.2.0rc2 or pulp 0.5.0 has sporatic issues with
|
|
|
|
self.image = os.environ.get(
|
|
|
|
# dropping published collections in CI. Try running the tests multiple times when updating. Will also need to
|
|
|
|
|
|
|
|
# comment out the cache tests in 'test/integration/targets/ansible-galaxy-collection/tasks/install.yml' when
|
|
|
|
|
|
|
|
# the newer update is available.
|
|
|
|
|
|
|
|
self.pulp = os.environ.get(
|
|
|
|
|
|
|
|
'ANSIBLE_PULP_CONTAINER',
|
|
|
|
'ANSIBLE_PULP_CONTAINER',
|
|
|
|
'quay.io/ansible/pulp-galaxy-ng:b79a7be64eff'
|
|
|
|
'quay.io/pulp/galaxy:4.7.1'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
self.uses_docker = True
|
|
|
|
self.uses_docker = True
|
|
|
@ -96,46 +107,45 @@ class GalaxyProvider(CloudProvider):
|
|
|
|
"""Setup cloud resource before delegation and reg cleanup callback."""
|
|
|
|
"""Setup cloud resource before delegation and reg cleanup callback."""
|
|
|
|
super().setup()
|
|
|
|
super().setup()
|
|
|
|
|
|
|
|
|
|
|
|
galaxy_port = 80
|
|
|
|
with tempfile.NamedTemporaryFile(mode='w+') as env_fd:
|
|
|
|
pulp_port = 24817
|
|
|
|
settings = '\n'.join(
|
|
|
|
|
|
|
|
f'{key}={value}' for key, value in SETTINGS.items()
|
|
|
|
ports = [
|
|
|
|
)
|
|
|
|
galaxy_port,
|
|
|
|
env_fd.write(settings)
|
|
|
|
pulp_port,
|
|
|
|
env_fd.flush()
|
|
|
|
]
|
|
|
|
display.info(f'>>> galaxy_ng Configuration\n{settings}', verbosity=3)
|
|
|
|
|
|
|
|
|
|
|
|
# Create the container, don't run it, we need to inject configs before it starts
|
|
|
|
|
|
|
|
descriptor = run_support_container(
|
|
|
|
descriptor = run_support_container(
|
|
|
|
self.args,
|
|
|
|
self.args,
|
|
|
|
self.platform,
|
|
|
|
self.platform,
|
|
|
|
self.pulp,
|
|
|
|
self.image,
|
|
|
|
'galaxy-pulp',
|
|
|
|
GALAXY_HOST_NAME,
|
|
|
|
ports,
|
|
|
|
[
|
|
|
|
start=False,
|
|
|
|
80,
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
aliases=[
|
|
|
|
|
|
|
|
GALAXY_HOST_NAME,
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
start=True,
|
|
|
|
|
|
|
|
options=[
|
|
|
|
|
|
|
|
'--env-file', env_fd.name,
|
|
|
|
|
|
|
|
],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if not descriptor:
|
|
|
|
if not descriptor:
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
pulp_id = descriptor.container_id
|
|
|
|
injected_files = [
|
|
|
|
|
|
|
|
('/etc/galaxy-importer/galaxy-importer.cfg', GALAXY_IMPORTER, 'galaxy-importer'),
|
|
|
|
injected_files = {
|
|
|
|
]
|
|
|
|
'/etc/pulp/settings.py': SETTINGS.format(host=descriptor.name).encode(),
|
|
|
|
for path, content, friendly_name in injected_files:
|
|
|
|
'/etc/cont-init.d/111-postgres': SET_ADMIN_PASSWORD,
|
|
|
|
|
|
|
|
'/etc/cont-init.d/000-ansible-test-overrides': OVERRIDES,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for path, content in injected_files.items():
|
|
|
|
|
|
|
|
with tempfile.NamedTemporaryFile() as temp_fd:
|
|
|
|
with tempfile.NamedTemporaryFile() as temp_fd:
|
|
|
|
temp_fd.write(content)
|
|
|
|
temp_fd.write(content)
|
|
|
|
temp_fd.flush()
|
|
|
|
temp_fd.flush()
|
|
|
|
docker_cp_to(self.args, pulp_id, temp_fd.name, path)
|
|
|
|
display.info(f'>>> {friendly_name} Configuration\n{to_text(content)}', verbosity=3)
|
|
|
|
|
|
|
|
docker_exec(self.args, descriptor.container_id, ['mkdir', '-p', os.path.dirname(path)], True)
|
|
|
|
descriptor.start(self.args)
|
|
|
|
docker_cp_to(self.args, descriptor.container_id, temp_fd.name, path)
|
|
|
|
|
|
|
|
|
|
|
|
self._set_cloud_config('PULP_HOST', descriptor.name)
|
|
|
|
self._set_cloud_config('PULP_HOST', GALAXY_HOST_NAME)
|
|
|
|
self._set_cloud_config('PULP_PORT', str(pulp_port))
|
|
|
|
|
|
|
|
self._set_cloud_config('GALAXY_PORT', str(galaxy_port))
|
|
|
|
|
|
|
|
self._set_cloud_config('PULP_USER', 'admin')
|
|
|
|
self._set_cloud_config('PULP_USER', 'admin')
|
|
|
|
self._set_cloud_config('PULP_PASSWORD', 'password')
|
|
|
|
self._set_cloud_config('PULP_PASSWORD', 'password')
|
|
|
|
|
|
|
|
|
|
|
@ -148,21 +158,19 @@ class GalaxyEnvironment(CloudEnvironment):
|
|
|
|
pulp_user = str(self._get_cloud_config('PULP_USER'))
|
|
|
|
pulp_user = str(self._get_cloud_config('PULP_USER'))
|
|
|
|
pulp_password = str(self._get_cloud_config('PULP_PASSWORD'))
|
|
|
|
pulp_password = str(self._get_cloud_config('PULP_PASSWORD'))
|
|
|
|
pulp_host = self._get_cloud_config('PULP_HOST')
|
|
|
|
pulp_host = self._get_cloud_config('PULP_HOST')
|
|
|
|
galaxy_port = self._get_cloud_config('GALAXY_PORT')
|
|
|
|
|
|
|
|
pulp_port = self._get_cloud_config('PULP_PORT')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return CloudEnvironmentConfig(
|
|
|
|
return CloudEnvironmentConfig(
|
|
|
|
ansible_vars=dict(
|
|
|
|
ansible_vars=dict(
|
|
|
|
pulp_user=pulp_user,
|
|
|
|
pulp_user=pulp_user,
|
|
|
|
pulp_password=pulp_password,
|
|
|
|
pulp_password=pulp_password,
|
|
|
|
pulp_api='http://%s:%s' % (pulp_host, pulp_port),
|
|
|
|
pulp_api=f'http://{pulp_host}',
|
|
|
|
pulp_server='http://%s:%s/pulp_ansible/galaxy/' % (pulp_host, pulp_port),
|
|
|
|
pulp_server=f'http://{pulp_host}/pulp_ansible/galaxy/',
|
|
|
|
galaxy_ng_server='http://%s:%s/api/galaxy/' % (pulp_host, galaxy_port),
|
|
|
|
galaxy_ng_server=f'http://{pulp_host}/api/galaxy/',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
env_vars=dict(
|
|
|
|
env_vars=dict(
|
|
|
|
PULP_USER=pulp_user,
|
|
|
|
PULP_USER=pulp_user,
|
|
|
|
PULP_PASSWORD=pulp_password,
|
|
|
|
PULP_PASSWORD=pulp_password,
|
|
|
|
PULP_SERVER='http://%s:%s/pulp_ansible/galaxy/api/' % (pulp_host, pulp_port),
|
|
|
|
PULP_SERVER=f'http://{pulp_host}/pulp_ansible/galaxy/api/',
|
|
|
|
GALAXY_NG_SERVER='http://%s:%s/api/galaxy/' % (pulp_host, galaxy_port),
|
|
|
|
GALAXY_NG_SERVER=f'http://{pulp_host}/api/galaxy/',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|