Allow openstack_hosts role to configure git safe.directory entries

This is defaulted to '*" and will be undefined when a CI specific
override is subsequently merged to the openstack-ansible repository.

Change-Id: I1c1dc35d8d59db4ae2b6770a620d91548a8a3734
(cherry picked from commit a8d1c8268a252cd7cc5ff0ec0988b75277a0a5fe)
This commit is contained in:
Jonathan Rosser 2024-05-29 16:35:40 +01:00
parent 5289bb5ff3
commit 26826040dd
4 changed files with 20 additions and 1 deletions

View File

@ -207,3 +207,6 @@ openstack_hosts_systemd_networkd_networks: []
openstack_hosts_systemd_networkd_prefix: openstack-net
openstack_hosts_systemd_services: []
openstack_hosts_systemd_slice: "openstack-hosts"
openstack_hosts_git_safe_directories:
- "*"

View File

@ -163,7 +163,6 @@
apply:
tags:
- openstack_hosts-config
when: ansible_facts['hostname'] != 'aio1'
- include_tasks: openstack_hosts_systemd.yml
args:

View File

@ -29,6 +29,16 @@
value: "{{ 'git/' ~ _git_version.stdout.split(' ')[2] ~ ' (osa/' ~ lookup('env', 'OSA_VERSION') ~ '/' ~ component | default('undefined') ~ ')' }}"
when: _git_version.rc == 0
- name: Configure git safe directories
git_config:
scope: system
name: safe.directory
value: "{{ item }}"
with_items: "{{ openstack_hosts_git_safe_directories }}"
when:
- _git_version.rc == 0
- openstack_hosts_git_safe_directories is defined
- name: Write git config when git is not installed
template:
src: gitconfig.j2

View File

@ -1,2 +1,9 @@
[http "https://opendev.org/"]
userAgent = git/unknown (osa/{{ lookup('env', 'OSA_VERSION') }}/{{ component | default('undefined') }})
{% if openstack_hosts_git_safe_directories is defined %}
[safe]
{% for dir in openstack_hosts_git_safe_directories %}
directory {{ dir }}
{% endfor %}
{% endif %}