Break out control plane EE as its own thing

This commit is contained in:
Elijah DeLee
2021-06-07 15:39:20 -04:00
parent 7832639c25
commit 2ce276455a
2 changed files with 31 additions and 16 deletions

View File

@@ -51,7 +51,7 @@ class Command(BaseCommand):
)
def handle(self, *args, **options):
changed = False
changed = []
registry_cred = None
if options.get("registry_username"):
@@ -68,12 +68,12 @@ class Command(BaseCommand):
sys.stderr.write("No registry credential type found")
sys.exit(1)
registry_cred, created = Credential.objects.get_or_create(
registry_cred, cred_created = Credential.objects.get_or_create(
name="Default Execution Environment Registry Credential", managed_by_tower=True, credential_type=registry_cred_type[0]
)
if created:
print("Default Execution Environment Credential registered.")
if cred_created:
print("'Default Execution Environment Credential' registered.")
inputs = {
"host": options.get("registry_url"),
@@ -84,21 +84,28 @@ class Command(BaseCommand):
registry_cred.inputs = inputs
registry_cred.save()
changed = True
changed.append(True)
if not created:
print('Updated Default Execution Environment Credential')
if not cred_created:
print("Updated 'Default Execution Environment Credential'")
for ee in reversed(settings.DEFAULT_EXECUTION_ENVIRONMENTS):
_, created = ExecutionEnvironment.objects.update_or_create(
name=ee["name"], defaults={"image": ee["image"], "managed_by_tower": True, "credential": registry_cred}
)
# Create default globally available Execution Environments
for ee in reversed(settings.GLOBAL_JOB_EXECUTION_ENVIRONMENTS):
_, ee_created = ExecutionEnvironment.objects.update_or_create(name=ee["name"], image=ee["image"], credential=registry_cred)
if ee_created:
changed.append(True)
print(f"'{ee['name']}' Default Execution Environment registered.")
if created:
changed = True
print("Default Execution Environment(s) registered.")
# Create the control plane execution environment that is used for project updates and system jobs
control_plane_ee = settings.CONTROL_PLANE_EXECUTION_ENVIRONMENT
_cp_ee, cp_created = ExecutionEnvironment.objects.update_or_create(
name="Control Plane Execution Environment", defaults={'image': control_plane_ee, 'managed_by_tower': True, 'credential': registry_cred}
)
if cp_created:
changed.append(True)
print("Control Plane Execution Environment registered.")
if changed:
if any(changed):
print("(changed: True)")
else:
print("(changed: False)")

View File

@@ -180,7 +180,15 @@ DEFAULT_EXECUTION_ENVIRONMENT = None
# This list is used for creating default EEs when running awx-manage create_preload_data.
# Should be ordered from highest to lowest precedence.
DEFAULT_EXECUTION_ENVIRONMENTS = [{'name': 'AWX EE 0.2.0', 'image': 'quay.io/ansible/awx-ee:0.2.0'}]
# The awx-manage register_default_execution_environments command reads this setting and registers the EE(s)
# If a registry credential is needed to pull the image, that can be provided to the awx-manage command
GLOBAL_JOB_EXECUTION_ENVIRONMENTS = [{'name': 'AWX EE 0.3.0', 'image': 'quay.io/ansible/awx-ee:0.3.0'}]
# This setting controls which EE will be used for project updates.
# The awx-manage register_default_execution_environments command reads this setting and registers the EE
# This image is distinguished from others by having "managed_by_tower" set to True and users have limited
# ability to modify it through the API.
# If a registry credential is needed to pull the image, that can be provided to the awx-manage command
CONTROL_PLANE_EXECUTION_ENVIRONMENT = 'quay.io/ansible/awx-ee:0.3.0'
# Note: This setting may be overridden by database settings.
STDOUT_MAX_BYTES_DISPLAY = 1048576