diff --git a/defaults/main.yml b/defaults/main.yml index e6357e4d..c48ceefd 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -212,3 +212,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: + - "*" diff --git a/tasks/main.yml b/tasks/main.yml index 13ebc42b..275a7e82 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -169,7 +169,6 @@ apply: tags: - openstack_hosts-config - when: ansible_facts['hostname'] != 'aio1' - name: Including openstack_hosts_systemd tasks include_tasks: openstack_hosts_systemd.yml diff --git a/tasks/openstack_gitconfig.yml b/tasks/openstack_gitconfig.yml index 70314e7a..0a126408 100644 --- a/tasks/openstack_gitconfig.yml +++ b/tasks/openstack_gitconfig.yml @@ -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 diff --git a/templates/gitconfig.j2 b/templates/gitconfig.j2 index 27e6d4bc..afe8f906 100644 --- a/templates/gitconfig.j2 +++ b/templates/gitconfig.j2 @@ -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 %}