diff --git a/awx/main/management/commands/provision_instance.py b/awx/main/management/commands/provision_instance.py index c3c8f188ab..c5c5ba3e1d 100644 --- a/awx/main/management/commands/provision_instance.py +++ b/awx/main/management/commands/provision_instance.py @@ -1,7 +1,7 @@ # Copyright (c) 2015 Ansible, Inc. # All Rights Reserved -from django.core.management.base import BaseCommand, CommandError +from django.core.management.base import BaseCommand from django.db import transaction from awx.main.models import Instance @@ -22,8 +22,9 @@ class Command(BaseCommand): def _register_hostname(self, hostname, node_type, uuid): if not hostname: - return - (changed, instance) = Instance.objects.register(hostname=hostname, node_type=node_type, uuid=uuid) + (changed, instance) = Instance.objects.get_or_register() + else: + (changed, instance) = Instance.objects.register(hostname=hostname, node_type=node_type, uuid=uuid) if changed: print("Successfully registered instance {}".format(hostname)) else: @@ -32,8 +33,6 @@ class Command(BaseCommand): @transaction.atomic def handle(self, **options): - if not options.get('hostname'): - raise CommandError("Specify `--hostname` to use this command.") self.changed = False self._register_hostname(options.get('hostname'), options.get('node_type'), options.get('uuid')) if self.changed: diff --git a/awx/main/tasks/system.py b/awx/main/tasks/system.py index 008c3bcb2f..3f713dde3c 100644 --- a/awx/main/tasks/system.py +++ b/awx/main/tasks/system.py @@ -612,10 +612,6 @@ def cluster_node_heartbeat(): if inst.hostname == settings.CLUSTER_HOST_ID: this_inst = inst break - else: - (changed, this_inst) = Instance.objects.get_or_register() - if changed: - logger.info("Registered tower control node '{}'".format(this_inst.hostname)) inspect_execution_nodes(instance_list) diff --git a/tools/ansible/roles/dockerfile/files/launch_awx_task.sh b/tools/ansible/roles/dockerfile/files/launch_awx_task.sh index ae1a87a6b0..f0af27cda7 100755 --- a/tools/ansible/roles/dockerfile/files/launch_awx_task.sh +++ b/tools/ansible/roles/dockerfile/files/launch_awx_task.sh @@ -17,4 +17,6 @@ set -e wait-for-migrations +awx-manage provision_instance + supervisord -c /etc/supervisord_task.conf