From f3b00c1e1677db564e469190c35c26dbf26f1bb0 Mon Sep 17 00:00:00 2001 From: "a.b.christie" Date: Fri, 23 Jan 2026 13:24:59 +0000 Subject: [PATCH] feat: Fix for latest deployment --- roles/nginx/tasks/deploy.yaml | 20 +++++++------------ roles/nginx/tasks/login.yaml | 17 ---------------- roles/nginx/tasks/logout.yaml | 10 ---------- roles/nginx/tasks/main.yaml | 19 ++++-------------- roles/nginx/tasks/prep.yaml | 9 --------- roles/nginx/templates/role.yaml.j2 | 11 ---------- .../templates/rolebinding-default-sa.yaml.j2 | 18 ----------------- 7 files changed, 11 insertions(+), 93 deletions(-) delete mode 100644 roles/nginx/tasks/login.yaml delete mode 100644 roles/nginx/tasks/logout.yaml delete mode 100644 roles/nginx/templates/role.yaml.j2 delete mode 100644 roles/nginx/templates/rolebinding-default-sa.yaml.j2 diff --git a/roles/nginx/tasks/deploy.yaml b/roles/nginx/tasks/deploy.yaml index 9220ce6..2eb9ac9 100644 --- a/roles/nginx/tasks/deploy.yaml +++ b/roles/nginx/tasks/deploy.yaml @@ -23,24 +23,18 @@ - name: Creating namespace material k8s: - definition: "{{ lookup('template', '{{ item }}.yaml.j2') }}" + definition: "{{ lookup('template', item) }}" wait: yes loop: - - serviceaccount - - role - -- name: Relax {{ nx_namespace }} 'default' service account (for cert-manager) - k8s: - definition: "{{ lookup('template', 'rolebinding-default-sa.yaml.j2') }}" - wait: yes + - serviceaccount.yaml.j2 - name: Deploy nginx ({{ nx_hostname }}) k8s: - definition: "{{ lookup('template', '{{ item }}.yaml.j2') }}" + definition: "{{ lookup('template', item) }}" wait: yes wait_timeout: "{{ wait_timeout }}" loop: - - configmap - - deployment - - service - - ingress + - configmap.yaml.j2 + - deployment.yaml.j2 + - service.yaml.j2 + - ingress.yaml.j2 diff --git a/roles/nginx/tasks/login.yaml b/roles/nginx/tasks/login.yaml deleted file mode 100644 index 1e445bf..0000000 --- a/roles/nginx/tasks/login.yaml +++ /dev/null @@ -1,17 +0,0 @@ ---- - -# Called (normally) to authenticate with OpenShift. -# At the end of this play two variables are set, -# the kubernetes API host and an API key. - -- name: Log in to OpenShift (obtain access token) - k8s_auth: - host: "{{ okd_master_hostname }}" - username: "{{ okd_admin }}" - password: "{{ okd_admin_password }}" - register: k8s_auth_results - -- name: Set API key - set_fact: - k8s_auth_host: "{{ okd_master_hostname }}" - k8s_auth_api_key: "{{ k8s_auth_results.k8s_auth.api_key }}" diff --git a/roles/nginx/tasks/logout.yaml b/roles/nginx/tasks/logout.yaml deleted file mode 100644 index 6a3aac0..0000000 --- a/roles/nginx/tasks/logout.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -# Called to logout of an OpenShift session - -- name: Log out (revoke a prior access token) - k8s_auth: - host: "{{ okd_master_hostname }}" - api_key: "{{ k8s_auth_api_key }}" - state: absent - when: k8s_auth_api_key is defined diff --git a/roles/nginx/tasks/main.yaml b/roles/nginx/tasks/main.yaml index 75ba891..db1566a 100644 --- a/roles/nginx/tasks/main.yaml +++ b/roles/nginx/tasks/main.yaml @@ -2,12 +2,6 @@ - include_tasks: prep.yaml -# If it looks like we're deploying to OpenShift -# we need to use the k8s authentication module to login -# and obtain an API key. -- include_tasks: login.yaml - when: okd_master_hostname is defined - # A kubernetes (or OpenShift) host and an API key must be set. # We will either have authenticated against an OpenShift server # or the AWX kubernetes credentials will have injected suitable @@ -17,24 +11,19 @@ - name: Assert authentication assert: that: - - k8s_auth_host|length > 0 - - k8s_auth_api_key|length > 0 + - k8s_auth_host | length > 0 + - k8s_auth_api_key | length > 0 # Go... - block: - include_tasks: deploy.yaml - when: nx_state|string == 'present' + when: nx_state | string == 'present' - include_tasks: undeploy.yaml - when: nx_state|string == 'absent' + when: nx_state | string == 'absent' module_defaults: group/k8s: host: "{{ k8s_auth_host }}" api_key: "{{ k8s_auth_api_key }}" - -# If it looks like we're deploying to OpenShift -# we now need to logout... -- include_tasks: logout.yaml - when: okd_master_hostname is defined diff --git a/roles/nginx/tasks/prep.yaml b/roles/nginx/tasks/prep.yaml index 32e8a58..762d5ca 100644 --- a/roles/nginx/tasks/prep.yaml +++ b/roles/nginx/tasks/prep.yaml @@ -6,15 +6,6 @@ - debug: var: ansible_version.full -# Basic pre-playbook prerequisites. -# We need the openshift/kubernetes module amongst other things... - -- name: Install prerequisite Python modules - pip: - name: - - jmespath==0.9.4 - extra_args: --user - # Kubernetes credentials ------------------------------------------------------ # We don't use the Kubernetes credentials directly, diff --git a/roles/nginx/templates/role.yaml.j2 b/roles/nginx/templates/role.yaml.j2 deleted file mode 100644 index a958802..0000000 --- a/roles/nginx/templates/role.yaml.j2 +++ /dev/null @@ -1,11 +0,0 @@ ---- -kind: Role -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: nx-psp-unrestricted - namespace: "{{ nx_namespace }}" -rules: -- apiGroups: ['policy'] - resources: ['podsecuritypolicies'] - verbs: ['use'] - resourceNames: ['{{ nx_sa_psp }}'] diff --git a/roles/nginx/templates/rolebinding-default-sa.yaml.j2 b/roles/nginx/templates/rolebinding-default-sa.yaml.j2 deleted file mode 100644 index d3a9b52..0000000 --- a/roles/nginx/templates/rolebinding-default-sa.yaml.j2 +++ /dev/null @@ -1,18 +0,0 @@ ---- - -# A RoleBinding to allow the cert-manager cm-acme-http-solver Pod -# to deploy to our namespace. - -kind: RoleBinding -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: default-sa - namespace: "{{ nx_namespace }}" -roleRef: - kind: Role - name: nx-psp-unrestricted - apiGroup: rbac.authorization.k8s.io -subjects: -- kind: ServiceAccount - name: default - namespace: "{{ nx_namespace }}"