From 2ca458f78e78d94fb8c635b3f26a8f6120b2a1d4 Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Fri, 5 Jul 2024 19:32:02 +0100 Subject: [PATCH] Add support for deploying mcapi control plane k8s on debian-12 Change-Id: I616d723f3ec5ef87123b3dba498e9bccce50b9c1 --- .../user-collection-requirements.yml | 4 ++-- .../openstack_deploy/user_variables_k8s.yml | 3 +++ .../playbooks/mcapi_control_plane_k8s.yml | 22 ++++++++++++++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/mcapi_vexxhost/playbooks/files/openstack_deploy/user-collection-requirements.yml b/mcapi_vexxhost/playbooks/files/openstack_deploy/user-collection-requirements.yml index 6af873e2..bb5d26c4 100644 --- a/mcapi_vexxhost/playbooks/files/openstack_deploy/user-collection-requirements.yml +++ b/mcapi_vexxhost/playbooks/files/openstack_deploy/user-collection-requirements.yml @@ -1,8 +1,8 @@ collections: - name: vexxhost.kubernetes - source: https://github.com/vexxhost/ansible-collection-kubernetes + source: https://github.com/jrosser/ansible-collection-kubernetes type: git - version: v1.14.1 + version: venv-support - name: osa_ops.mcapi_vexxhost type: git version: master diff --git a/mcapi_vexxhost/playbooks/files/openstack_deploy/user_variables_k8s.yml b/mcapi_vexxhost/playbooks/files/openstack_deploy/user_variables_k8s.yml index 5587921f..e1610f50 100644 --- a/mcapi_vexxhost/playbooks/files/openstack_deploy/user_variables_k8s.yml +++ b/mcapi_vexxhost/playbooks/files/openstack_deploy/user_variables_k8s.yml @@ -14,3 +14,6 @@ openstack_host_nf_conntrack_max: 1572864 # OSA containers dont run ssh by default so cannot use synchronize upload_helm_chart_method: copy + +# Run ansible modules in a venv on the target hosts +ansible_collection_kubernetes_target_venv: /opt/mcapi_ansible_venv diff --git a/mcapi_vexxhost/playbooks/mcapi_control_plane_k8s.yml b/mcapi_vexxhost/playbooks/mcapi_control_plane_k8s.yml index a367f1be..3b14ddce 100644 --- a/mcapi_vexxhost/playbooks/mcapi_control_plane_k8s.yml +++ b/mcapi_vexxhost/playbooks/mcapi_control_plane_k8s.yml @@ -13,11 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Gather k8s facts +- name: Initial facts gathering and venv setup hosts: k8s_all gather_facts: false tags: - always + - k8s-venv tasks: - name: Gather minimal facts for k8s setup: @@ -26,6 +27,22 @@ - min when: osa_gather_facts | default(True) + - name: ensure python3 virtualenv is present + ansible.builtin.package: + name: + - python3-venv + - python3-setuptools + when: ansible_facts['os_family'] == 'Debian' + + - name: ensure ansible target venv is present + ansible.builtin.pip: + name: + - packaging + virtualenv_command: "python3 -m venv" + virtualenv: "{{ ansible_collection_kubernetes_target_venv }}" + when: ansible_collection_kubernetes_target_venv is defined + + - name: Create and configure k8s container hosts: k8s_all serial: "{{ k8s_serial | default('20%') }}" @@ -104,6 +121,7 @@ vars: k8s_node_labels: openstack-control-plane: enabled + ansible_python_interpreter: "{{ ansible_collection_kubernetes_target_venv ~ '/bin/python' }}" roles: - role: "vexxhost.containers.containerd" - role: "vexxhost.kubernetes.kubernetes" @@ -126,6 +144,8 @@ hosts: k8s_all gather_facts: true user: root + vars: + ansible_python_interpreter: "{{ ansible_collection_kubernetes_target_venv ~ '/bin/python' }}" roles: - role: "vexxhost.kubernetes.cert_manager" - role: "vexxhost.kubernetes.cluster_api"