perniciouscaffeine perniciouscaffeine - 18 days ago 13
Git Question

How to have Ansible Git install into an existing directory

Attempting to repetitively git clone deploy into a common directory, but getting errors "/www' already exists and is not an empty directory".


error:
fatal: [35.162.216.10]: FAILED! => {"changed": false, "cmd": "/usr/bin/git clone --origin origin https://github.com/installtest/PHP-Algos.git /www", "failed": true, "msg": "fatal: destination path '/www' already exists and is not an empty directory.", "rc": 128, "stderr": "fatal: destination path '/www' already exists and is not an empty directory.\n", "stdout": "", "stdout_lines": []}


sections from playbook:

vars:
- website_dir: /www
- name: Deploy Code From Github
git:
dest={{ website_dir }}/
repo=https://github.com/installtest/PHP-Algos.git
update=yes
force=yes


perms for the deploy directory. The deploy is currently as ubuntu.

root@ip-172-30-0-219:~# ls -al /www
total 12
drwxrwxr-x 2 ubuntu www-data 4096 Nov 14 04:43 .
drwxr-xr-x 24 root root 4096 Nov 14 04:33 ..
-rw-r--r-- 1 ubuntu www-data 27 Nov 14 04:43 DATA_VARIABLES

Answer

dest parameter of git module is a destination directory, not the directory one step above:

Absolute path of where the repository should be checked out to.

You should use:

dest={{ website_dir }}/PHP-Algos
Comments