From b06a0aea058f521107ce3eac377279a35fedcb7e Mon Sep 17 00:00:00 2001 From: "Eric D. Helms" Date: Fri, 6 Oct 2023 15:52:05 -0400 Subject: [PATCH] Add Candlepin pipeline to run puppet-candlepin tests --- pipelines/candlepin.yml | 3 ++ pipelines/candlepin/01-boxes.yml | 8 +++++ pipelines/candlepin/02-install.yml | 11 ++++++ pipelines/candlepin/03-tests.yml | 17 +++++++++ pipelines/vars/forklift_candlepin.yml | 8 +++++ roles/beaker/defaults/main.yml | 7 ++++ roles/beaker/tasks/main.yml | 50 +++++++++++++++++++++++++++ roles/beaker/tasks/test.yml | 5 +++ 8 files changed, 109 insertions(+) create mode 100644 pipelines/candlepin.yml create mode 100644 pipelines/candlepin/01-boxes.yml create mode 100644 pipelines/candlepin/02-install.yml create mode 100644 pipelines/candlepin/03-tests.yml create mode 100644 pipelines/vars/forklift_candlepin.yml create mode 100644 roles/beaker/defaults/main.yml create mode 100644 roles/beaker/tasks/main.yml create mode 100644 roles/beaker/tasks/test.yml diff --git a/pipelines/candlepin.yml b/pipelines/candlepin.yml new file mode 100644 index 000000000..fcdcea316 --- /dev/null +++ b/pipelines/candlepin.yml @@ -0,0 +1,3 @@ +- import_playbook: candlepin/01-boxes.yml +- import_playbook: candlepin/02-install.yml +- import_playbook: candlepin/03-tests.yml diff --git a/pipelines/candlepin/01-boxes.yml b/pipelines/candlepin/01-boxes.yml new file mode 100644 index 000000000..2a2758787 --- /dev/null +++ b/pipelines/candlepin/01-boxes.yml @@ -0,0 +1,8 @@ +--- +- name: create vagrant boxes + hosts: localhost + become: False + vars_files: + - ../vars/forklift_candlepin.yml + roles: + - forklift diff --git a/pipelines/candlepin/02-install.yml b/pipelines/candlepin/02-install.yml new file mode 100644 index 000000000..3b6d7662f --- /dev/null +++ b/pipelines/candlepin/02-install.yml @@ -0,0 +1,11 @@ +--- +- name: Setup git repo + become: True + hosts: + - "{{ forklift_name }}" + vars_files: + - ../vars/forklift_candlepin.yml + vars: + beaker_puppet_module: "puppet-candlepin" + roles: + - beaker diff --git a/pipelines/candlepin/03-tests.yml b/pipelines/candlepin/03-tests.yml new file mode 100644 index 000000000..3c630ea84 --- /dev/null +++ b/pipelines/candlepin/03-tests.yml @@ -0,0 +1,17 @@ +--- +- name: run tests + become: True + hosts: + - "{{ forklift_name }}" + vars_files: + - ../vars/forklift_candlepin.yml + tasks: + - name: Run acceptance tests + ansible.builtin.include_role: + name: beaker + tasks_from: test + vars: + beaker_puppet_module: "puppet-candlepin" + beaker_os: "{{ pipeline_os.replace('-stream', '') }}" + beaker_environment: + BEAKER_FACTER_CANDLEPIN_BASEURL: "https://stagingyum.theforeman.org/candlepin/{{ pipeline_version }}/el{{ ansible_distribution_major_version }}/x86_64" diff --git a/pipelines/vars/forklift_candlepin.yml b/pipelines/vars/forklift_candlepin.yml new file mode 100644 index 000000000..df531f83e --- /dev/null +++ b/pipelines/vars/forklift_candlepin.yml @@ -0,0 +1,8 @@ +forklift_name: "pipe-candlepin-{{ pipeline_version }}-{{ pipeline_os }}" + +server_box: + box: "{{ pipeline_os }}" + memory: 4680 + +forklift_boxes: + "{{ {forklift_name: server_box} }}" diff --git a/roles/beaker/defaults/main.yml b/roles/beaker/defaults/main.yml new file mode 100644 index 000000000..6d00c45f5 --- /dev/null +++ b/roles/beaker/defaults/main.yml @@ -0,0 +1,7 @@ +beaker_base_environment: + BEAKER_HYPERVISOR: "docker" + BEAKER_provision: "yes" + BEAKER_setfile: "{{ beaker_os }}-64{hostname={{ beaker_os }}-64.example.com}" + BEAKER_destroy: "no" +beaker_environment: {} +beaker_puppet_module_path: "/src/{{ beaker_puppet_module }}" diff --git a/roles/beaker/tasks/main.yml b/roles/beaker/tasks/main.yml new file mode 100644 index 000000000..5feec2a9e --- /dev/null +++ b/roles/beaker/tasks/main.yml @@ -0,0 +1,50 @@ +--- +- name: Install podman-docker + package: + name: podman-docker + state: installed + +- name: Start podman + service: + name: podman + state: started + +- name: Install git + package: + name: git + state: installed + +- name: Enable ruby 2.7 module + command: dnf module enable -y ruby:2.7 + when: ansible_distribution_major_version == "8" + +- name: enable powertools + command: dnf config-manager --set-enabled powertools + when: ansible_distribution_major_version == "8" + +- name: enable CRB + command: dnf config-manager --set-enabled crb + when: ansible_distribution_major_version == "9" + +- name: Install Ruby + package: + state: installed + name: + - ruby + - ruby-devel + - rubygem-bundler + - gcc-c++ + - make + - redhat-rpm-config + - libyaml-devel + +- name: Clone puppet module + ansible.builtin.git: + repo: "https://github.com/theforeman/{{ beaker_puppet_module }}.git" + dest: "{{ beaker_puppet_module_path }}" + version: "{{ beaker_puppet_module_version | default(omit) }}" + +- name: Bundle install + command: bundle install + args: + chdir: "{{ beaker_puppet_module_path }}" diff --git a/roles/beaker/tasks/test.yml b/roles/beaker/tasks/test.yml new file mode 100644 index 000000000..69c314881 --- /dev/null +++ b/roles/beaker/tasks/test.yml @@ -0,0 +1,5 @@ +- name: Run acceptance tests + command: bundle exec rake beaker + args: + chdir: "{{ beaker_puppet_module_path }}" + environment: "{{ beaker_base_environment | ansible.builtin.combine(beaker_environment) }}"