ansistrano / deploy

Ansible role to deploy scripting applications like PHP, Python, Ruby, etc. in a capistrano style
https://ansistrano.com
MIT License
2.37k stars 343 forks source link

git subtree sync fails for some reason #252

Closed pzaj2 closed 7 years ago

pzaj2 commented 7 years ago

Hi

I have this huge issue with anistrano. I couldn't find any answers related to it. Now I have idea why this is happening, to be honest I'm not sure what this task is meant to accomplish. I'm trying to deploy to vagrant box. This is error I'm getting:

{
   "changed":true,
   "cmd":"{\n git ls-files -z --with-tree=\"develop\" | tr '\\0' '\\n';\n git submodule foreach --recursive --quiet 'git ls-files -z --with-tree=\"$sha1\" | tr \"\\0\" \"\\n\" | sed \"s#^#$path/#\"';\n } | grep \"^$prefix\" | sed \"s#^$prefix/##\" | rsync -a --files-from=- \"./$prefix/\" www/develop/releases/20170915182027Z/",
   "delta":"0:00:00.447794",
   "end":"2017-09-15 18:20:52.020742",
   "failed":true,
   "rc":11,
   "start":"2017-09-15 18:20:51.572948",
   "stderr":"rsync: mkdir \"/home/vagrant/www/develop/repo/www/develop/releases/20170915182027Z\" failed: No such file or directory (2)\nrsync error: error in file IO (code 11) at main.c(674) [Receiver=3.1.1]",
   "stderr_lines":[
      "rsync: mkdir \"/home/vagrant/www/develop/repo/www/develop/releases/20170915182027Z\" failed: No such file or directory (2)",
      "rsync error: error in file IO (code 11) at main.c(674) [Receiver=3.1.1]"
   ],
   "stdout":"",
   "stdout_lines":[

   ]
}

My vars are:

    ansistrano_deploy_from: "{{ playbook_dir }}"
    ansistrano_deploy_to: "www/{{ branch }}"
    ansistrano_keep_releases: 3
    ansistrano_deploy_via: "git"
    ansistrano_git_repo: "git@gitlab.com:<acc>/<repo>.git"
    ansistrano_git_branch: "{{ branch }}"

and I only use a single role at this moment -

      - role: cbrunnkvist.ansistrano-symfony-deploy
ricardclau commented 7 years ago

It looks like there is an IO problem while trying to write files in your vagrant box disk

This particular command rsyncs from a shared directory where we run git commands to your final releases folder

It does not look like anything related to ansible or ansistrano but a problem in the virtual machine itself. Hard to diagnose better without further info.

Have you ever been able to deploy anything at all? Is the virtual disk full?

pzaj2 commented 7 years ago

@ricardclau I see, well, I wasn't able to deploy anything BUT, the repo has been pulled and written to /home/vagrant/www/develop/repo. I also have releases there (/home/vagrant/www/develop/releases). One thing I noticed is the path for mkdir command, it doesn't seem to make sense. Perhaps that's the problem?

I said I wasn't able to deploy anything, but that's not correct - I managed to make ansible install nginx, php, mysql, imagemagick, node.js.

As for my vagrant box, I think there's enough space:

vagrant@vagrant:~$ df -h
Filesystem                    Size  Used Avail Use% Mounted on
udev                          225M     0  225M   0% /dev
tmpfs                          49M  1.9M   47M   4% /run
/dev/mapper/vagrant--vg-root   38G  1.9G   35G   6% /
tmpfs                         245M     0  245M   0% /dev/shm
tmpfs                         5.0M     0  5.0M   0% /run/lock
tmpfs                         245M     0  245M   0% /sys/fs/cgroup
/dev/sda1                     472M   58M  391M  13% /boot
vagrant                       135G   84G   52G  62% /vagrant
vagrant_data                  135G   84G   52G  62% /vagrant_data
tmpfs                          49M     0   49M   0% /run/user/1000
ricardclau commented 7 years ago

Ah yeah, I see the problem

ansistrano_deploy_to: "www/{{ branch }}"

This would be relative to the playbook, probably not exactly where you want to put it

Try it with

ansistrano_deploy_to: "/home/vagrant/www/{{ branch }}"

pzaj2 commented 7 years ago

@ricardclau hmm, that makes sense. Although I'm quite surprised, since my playbook is on local machine... why would my local machine (the one playbook is run at) have any part in this? Is ansistrano_deploy_from part of that too? I tried to understand the need for it, but I can't find any use of that. Anyway, thanks for help, I will try that in the meantime.

ricardclau commented 7 years ago

deploy_from is not used in the git strategy, it is used in strategies like copy, rsync, etc... deploy_to is a path in the server you deploy to and either you put an absolute path or it will be relative to where the command is executed. If you check that particular one (https://github.com/ansistrano/deploy/blob/master/tasks/update-code/git.yml#L58:L70), there is a

args:
    chdir: "{{ ansistrano_deploy_to }}/repo/"

Which is exactly what is happening to you

Mistery solved!