tl;dr;
hg clone ssh://hg@bitbucket.org/team/repo ~/prod/
fails with "destination is not empty" if ~/prod/ is not empty. Can I force cloning?
I am trying to write my first Ansible playbook that should deploy my code from a Bitbucket Mercurial repository to my server. There is a deployment path, ~/prod
, which contains all code files as well as the data in ~/prod/media
and ~/prod/db.db
. To make sure the playbook works even if the ~/prod
directory is empty or doesn't exist, this is what I have so far:
- name: create directory
file: path=/home/user/prod state=directory
- name: clone repo
hg:
repo: ssh://hg@bitbucket.org/team/repo
dest: /home/user/prod
force: yes
In my understanding, it ensures that the deployment directory exists and then clones the repo there. It works beautifully if the directory doesn't exist or is empty. However, as soon as I've cloned the repo once, this playbook fails with destination is not empty
.
I can move media and db.db out first, then delete all other files, then clone, then move the data back. But it looks cumbersome.
I simply want to force cloning. But I cannot find the way to do it. Presumably this is so wrong that Mercurial won't allow me doing this. Why and what's a better way to go?