ansible: how to copy files from a linked directory - ansible

I have a symbolically linked folder in linux and would like to copy the contents of the folder to a folder on a remote machine. I tried so far using the synchronize command because I am trying to copy the entire tree, folders and files.
When I run the synchronize command, it is creating the folder as a symbolic link and the folder is empty. How can I copy the contents of the symbolic link without creating a symbolic link?

you can use
copy_links: yes
with synchronize module.
"Copy symlinks as the item that they point to (the referent) is copied, rather than the symlink."
synchronize module Ref

Related

Modify source file used for the Copy on the target machine

I'm using the Copy module to transfer a 10G file from my machine to the remote /tmp dir. However, Copy uses an intermediate folder inside home and I need to transfer the file directly to /tmp because /home doesn't have enough space.
Is it possible to control the src path used by the Copy module?
Thanks
In your ansible.cfg change the "remote_tmp" to a location where sufficient space available or you run your playbook as below:
ANSIBLE_REMOTE_TEMP=/dir1/some_dir/large_space/ ansible-playbook copy.yml
Official Documentation for ANSIBLE_REMOTE_TEMP with shell plugin

A simple way to copy file into osx folder

it's possible copy 3 file into different folder in mac osx via some kind of system?
Scenario
one file need to be copied, for example a silverlight app inside
/Application Folder
one file need to be copied, inside /Documents
folder
another inside /picture folder
What can I use?(pkg, a navite osx app) what is the easiest way?
I need that this is an user friendly installation (no shell script)

What is a usual workflow for dealing with shared files with capistrano?

My .csv recreates on every release, and, as I understand, to keep its data unchanged between deploys I need to put it in /shared directory and simlink to it from my deploy.rb.
Is this the right route? (I have this question because I don't seem to find much info on how to do this with respect to, eg, databases, for some reason. /shared directory is mostly used for .conf files and paperclip-like directories).
When using capistrano, your application code will be "uploaded" to some directory on the server. Capistrano uses this structure:
/path_to_folder:
current - symlink to the directory with the current release
releases - contains all kept releases
shared - files that should persist between releases
So to your question - copy the .csv file somewhere into "shared" directory and then in the config/deploy.rb add this:
namespace :deploy do
task :create_symlinks do
run "ln -s #{shared_path}/something.csv #{latest_release}/db/something.csv"
end
end
after 'deploy:update_code', 'deploy:create_symlinks'
Replace "something" with the file name that you copied. You can also put the csv file into some directory under "shared" if you want to, I'd use "db" in this case. If you do so, don't forget to update path in the symlink.

Extra Copy of New Rsync Files

I am attempting to mirror a directory on a remote server using rsync. However, I would like a copy of all newly created files to be stored in a separate directory on the local machine.
For example, if a new file is added on the remote server, I would like it to mirror regularly (for example, to ~/mirror), but save an additional copy of only the new file in another folder, (for example, ~/staging). To be clear, only the new files should appear in staging.
My first approach was to allow rsync to update the timestamps, and then use that to make a copy. However, I would now like to preserve timestamps.
Can anyone provide ideas on a simple approach? I am open to use of additional utilities other than rsync.
You might consider making hardlinks in the extra directory.
ln --force --target-directory=~/staging ~/mirror/*
Edit:
If this is a Linux system, incron will trigger on inotify events and would allow you to make copies of files as they are added to a directory you specify.

File security attributes getting screwed up on file copy

I've a windows service that updates our product. It copies the product files into a temp directory, usually "C:\Windows\Temp", patches the binaries, and then uses MoveFileEx to copy the files back to the install directory on a reboot, usually "C:\Program Files\Product". The files in the install directory are inheriting their security attributes from the parent folder. After the copy, patch, and reboot, the files in the install directory are missing some ACLs. Specifically the files don't have the ACL for the Users group anymore so users can no longer run the program after the reboot.
Can anyone explain whats going on here? It seems that copying from the install directory to the temp directory, the files inherit the ACLs of the temp directory. On the MoveFileEx/Reboot, though, the files only inherit the ACLs that both the install and temp directories have in common.
In Windows if you copy a file the file takes on the ACLs of the destination directory. If you move a file the ACL goes with it overriding any it might inherit from that directory. I'm not sure how MoveFileEx might operate differently on a file.
The temp directory is usually located under the user profile (both %TMP% and %TEMP% usually point here) so copying files here will have permissions for that user. Moving those files to the program files directory will take only that users rights with them and therefore only runnable by the installing user.
One potential workaround is to patch copies of the files with-in the same directory but with different names. After the reboot, the patched versions could be swapped in. Alternatively, do a reboot first and then patch them in-place, and just back them up to the temp directory in the event a manual rollback is required.
If you really want to move them to a different location, creating a temp folder in the same place as the files to be patched would help the permissions stay the same assuming the directory is using inherited permissions.

Resources