Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: fix ci tests #4

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pytest_extra_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: MIT

# ansible and dependencies for all supported platforms
ansible ; python_version > "2.6"
ansible<2.7 ; python_version < "2.7"
idna<2.8 ; python_version < "2.7"
PyYAML<5.1 ; python_version < "2.7"
13 changes: 11 additions & 2 deletions tasks/enable-repositories/CentOS.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# SPDX-License-Identifier: MIT
# No enable-repositories tasks are needed for Fedora. This file serves as a
# placeholder and prevents RedHat.yml to be executed instead.
---
- name: List active CentOS repositories
command: dnf repolist
register: __gfs2_repolist
changed_when: false
check_mode: false

- name: Enable CentOS repositories
command: dnf config-manager --set-enabled {{ item.id | quote }}
loop: "{{ __gfs2_repos }}"
when: item.id not in __gfs2_repolist.stdout
changed_when: item.name not in __gfs2_repolist.stdout
26 changes: 4 additions & 22 deletions tasks/install-packages.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
# SPDX-License-Identifier: MIT
---
- name: Ensure ansible_facts used by role
setup:
gather_subset: "{{ __gfs2_required_facts_subsets }}"
when: __gfs2_required_facts |
difference(ansible_facts.keys() | list) | length > 0

- name: Determine if system is ostree and set flag
when: not __gfs2_is_ostree is defined
block:
- name: Check if system is ostree
stat:
path: /run/ostree-booted
register: __ostree_booted_stat

- name: Set flag to indicate system is ostree
set_fact:
__gfs2_is_ostree: "{{ __ostree_booted_stat.stat.exists }}"

- name: Find environment-specific tasks to enable repositories
ansible.builtin.set_fact:
__gfs2_enable_repo_tasks_file: \
"{{ __gfs2_enable_repo_tasks_file_candidate }}"
__gfs2_enable_repo_tasks_file: >-
{{ __gfs2_enable_repo_tasks_file_candidate }}
loop:
- "{{ ansible_facts['os_family'] }}.yml"
- "{{ ansible_facts['distribution'] }}.yml"
Expand All @@ -32,8 +14,8 @@
{{ ansible_facts['distribution'] ~ '_' ~
ansible_facts['distribution_version'] }}.yml
vars:
__gfs2_enable_repo_tasks_file_candidate: \
"{{ role_path }}/tasks/enable-repositories/{{ item }}"
__gfs2_enable_repo_tasks_file_candidate: >-
{{ role_path }}/tasks/enable-repositories/{{ item }}
when:
- gfs2_enable_repos | bool
- __gfs2_enable_repo_tasks_file_candidate is file
Expand Down
9 changes: 6 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# SPDX-License-Identifier: MIT
---
- name: Set platform/version specific variables
ansible.builtin.include_tasks: set_vars.yml

- name: Install required packages
ansible.builtin.include_tasks: install-packages.yml

- name: Check for an active stonith resource
ansible.builtin.command:
argv:
Expand All @@ -14,9 +20,6 @@
or "Started" not in stonith_status.stdout
when: not _gfs2_test_allow_stonith_disabled

- name: Install required packages
ansible.builtin.include_tasks: install-packages.yml

- name: Setup cluster
ansible.builtin.include_tasks: setup-cluster.yml
when: gfs2_file_systems | length > 0
33 changes: 33 additions & 0 deletions tasks/set_vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
- name: Ensure ansible_facts used by role
ansible.builtin.setup:
gather_subset: "{{ __gfs2_required_facts_subsets }}"
when: __gfs2_required_facts |
difference(ansible_facts.keys() | list) | length > 0

- name: Determine if system is ostree and set flag
when: not __gfs2_is_ostree is defined
block:
- name: Check if system is ostree
ansible.builtin.stat:
path: /run/ostree-booted
register: __ostree_booted_stat

- name: Set flag to indicate system is ostree
ansible.builtin.set_fact:
__gfs2_is_ostree: "{{ __ostree_booted_stat.stat.exists }}"

- name: Set platform/version specific variables
ansible.builtin.include_vars: "{{ __vars_file }}"
loop:
- "{{ ansible_facts['os_family'] }}.yml"
- "{{ ansible_facts['distribution'] }}.yml"
- >-
{{ ansible_facts['distribution'] ~ '_' ~
ansible_facts['distribution_major_version'] }}.yml
- >-
{{ ansible_facts['distribution'] ~ '_' ~
ansible_facts['distribution_version'] }}.yml
vars:
__vars_file: "{{ role_path }}/vars/{{ item }}"
when: __vars_file is file
2 changes: 0 additions & 2 deletions tests/library/find_unused_disk.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/python

from __future__ import absolute_import, division, print_function

__metaclass__ = type
Expand Down
5 changes: 3 additions & 2 deletions tests/module_utils/size.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def get(self, units="autobin", fmt="%0.1f %sb"):
exp += 1
else:
ftr, exp = self._parse_units(units.strip())
value = (float(self.factor**self.exponent) / float(ftr**exp)) * self.number

value = (
float(self.factor**self.exponent) / float(ftr**exp)
Dismissed Show dismissed Hide dismissed
Dismissed Show dismissed Hide dismissed
) * self.number
return self._format(fmt, ftr, exp) % value
5 changes: 5 additions & 0 deletions vars/CentOS_8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: MIT
---
__gfs2_repos:
- id: resilientstorage
name: ResilientStorage
5 changes: 5 additions & 0 deletions vars/CentOS_9.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: MIT
---
__gfs2_repos:
- id: resilientstorage
name: ResilientStorage
Loading