unable to create directory

I am trying to clone a git repository using the git clone command but it is unable to create the directory structure and copies the entire files in the parent directory.
example when i do the

  • git: repo=http://pathtothegit/container.git dest=/data/config recursive=yes ====> it only copies the files to the /data/config directory it doesnot make the directory container under /data/config like /data/config/container rather copies all the files under /data/config ( not under /data/config/container/)

Could you please let me know if i need to mention anything in the git module…thanks for the help…

I am trying to clone a git repository using the git clone command but it is
unable to create the directory structure and copies the entire files in the
parent directory.
example when i do the
- git: repo=http://pathtothegit/container.git dest=/data/config
recursive=yes ====> it only copies the files to the /data/config directory
it doesnot make the directory container under /data/config like
/data/config/container rather copies all the files under /data/config ( not
under /data/config/container/)

Could you please let me know if i need to mention anything in the git
module...thanks for the help..

That's just how Git and the Git module work.

As the Ansible documentation for Git module state:
dest -> The path of where the repository should be checked out.

Ansible is running
git clone http://pathtothegit/container.git /data/config

If you do that on the command line you'll get the same result.

From the man git:

git clone <repository> [<directory>]

<directory>
  The name of a new directory to clone into. The "humanish" part of the
  source repository is used if no directory is explicitly given
  (repo for /path/to/repo.git and foo for host.xz:foo/.git). Cloning into
  an existing directory is only allowed if the directory is empty.

Thanks for replying Kai, if i understand you correctly , git module in anisble doesnot create the parent directory for example if the playbook has the below git play
git: repo= git: repo=https://github.com/drush-ops/drush.git dest=/data/gitfiles clone=yes ==> it will not create a drush directory under /data/gitfiles…

and only when we run @command prompt git clone https://github.com/drush-ops/drush.git , it will create a directory drush under the present working directory as there was no directory mention…so there is no way that we have that directory “drush” created under the directory …thanks for the help.

Thanks for replying Kai, if i understand you correctly , git module in
anisble doesnot create the parent directory for example if the playbook has
the below git play
git: repo= git: repo=https://github.com/drush-ops/drush.git
dest=/data/gitfiles clone=yes ==> it will not create a drush directory
under /data/gitfiles...

Well, it sort of does, it will create /data/gitfiles if it doesn't exist, but i doesn't append a directory to dest.

and only when we run @command prompt git clone
https://github.com/drush-ops/drush.git , it will create a directory drush
under the present working directory as there was no directory mention...so
there is no way that we have that directory "drush" created under the
directory ...thanks for the help.

Correct, that a feature of git command line tool.
If you set dest to /data/gitfiles/drush you'll get what you are looking for.
The git-module will create the drush directory if it doesn't exist.

thanks again Kai for that insight…

also anytime if need to run the clone multiple times then can we use the force command …to get the updated repo…