From 1e21b446be5b95a9e8e2bc91e8140f0b9f0cc35e Mon Sep 17 00:00:00 2001 From: emo Date: Mon, 27 Nov 2023 22:56:53 +0100 Subject: [PATCH] refactor tasks in role linux_container --- .../roles/linux_container/tasks/container.yml | 12 ++++++++++++ .../roles/linux_container/tasks/main.yml | 12 +----------- 2 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 collections/ansible_collections/theliberatededge/test_linux_containers/roles/linux_container/tasks/container.yml diff --git a/collections/ansible_collections/theliberatededge/test_linux_containers/roles/linux_container/tasks/container.yml b/collections/ansible_collections/theliberatededge/test_linux_containers/roles/linux_container/tasks/container.yml new file mode 100644 index 0000000..97ba8f4 --- /dev/null +++ b/collections/ansible_collections/theliberatededge/test_linux_containers/roles/linux_container/tasks/container.yml @@ -0,0 +1,12 @@ +--- +- name: find current container state + ansible.builtin.command: lxc ls {{ lte_container_name }} + register: container_state + changed_when: false +- name: launch debian bookworm linux container + ansible.builtin.shell: + cmd: | + lxc launch \ + images:debian/{{ lte_debian_version }}/cloud \ + {{ lte_container_name }} + when: (container_state.rc == 1) or ("RUNNING" not in container_state.stdout) diff --git a/collections/ansible_collections/theliberatededge/test_linux_containers/roles/linux_container/tasks/main.yml b/collections/ansible_collections/theliberatededge/test_linux_containers/roles/linux_container/tasks/main.yml index 97ba8f4..467c0a2 100644 --- a/collections/ansible_collections/theliberatededge/test_linux_containers/roles/linux_container/tasks/main.yml +++ b/collections/ansible_collections/theliberatededge/test_linux_containers/roles/linux_container/tasks/main.yml @@ -1,12 +1,2 @@ --- -- name: find current container state - ansible.builtin.command: lxc ls {{ lte_container_name }} - register: container_state - changed_when: false -- name: launch debian bookworm linux container - ansible.builtin.shell: - cmd: | - lxc launch \ - images:debian/{{ lte_debian_version }}/cloud \ - {{ lte_container_name }} - when: (container_state.rc == 1) or ("RUNNING" not in container_state.stdout) +- include_tasks: container.yml