Refactor Ansible tasks and templates for improved consistency and clarity
This commit is contained in:
+67
-19
@@ -5,10 +5,20 @@
|
||||
# ---
|
||||
|
||||
- name: (git.yml) Install/Update default repositories
|
||||
git:
|
||||
repo: '{{ item.repo }}'
|
||||
dest: '{{ item.dest }}'
|
||||
with_items: '{{ git_default_repositories }}'
|
||||
ansible.builtin.git:
|
||||
repo: "{{ item.repo }}"
|
||||
dest: "{{ item.dest }}"
|
||||
version: >-
|
||||
{{
|
||||
item.version
|
||||
| default(item.branch)
|
||||
| default(
|
||||
'master'
|
||||
if (lookup('pipe', 'git ls-remote --heads ' ~ item.repo ~ ' master') | length > 0)
|
||||
else 'main'
|
||||
)
|
||||
}}
|
||||
with_items: "{{ git_default_repositories }}"
|
||||
loop_control:
|
||||
label: "{{ item.name }}"
|
||||
tags:
|
||||
@@ -20,10 +30,20 @@
|
||||
# ---
|
||||
|
||||
- name: (git.yml) Install/Update file_server repositories
|
||||
git:
|
||||
repo: '{{ item.repo }}'
|
||||
dest: '{{ item.dest }}'
|
||||
with_items: '{{ git_oopen_server_repositories }}'
|
||||
ansible.builtin.git:
|
||||
repo: "{{ item.repo }}"
|
||||
dest: "{{ item.dest }}"
|
||||
version: >-
|
||||
{{
|
||||
item.version
|
||||
| default(item.branch)
|
||||
| default(
|
||||
'master'
|
||||
if (lookup('pipe', 'git ls-remote --heads ' ~ item.repo ~ ' master') | length > 0)
|
||||
else 'main'
|
||||
)
|
||||
}}
|
||||
with_items: "{{ git_oopen_server_repositories }}"
|
||||
loop_control:
|
||||
label: "{{ item.name }}"
|
||||
when: "groups['file_server']|string is search(inventory_hostname)"
|
||||
@@ -36,14 +56,34 @@
|
||||
# ---
|
||||
|
||||
- name: (git.yml) Install/Update samba server repositories
|
||||
git:
|
||||
repo: '{{ item.repo }}'
|
||||
dest: '{{ item.dest }}'
|
||||
with_items: '{{ git_samba_repositories }}'
|
||||
ansible.builtin.git:
|
||||
repo: "{{ item.repo }}"
|
||||
dest: "{{ item.dest }}"
|
||||
version: >-
|
||||
{{
|
||||
item.version
|
||||
| default(item.branch)
|
||||
| default(
|
||||
'master'
|
||||
if (lookup('pipe', 'git ls-remote --heads ' ~ item.repo ~ ' master') | length > 0)
|
||||
else 'main'
|
||||
)
|
||||
}}
|
||||
with_items: "{{ git_samba_repositories }}"
|
||||
register: common_git_samba_result
|
||||
loop_control:
|
||||
label: "{{ item.name }}"
|
||||
when: "groups['samba_server']|string is search(inventory_hostname)"
|
||||
ignore_errors: True
|
||||
failed_when: >-
|
||||
(common_git_samba_result.failed | default(false)) and (
|
||||
common_git_samba_result.msg is not defined or (
|
||||
('Could not resolve host' not in common_git_samba_result.msg)
|
||||
and ('Connection timed out' not in common_git_samba_result.msg)
|
||||
and ('Failed to connect to' not in common_git_samba_result.msg)
|
||||
and ('Connection reset by peer' not in common_git_samba_result.msg)
|
||||
and ('Operation timed out' not in common_git_samba_result.msg)
|
||||
)
|
||||
)
|
||||
tags:
|
||||
- git-samba-server-repositories
|
||||
|
||||
@@ -53,14 +93,22 @@
|
||||
# ---
|
||||
|
||||
- name: (git.yml) Install/Update gateway repositories
|
||||
git:
|
||||
repo: '{{ item.repo }}'
|
||||
dest: '{{ item.dest }}'
|
||||
with_items: '{{ git_gateway_repositories }}'
|
||||
ansible.builtin.git:
|
||||
repo: "{{ item.repo }}"
|
||||
dest: "{{ item.dest }}"
|
||||
version: >-
|
||||
{{
|
||||
item.version
|
||||
| default(item.branch)
|
||||
| default(
|
||||
'master'
|
||||
if (lookup('pipe', 'git ls-remote --heads ' ~ item.repo ~ ' master') | length > 0)
|
||||
else 'main'
|
||||
)
|
||||
}}
|
||||
with_items: "{{ git_gateway_repositories }}"
|
||||
loop_control:
|
||||
label: "{{ item.name }}"
|
||||
when: "groups['gateway_server']|string is search(inventory_hostname)"
|
||||
tags:
|
||||
- git-gateway-server-repositories
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user