Consolidate redundant git tasks in oracle-db-postinstall role

- Replace 4 separate git tasks with a single consolidated task
- Add proper error handling with failed_when condition
- Remove ignore_errors usage that was masking real errors
This commit is contained in:
Yacine31
2025-12-02 13:38:32 +01:00
parent e9b96ad99b
commit 5a7a40c3a3

View File

@@ -1,4 +1,5 @@
--- ---
---
# #
# post configuration d'une installation de base de données Oracle # post configuration d'une installation de base de données Oracle
# #
@@ -20,47 +21,19 @@
# --------------------------------------------------- # ---------------------------------------------------
# récupération des scripts sql # récupération des scripts sql
# --------------------------------------------------- # ---------------------------------------------------
- name: Vérifier si le répertoire scripts existe - name: Gérer le repository des scripts SQL
ansible.builtin.stat:
path: "{{ scripts_dir }}"
register: scripts_directory
- name: Cloner le repo scripts si inexistant
ansible.builtin.git:
repo: https://github.com/Yacine31/sql.git
dest: "{{ scripts_dir }}"
update: no
when: not scripts_directory.stat.exists
become: true
become_method: su
become_user: oracle
tags: scripts
- name: Mettre à jour le repo scripts si existe
ansible.builtin.git: ansible.builtin.git:
repo: https://github.com/Yacine31/sql.git repo: https://github.com/Yacine31/sql.git
dest: "{{ scripts_dir }}" dest: "{{ scripts_dir }}"
update: yes update: yes
force: yes force: yes
when: scripts_directory.stat.exists
become: true become: true
become_method: su become_method: su
become_user: oracle become_user: oracle
register: git_result
failed_when: git_result.failed and 'already exists' not in git_result.msg
tags: scripts tags: scripts
- name: Clonage du repository github SQL car le répertoire n'existe pas
ansible.builtin.git:
repo: https://github.com/Yacine31/sql.git
dest: "{{ scripts_dir }}"
clone: yes
update: yes
force: yes
when: not scripts_directory.stat.exists
ignore_errors: true
become: true
become_method: su
become_user: oracle
# --------------------------------------------------- # ---------------------------------------------------
# changement du propriétaire de root en oracle # changement du propriétaire de root en oracle
# --------------------------------------------------- # ---------------------------------------------------