How to pull code from local machine

57 views
Skip to first unread message

9dev...@gmail.com

unread,
Jul 15, 2014, 6:14:23 AM7/15/14
to ansible...@googlegroups.com
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.





Paul Tötterman

unread,
Jul 15, 2014, 9:27:52 AM7/15/14
to ansible...@googlegroups.com
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

mvermaes

unread,
Jul 15, 2014, 11:10:59 AM7/15/14
to ansible...@googlegroups.com
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

Michael DeHaan

unread,
Jul 15, 2014, 11:39:26 AM7/15/14
to ansible...@googlegroups.com
"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.




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/68471377-4f6d-4df9-91f2-f88d2824da48%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Michael Vermaes

unread,
Jul 15, 2014, 11:52:30 AM7/15/14
to ansible...@googlegroups.com
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.


--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/XQXziYe2bnw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.

Michael DeHaan

unread,
Jul 15, 2014, 12:32:53 PM7/15/14
to ansible...@googlegroups.com
Yeah don't use -c local if just some of your machines are local

- hosts: localhost
  connection: local
  tasks:
     - ...

- hosts: other
  tasks:
     - ...

You can also set ansible_connection=local as an inventory variable.

Ansible will assume localhost means local if not explicitly defined in inventory.




Reply all
Reply to author
Forward
0 new messages