vmware.ansible-role-assets
ansible-role-assets
This is an Ansible playbook designed to download file assets automatically and, if needed, host them on a local HTTP server.
It is a part of the Chaperone project.
The assets are downloaded once and saved locally. They won't be downloaded again unless the checksum changes or the file is deleted.
Requirements
- A directory for downloads that the ansible_ssh_user can create and write to
- A valid dictionary (
dict
) of assets - If you want to host the assets via HTTP, make sure the ansible role
jdauphant.nginx
is available and setassets_http_hosted
to True
Role Variables
# Set to True to download files, or False to skip downloading (default is False)
download_files: False
# The directory where the downloaded assets will be stored.
downloads_dir: /var/www/html/downloads
# Timeout (in seconds) for URL requests
downloads_timeout: 10
# Set to False if SSL certificates should not be validated.
# Only use this on sites you control with self-signed certificates.
assets_validate_certs: True
# A dictionary of assets to download.
# The keys are the names of the files that will be downloaded.
# Each entry includes a checksum and a valid URL for the asset.
# Example:
# assets:
# google-image.png:
# description: google image
# checksum: 26f471f6ebe3b11557506f6ae96156e0a3852e5b
# url: https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png
# index.html:
# description: "descriptive use only, not mandatory"
# checksum: "3af37af6ebe3b11557506f6ae96156e0a381211e"
# url: "http://some.url/to/a/file"
assets: {}
# Should we set up a web server to host the assets for future downloads?
assets_http_hosted: False
# The port for the HTTP server
assets_http_port: 8484
Example playbook
---
- hosts: apache_servers
sudo: True
roles:
- assets
vars:
download_files: True
assets:
Notice.txt:
description: notice.txt
checksum: e6b8bfe20303703e30acf9e67d012060
url: "https://github.com/vmware/photon-controller/releases/download/v1.1.1/Notice.txt"
validate_certs: False
logo.png:
description: google logo
checksum: 80fa4bcab0351fdccb69c66fb55dcd00
url: "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"
validate_certs: False
License and Copyright
Copyright © 2015-2017 VMware, Inc. All Rights Reserved.
This code is licensed under both Apache License 2.0 and GPLv3.
You can find a copy of the licenses at: