summaryrefslogtreecommitdiffstats
path: root/tools/docker-compose-minikube/minikube/templates/bootstrap_minikube.py.j2
diff options
context:
space:
mode:
Diffstat (limited to 'tools/docker-compose-minikube/minikube/templates/bootstrap_minikube.py.j2')
-rw-r--r--tools/docker-compose-minikube/minikube/templates/bootstrap_minikube.py.j242
1 files changed, 42 insertions, 0 deletions
diff --git a/tools/docker-compose-minikube/minikube/templates/bootstrap_minikube.py.j2 b/tools/docker-compose-minikube/minikube/templates/bootstrap_minikube.py.j2
new file mode 100644
index 0000000000..861ba5e23a
--- /dev/null
+++ b/tools/docker-compose-minikube/minikube/templates/bootstrap_minikube.py.j2
@@ -0,0 +1,42 @@
+# Create Openshift/Kubernetes credential for Minikube
+# This script gets called by the bootstrap_development process
+# awx-manage shell_plus --quiet < bootstrap_minikube.py
+
+from awx.main.utils.encryption import encrypt_field
+
+NAME = 'Minikube'
+
+POD_SPEC = """apiVersion: v1
+kind: Pod
+metadata:
+ namespace: {{ minikube_service_account_namespace }}
+spec:
+ containers:
+ - image: 'quay.io/ansible/awx-ee:devel'
+ name: worker
+ args:
+ - ansible-runner
+ - worker
+ - '--private-data-dir=/runner'"""
+
+# Creates Minikube credential
+if not Credential.objects.filter(name=NAME).count():
+ cred = Credential()
+ cred.name = NAME
+ cred.credential_type = CredentialType.objects.get(name='OpenShift or Kubernetes API Bearer Token')
+ cred.description = 'Minikube Devel'
+ cred.inputs['host'] = 'https://minikube:8443'
+ cred.inputs['verify_ssl'] = False
+ cred.inputs['bearer_token'] = '{{ service_account_token }}'
+ encrypt_field(cred, 'bearer_token', secret_key=settings.SECRET_KEY)
+ cred.save()
+
+# Create Container Group for Minikube
+if not InstanceGroup.objects.filter(name=NAME).count():
+ ccgrp = InstanceGroup()
+ ccgrp.name = NAME
+ ccgrp.credential = cred
+ ccgrp.pod_spec_override = POD_SPEC
+ ccgrp.is_container_group = True
+ ccgrp.save()
+