From 4ad56e2772caaa42a486d604f764d7726b9562bb Mon Sep 17 00:00:00 2001 From: Luke Simmons Date: Sat, 14 Jan 2023 20:48:13 +0100 Subject: [PATCH] Fix for creating VirtualMachine (#9657) --- pipeline.Dockerfile | 4 ++++ .../roles/packet-ci/tasks/create-vms.yml | 15 +++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/pipeline.Dockerfile b/pipeline.Dockerfile index 167aca29b..c25c24244 100644 --- a/pipeline.Dockerfile +++ b/pipeline.Dockerfile @@ -45,3 +45,7 @@ RUN wget https://releases.hashicorp.com/vagrant/${VAGRANT_VERSION}/vagrant_${VAG dpkg -i vagrant_${VAGRANT_VERSION}_x86_64.deb && \ rm vagrant_${VAGRANT_VERSION}_x86_64.deb && \ vagrant plugin install vagrant-libvirt + +# Install Kubernetes collections +RUN pip3 install kubernetes \ + && ansible-galaxy collection install kubernetes.core \ No newline at end of file diff --git a/tests/cloud_playbooks/roles/packet-ci/tasks/create-vms.yml b/tests/cloud_playbooks/roles/packet-ci/tasks/create-vms.yml index bf63c9179..77373151c 100644 --- a/tests/cloud_playbooks/roles/packet-ci/tasks/create-vms.yml +++ b/tests/cloud_playbooks/roles/packet-ci/tasks/create-vms.yml @@ -11,20 +11,19 @@ mode: 0755 - name: Template vm files for CI job - template: - src: "vm.yml.j2" - dest: "/tmp/{{ test_name }}/instance-{{ vm_id }}.yml" - mode: 0644 + set_fact: + vms_files: "{{ vms_files }} + [{{ lookup('ansible.builtin.template', 'vm.yml.j2') | from_yaml }}]" + vars: + vms_files: [] loop: "{{ range(1, vm_count|int + 1, 1) | list }}" loop_control: index_var: vm_id - name: Start vms for CI job - command: "kubectl apply -f /tmp/{{ test_name }}/instance-{{ vm_id }}.yml" + kubernetes.core.k8s: + definition: "{{ item }}" changed_when: false - loop: "{{ range(1, vm_count|int + 1, 1) | list }}" - loop_control: - index_var: vm_id + loop: "{{ vms_files }}" - name: Wait for vms to have ipaddress assigned shell: "set -o pipefail && kubectl get vmis -n {{ test_name }} instance-{{ vm_id }} -o json | jq '.status.interfaces[].ipAddress' | tr -d '\"'"