diff --git a/config/crd/bases/awx.ansible.com_awxmeshingresses.yaml b/config/crd/bases/awx.ansible.com_awxmeshingresses.yaml index 4ed7eddd..fcdb22ba 100644 --- a/config/crd/bases/awx.ansible.com_awxmeshingresses.yaml +++ b/config/crd/bases/awx.ansible.com_awxmeshingresses.yaml @@ -41,6 +41,12 @@ spec: deployment_name: description: Name of the AWX deployment to create the Mesh Ingress for. type: string + external_hostname: + description: External hostname to use for the Mesh Ingress. + type: string + external_ipaddress: + description: External IP address to use for the Mesh Ingress. + type: string status: description: Status defines the observed state of AWXMeshIngress type: object diff --git a/roles/mesh_ingress/tasks/main.yml b/roles/mesh_ingress/tasks/main.yml index 5310c551..43b3e532 100644 --- a/roles/mesh_ingress/tasks/main.yml +++ b/roles/mesh_ingress/tasks/main.yml @@ -1,4 +1,12 @@ --- +- name: Import common role + import_role: + name: common + +- name: Debug is_openshift + debug: + msg: "is_openshift={{ is_openshift }}" + - name: Check for presence of AWX instance that we will use to create the Mesh Ingress for. k8s_info: api_version: awx.ansible.com/v1beta1 @@ -37,12 +45,14 @@ wait: yes wait_timeout: "120" register: route + when: is_openshift | bool # TODO: need to wait until the route is ready before we can get the hostname - name: Set external_hostname set_fact: external_hostname: "{{ route.result.status.ingress[0].host }}" + when: is_openshift | bool - name: Create other resources k8s: @@ -81,12 +91,27 @@ set_fact: awx_task_pod_name: "{{ awx_task_pod['metadata']['name'] | default('') }}" -## TODO: awx-manage provision_instance does not currently support peer from control nodes -## !!!dependent on API/CLI changes!!! -# - name: Add new instance to AWX -# k8s_exec: -# namespace: "{{ ansible_operator_meta.namespace }}" -# pod: "{{ awx_task_pod_name }}" -# container: "{{ deployment_name }}-task" -# command: awx-manage provision_instance ... -# register: result +# TODO: awx-manage provision_instance does not currently support peer from control nodes +# !!!dependent on API/CLI changes!!! +- name: Add new instance to AWX + kubernetes.core.k8s_exec: + namespace: "{{ ansible_operator_meta.namespace }}" + pod: "{{ awx_task_pod_name }}" + container: "{{ deployment_name }}-task" + command: "awx-manage provision_instance --hostname {{ ansible_operator_meta.name }} --node_type hop --listener_port 6667 --peers_from_control_nodes" + register: result + +- name: Add internal receptor address + kubernetes.core.k8s_exec: + namespace: "{{ ansible_operator_meta.namespace }}" + pod: "{{ awx_task_pod_name }}" + container: "{{ deployment_name }}-task" + command: "awx-manage add_receptor_address --hostname {{ ansible_operator_meta.name }} --address {{ ansible_operator_meta.name }} --port 27199 --protocol ws --is_internal" + + +- name: Add external receptor address + kubernetes.core.k8s_exec: + namespace: "{{ ansible_operator_meta.namespace }}" + pod: "{{ awx_task_pod_name }}" + container: "{{ deployment_name }}-task" + command: "awx-manage add_receptor_address --hostname {{ ansible_operator_meta.name }} --address {{ external_hostname }} --protocol ws" diff --git a/roles/mesh_ingress/templates/receptor_conf.configmap.yml.j2 b/roles/mesh_ingress/templates/receptor_conf.configmap.yml.j2 index a442cb79..c528922a 100644 --- a/roles/mesh_ingress/templates/receptor_conf.configmap.yml.j2 +++ b/roles/mesh_ingress/templates/receptor_conf.configmap.yml.j2 @@ -7,9 +7,11 @@ metadata: data: receptor_conf: | --- - - node: + - node: id: {{ ansible_operator_meta.name }} - log-level: debug + - control-service: + service: control - ws-listener: port: 27199 tls: tlsserver diff --git a/roles/mesh_ingress/templates/statefulset.yml.j2 b/roles/mesh_ingress/templates/statefulset.yml.j2 index 6c0f99ef..98bf02bc 100644 --- a/roles/mesh_ingress/templates/statefulset.yml.j2 +++ b/roles/mesh_ingress/templates/statefulset.yml.j2 @@ -19,7 +19,8 @@ spec: - | internal_hostname={{ ansible_operator_meta.name }} external_hostname={{ external_hostname }} - receptor --cert-makereq bits=2048 commonname=$internal_hostname dnsname=$internal_hostname dnsname=$external_hostname nodeid=$internal_hostname outreq=/etc/receptor/tls/receptor.req outkey=/etc/receptor/tls/receptor.key + external_ipaddress={{ external_ipaddress }} + receptor --cert-makereq bits=2048 commonname=$internal_hostname dnsname=$internal_hostname dnsname=$external_hostname nodeid=$internal_hostname ipaddress=$external_ipaddress outreq=/etc/receptor/tls/receptor.req outkey=/etc/receptor/tls/receptor.key receptor --cert-signreq req=/etc/receptor/tls/receptor.req cacert=/etc/receptor/tls/ca/mesh-CA.crt cakey=/etc/receptor/tls/ca/mesh-CA.key outcert=/etc/receptor/tls/receptor.crt verify=yes exec receptor --config /etc/receptor/receptor.conf image: '{{ _control_plane_ee_image }}'