From 3cbb6b24c1a1da0225440bc1dcfa2c36539dda05 Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Tue, 12 Apr 2022 14:13:59 -0600 Subject: [PATCH] add setup-snapshot.yml used to prepare testing snapshots When running CI tests, test performance can be improved by creating a snapshot image to use for the test, pre-installed with packages used by the role tests. The CI system can use tests/setup-snapshot.yml to prepare the snapshot image. Rather than having a list of packages to install in multiple places, the code which ensures the facts and variables is moved to a separate tasks/set_facts.yml so that the setup playbook can use `tasks_from: set_facts.yml` to get the list of network packages to install. NOTE: The network role developers should add additional packages to setup-snapshot.yml for other packages installed by other tests. Signed-off-by: Rich Megginson --- tasks/main.yml | 15 +-------------- tasks/set_facts.yml | 17 +++++++++++++++++ tests/setup-snapshot.yml | 12 ++++++++++++ 3 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 tasks/set_facts.yml create mode 100644 tests/setup-snapshot.yml diff --git a/tasks/main.yml b/tasks/main.yml index 78881f7..336e387 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,20 +2,7 @@ # get service facts, used in defaults/main.yml --- - name: Ensure ansible_facts used by role - setup: - gather_subset: min - when: not ansible_facts.keys() | list | - intersect(__network_required_facts) == __network_required_facts - no_log: true - -- name: Check which services are running - service_facts: - no_log: true - -# needed for ansible_facts.packages -- name: Check which packages are installed - package_facts: - no_log: true + include_tasks: tasks/set_facts.yml - name: Print network provider debug: diff --git a/tasks/set_facts.yml b/tasks/set_facts.yml new file mode 100644 index 0000000..c0c9ff6 --- /dev/null +++ b/tasks/set_facts.yml @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: BSD-3-Clause +--- +- name: Ensure ansible_facts used by role are present + setup: + gather_subset: min + when: not ansible_facts.keys() | list | + intersect(__network_required_facts) == __network_required_facts + no_log: true + +- name: Check which services are running + service_facts: + no_log: true + +# needed for ansible_facts.packages +- name: Check which packages are installed + package_facts: + no_log: true diff --git a/tests/setup-snapshot.yml b/tests/setup-snapshot.yml new file mode 100644 index 0000000..8302f62 --- /dev/null +++ b/tests/setup-snapshot.yml @@ -0,0 +1,12 @@ +- hosts: all + tasks: + - name: Set facts used by role + include_role: + name: linux-system-roles.network + tasks_from: set_facts.yml + public: true + + - name: Install test packages + package: + name: "{{ network_packages }}" + state: present