You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
Hi guys,
I'm quite new to Ansible and would like to perform the following in an idempotent fashion. I would basically like to minimise the number of downloads I need to perform from the web for certain file assets, so my plan is to download them once to an asset server and then retrieve them from there for all the target hosts in our cluster.
As far as I know the flow would go something like this.
# does file exist on target host
# if yes exit
# if no retrieve from asset server
# does file exist on asset server
# if not download from web to asset server
# copy file from asset server to target host
Are there any modules I could use to do this or are there any other recommendations on best practices for this scenario?
Any help would be appreciated.
Cheers,
Jason
James Martin
unread,
Feb 28, 2014, 10:12:40 AM2/28/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
Sounds like you'd have an asset server role that gets executed against
the asset server that collects all the assets, followed by a role that
gets executed against "target host". Take a look at the get_url
module for getting files from the web to your asset server, and
get_url or synchronize method to pull them from your asset server to
your target host.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
the copy module will also check if the file exists on the target server and not copy it if it is already there... CAVEAT, if you intend to modify the file on the target server then it will be replaced with the original if any of these modules detect that it is different. (i.e it will checksum the two files and only if they don't match will it copy the source over.
Adam
Adam
bryan hunt
unread,
Feb 28, 2014, 5:34:03 PM2/28/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
I'm always in favor of using the right tool for the job, is this not the sort of task at which rsync excels? An rsync module perhaps?
Brian Coca
unread,
Feb 28, 2014, 5:47:12 PM2/28/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
the syncronize module is an rsync wrapper.
Jason Sheedy
unread,
Mar 1, 2014, 5:19:45 AM3/1/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
Thanks for the feedback guys. I think, as James suggested, the simplest way would be to download all the assets in a separate role.
That sayid, I was hoping to download / sync to the asset server in an addhock fashion in various roles. To do that I think it would be easier to write a custom module than piecing together a long list of calls to standard modules every time I need an asset. As an example, I'm thinking something like this would be good:
tasks
- name: download asset and sync to asset server url: http://www.some.com/asset.tar.gz dest: /var/assets asset_host: ro...@my.asset.server
This would download the asset if if doesn't exist on the asset server and syncronise with the local file system. The dest directory could be mirrored between the asset server and the host machine.
Dmitry Horbach
unread,
Mar 2, 2014, 5:00:49 AM3/2/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
Custom module will work best in your case.
We are using the same approach but with more sources of asset. This module is basically used in every software installation role and separate role is not an option.
1) Check if file is already present in destination directory
2) Download from /opt/repository/app (mount of software repository for installations with Vagrant)
Drawback - none of your roles can be shared in Ansible Galaxy.
Jason Sheedy
unread,
Mar 2, 2014, 2:41:57 PM3/2/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
Thanks Dmitry. Hosting it on s3 is a great idea. We may be able to use that with get_url as a short term solution. The download speed is the main issue and we get great speeds from s3.