I do not have remote git repo, only a local one. Is it possible to pull a local repo to a remote machine?
I tried the following:
`
- name: pull the code
git: repo=file:///home/username/myproject/.git dest=/var/www
`
and got an error:
`
stderr: fatal: ‘/home/username/myproject/.git’ does not appear to be a git repository
fatal: Could not read from remote repository.
`
stderr: fatal: '/home/username/myproject/.git' does not appear to be a git repository fatal: Could not read from remote repository.
Have you tried if the actual git command succeeds?
git clone file:///home/username/myproject/.git
I suspect that it should be:
git clone file:///home/username/myproject
Cheers,
Paul
The docs for the module don’t specifically mention local repos, but I can’t see anything that would prevent it and it worked for me. I think you just need to remove the trailing .git in the repo specification. Try:
- name: pull the code
git: repo=file:///home/username/myproject/ dest=/var/www
“Is it possible to pull a local repo to a remote machine?”
Not directly.
You could check out locally and use the synchronize module instead.
Sorry, disregard my comment - I misread the question. I missed the reference to the remote machine and was assuming all directories mentioned were local, and the play was being executed with ‘-c local’. This does seem to work, but probably isn’t what is being requested.
Yeah don’t use -c local if just some of your machines are local
You can also set ansible_connection=local as an inventory variable.
Ansible will assume localhost means local if not explicitly defined in inventory.