Fix git service folder create task

The attempt to resolve the issue of a pre-existing
link in the place of the directory
( https://review.openstack.org/367563 ) did not work
as the file module requires a source and dest when
implementing a link.

This patch separates the task and only executes the
directory create if there is no link in place.

As per https://github.com/willthames/ansible-lint/issues/161
the mode for all directories is set to include a leading
zero to ensure that it's enforced as octal.

Change-Id: I27a64e8edaee1f652a4b3a95d05941df34824660
This commit is contained in:
Jesse Pretorius 2016-09-09 08:46:21 +01:00 committed by Jesse Pretorius (odyssey4me)
parent 53f6852ba3
commit f1705ace9f
1 changed files with 20 additions and 9 deletions

View File

@ -49,24 +49,19 @@
- repo-key
- repo-key-create
- name: Check if the git folder exists already
stat:
path: "{{ repo_service_home_folder }}/repo/openstackgit"
register: _git_folder
- name: File and directory setup (non-root user)
file:
path: "{{ item.path }}"
state: "{{ item.state }}"
owner: "{{ repo_service_user_name }}"
group: "{{ repo_service_group_name }}"
mode: "{{ item.mode | default('2755') }}"
mode: "{{ item.mode | default('02755') }}"
with_items:
- path: "{{ repo_service_home_folder }}"
state: "directory"
- path: "{{ repo_service_home_folder }}/.ssh"
state: "directory"
mode: "2700"
mode: "02700"
- path: "{{ repo_service_home_folder }}/repo"
state: "directory"
- path: "{{ repo_service_home_folder }}/repo/links"
@ -75,13 +70,29 @@
state: "directory"
- path: "{{ repo_service_home_folder }}/repo/os-releases/{{ openstack_release }}"
state: "directory"
- path: "{{ repo_service_home_folder }}/repo/openstackgit"
state: "{{ (_git_folder.stat.exists and _git_folder.stat.islnk) | ternary('link', 'directory') }}"
- path: "{{ repo_service_home_folder }}/repo/pools"
state: "directory"
tags:
- pkg-repo-dirs
- name: Check if the git folder exists already
stat:
path: "{{ repo_service_home_folder }}/repo/openstackgit"
register: _git_folder
tags:
- pkg-repo-dirs
- name: Git service data folder setup
file:
path: "{{ repo_service_home_folder }}/repo/openstackgit"
state: "directory"
owner: "{{ repo_service_user_name }}"
group: "{{ repo_service_group_name }}"
mode: "02755"
when: not _git_folder.stat.exists or (_git_folder.stat.exists and not _git_folder.stat.islnk)
tags:
- pkg-repo-dirs
- name: File and directory setup (root user)
file:
path: "{{ item.path }}"