pstadler / flightplan

Run sequences of shell commands against local and remote hosts.
https://www.npmjs.com/package/flightplan
MIT License
1.82k stars 116 forks source link

Passing flags to rsync #71

Open creynders opened 9 years ago

creynders commented 9 years ago

Maybe I just overlooked it in the documentation, but it's not entirely clear how I could pass flags to rsync when transferring files. E.g. I'd like to copy over symlink contents and not the symlinks themselves, this means I have to be able to set the -L flag.

I've tried:

  transport.transfer( files, plan.runtime.options.dest, {
    exec : {
      "copy-links" : true
    }
  } );

and

  transport.transfer( files, plan.runtime.options.dest, {
      "copy-links" : true
  } );

But to no avail. Is this not possible using the transfer wrapper, do I need to use transport.exec instead?

creynders commented 9 years ago

Just had a deeper look at the code and if I'm not mistaken that's definitely not possible ATM.

creynders commented 9 years ago

Looking at https://github.com/pstadler/flightplan/blob/master/lib/transport/shell.js#L117 I'd say the options are passed to child_process.exec, i.e. it only allows cwd, env, ... however I'd like to suggest to make it symmetrical to the other methods and only pass exec options to child_process.exec. The documentation for transport#exec says:

Options passed with exec will be forwarded to either of these functions.

It would make more sense if it was the same for transport#transfer. And in that case the options object could be used for setting the flags for rsync for instance, something like this:

  transport.transfer( files, plan.runtime.options.dest, {
    "copy-links" : true,
    exclude: ".git",
    exec : {
      cwd: './app'
    }
  } );

Or enveloped for easier plucking:

  transport.transfer( files, plan.runtime.options.dest, {
    transfer:{
      "copy-links" : true,
      exclude: ".git",
    },
    exec : {
      cwd: './app'
    }
  } );

P.S.: obviously it would be even more fantastic if exclude would be parsed in the same way files is.

pstadler commented 9 years ago

I agree, this makes sense.

pstadler commented 8 years ago

Also consider to pass the directory if this makes any sense (see #107)

pstadler commented 8 years ago

Take this into account: #109

kparkov commented 8 years ago

This is more than just an enhancement. I just tried to use local.transfer from a mac to a Ubuntu VPS. Ownership of files were set to mac user and group, which made no sense on the remote. Furthermore, the parent directory (the home dir) were now owned by the local user, which caused SSH to deny any further connections, effectively shutting me out.

I feel this must have been addressed before, and perhaps I am not aware of all option flags?

seybsen commented 8 years ago

@kparkov My workaround was using local.exec instead of local.transfer.

For example: local.exec('rsync -rz --chmod=ugo=rwX --delete --exclude \'shared\' ./dist/ ' + host.username + '@' + host.host + ':' + plan.runtime.options.projectDir + 'htdocs/', {silent: true});

pstadler commented 8 years ago

That's definitely the way to go. rsync is a nightmare to utilize in the way that flightplan does. I'm thinking about replacing it with sftp.

noose commented 8 years ago

Hi @pstadler ! When you plan to do something with that one? In my case I need pass -r parameter because I have ~18k files (semi-size symfony2 project) and when I do find to find proper file names - fly is crashing. I want to pass only dirnames for rsync.

pstadler commented 8 years ago

Pretty busy at the time, but I'm open for pull requests 👍

noose commented 8 years ago

FYI: dirty hack in flightplan.js (in project)

        local._context.hosts.map(function (host) {
            local.exec(
                'rsync -azr --progress --delete-after * .symfony.ini --rsh="ssh -p 22" '
                + host.username + '@' + host.host + ':' + getRemoteDir(plan.runtime.target + '/repo/')
            );
        });```

works 👌