Browse Source

Add default value for validation.py inventory

Add default value as localhost for the inventory
option of the validation.py cli script

Fix related CI issues that comes with this change:
* add block for only check sestatus when a stdout is defined
* add extra_vars to the validation.py script to be able
  to configure the check-ram validation for CI envirnonment.

Change-Id: I2aaaa702d587b9ea5b79338c4b1dbf426e2b581d
changes/01/739001/8
Mathieu Bultel 10 months ago
parent
commit
e943a4e420
3 changed files with 34 additions and 20 deletions
  1. +1
    -0
      roles/validations/defaults/main.yaml
  2. +20
    -17
      validations_common/roles/check_selinux_mode/tasks/main.yml
  3. +13
    -3
      validations_common/validation.py

+ 1
- 0
roles/validations/defaults/main.yaml View File

@ -17,6 +17,7 @@ command:
{{ val_exec }} run --group prep --validation-dir {{ validation_dir }}
--ansible-base-dir {{ ansible_dir }}
--output-log {{ log_dir }}/run-group.log
--extra-vars minimal_ram_gb=7
- output: "{{ log_dir }}/list.log"
command: >-
{{ val_exec }} list --validation-dir {{ validation_dir }}


+ 20
- 17
validations_common/roles/check_selinux_mode/tasks/main.yml View File

@ -5,22 +5,25 @@
register: sestatus
changed_when: false
when:
- "ansible_os_family == 'RedHat'"
- "ansible_os_family is defined and ansible_os_family == 'RedHat'"
- name: Fail if SELinux is not in Enforced mode (RHEL)
fail:
msg: >-
SELinux is running in {{ sestatus.stdout }} mode on the Undercloud.
Ensure that SELinux is enabled and running in Enforcing mode.
when:
- "sestatus.stdout != 'Enforcing'"
- "ansible_distribution == 'RedHat'"
- name: Check sestatus
block:
- name: Fail if SELinux is not in Enforced mode (RHEL)
fail:
msg: >-
SELinux is running in {{ sestatus.stdout }} mode on the Undercloud.
Ensure that SELinux is enabled and running in Enforcing mode.
when:
- "sestatus.stdout != 'Enforcing'"
- "ansible_distribution == 'RedHat'"
- name: Warn if SELinux is not in Enforced mode (CentOS)
warn:
msg: >-
SELinux is running in {{ sestatus.stdout }} mode on the Undercloud.
Ensure that SELinux is enabled and running in Enforcing mode.
when:
- "sestatus.stdout != 'Enforcing'"
- "ansible_distribution == 'CentOS'"
- name: Warn if SELinux is not in Enforced mode (CentOS)
warn:
msg: >-
SELinux is running in {{ sestatus.stdout }} mode on the Undercloud.
Ensure that SELinux is enabled and running in Enforcing mode.
when:
- "sestatus.stdout != 'Enforcing'"
- "ansible_distribution == 'CentOS'"
when: sestatus.stdout is defined

+ 13
- 3
validations_common/validation.py View File

@ -59,8 +59,11 @@ class Validation(argparse.ArgumentParser):
choices=['run', 'list', 'show'],
help='Validation Action')
parser.add_argument('--inventory', '-i', type=str,
help=('Path of the Ansible inventory.'))
default="localhost",
help="Path of the Ansible inventory.")
parser.add_argument('--extra-vars', action='store',
nargs='+',
help="Extra ansible variables")
parser.add_argument('--validation', '-v',
metavar='<validation_id>[,<validation_id>,...]',
dest="validation_name",
@ -164,7 +167,13 @@ class Validation(argparse.ArgumentParser):
quiet = parsed_args.quiet
validation_dir = parsed_args.validation_dir
ansible_base_dir = parsed_args.ansible_base_dir
extra_vars = parsed_args.extra_vars
if extra_vars:
try:
extra_vars = dict(e.split("=") for e in parsed_args.extra_vars)
except ValueError:
msg = "extra vars option should be formed as: KEY=VALUE."
raise RuntimeError(msg)
v_actions = ValidationActions(validation_path=validation_dir,
group=group)
if 'run' in action:
@ -174,6 +183,7 @@ class Validation(argparse.ArgumentParser):
group=group,
validation_name=validation_name,
base_dir=ansible_base_dir,
extra_vars=extra_vars,
quiet=quiet)
except RuntimeError as e:
sys.exit(e)


Loading…
Cancel
Save