Create directories if needed with ansible_pip_virtualenv_symlink

So, add more logic to ensure the parent directories for
ansible_pip_virtualenv_symlink exists, before we symlink into it.

Change-Id: I2c2a50f97610352a2e1e97fc92a7e9db2c851a25
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
Paul Belanger 2019-03-23 20:09:23 -04:00
parent 32b5a5c3bf
commit 0f06193eae

View File

@ -22,11 +22,27 @@
virtualenv_python: "{{ ansible_pip_virtualenv_python|default(omit) }}" virtualenv_python: "{{ ansible_pip_virtualenv_python|default(omit) }}"
virtualenv: "{{ ansible_pip_virtualenv|default(omit) }}" virtualenv: "{{ ansible_pip_virtualenv|default(omit) }}"
- name: Stat ansible_pip_virtualenv_symlink
stat:
path: "{{ ansible_pip_virtualenv_symlink | dirname }}"
register: r
no_log: true
when: ansible_pip_virtualenv_symlink is defined
- name: Create ansible_pip_virtualenv_symlink directory
become: true
file:
state: directory
path: "{{ ansible_pip_virtualenv_symlink | dirname }}"
when:
- ansible_pip_virtualenv_symlink is defined
- not r.stat.exists
- name: Symlink ansible virtualenv - name: Symlink ansible virtualenv
become: true become: true
file: file:
src: "{{ ansible_pip_virtualenv }}"
dest: "{{ ansible_pip_virtualenv_symlink }}" dest: "{{ ansible_pip_virtualenv_symlink }}"
src: "{{ ansible_pip_virtualenv }}"
state: link state: link
when: when:
- ansible_pip_virtualenv is defined - ansible_pip_virtualenv is defined