38 lines
1.6 KiB
YAML
38 lines
1.6 KiB
YAML
|
|
---
|
||
|
|
# =============================================================================
|
||
|
|
# tasks/validate.yml — Validation du fact (exécution + parsing JSON)
|
||
|
|
# =============================================================================
|
||
|
|
|
||
|
|
- name: Forcer le rechargement des facts si déploiement effectué
|
||
|
|
ansible.builtin.meta: flush_handlers
|
||
|
|
|
||
|
|
- name: Exécuter le script fact manuellement pour validation
|
||
|
|
ansible.builtin.command:
|
||
|
|
cmd: "{{ remote_users_fact_dir }}/{{ remote_users_fact_name }}"
|
||
|
|
register: _remote_users_fact_output
|
||
|
|
changed_when: false
|
||
|
|
failed_when: _remote_users_fact_output.rc != 0
|
||
|
|
|
||
|
|
- name: Valider que la sortie est du JSON parsable
|
||
|
|
ansible.builtin.set_fact:
|
||
|
|
_remote_users_fact_parsed: "{{ _remote_users_fact_output.stdout | from_json }}"
|
||
|
|
|
||
|
|
- name: Vérifier la présence des clés obligatoires
|
||
|
|
ansible.builtin.assert:
|
||
|
|
that:
|
||
|
|
- _remote_users_fact_parsed.sessions is defined
|
||
|
|
- _remote_users_fact_parsed.sessions.ssh is defined
|
||
|
|
- _remote_users_fact_parsed.sessions.citrix is defined
|
||
|
|
- _remote_users_fact_parsed.sessions.horizon is defined
|
||
|
|
- _remote_users_fact_parsed.sessions.total_by_protocol is defined
|
||
|
|
- _remote_users_fact_parsed.sessions.who_remote is defined
|
||
|
|
- _remote_users_fact_parsed.reliability is defined
|
||
|
|
- _remote_users_fact_parsed.reliability.verdict is defined
|
||
|
|
- _remote_users_fact_parsed.detection is defined
|
||
|
|
fail_msg: "Le fact remote_users ne retourne pas la structure JSON attendue"
|
||
|
|
success_msg: "Structure JSON validée avec succès"
|
||
|
|
|
||
|
|
- name: Recharger les ansible_local facts
|
||
|
|
ansible.builtin.setup:
|
||
|
|
filter: ansible_local
|