file-downloaded
Example:
# Download a file into /tmp - file-downloaded: url: https://frkl.io/images/frkl-logo-black.svg dest: /tmp/logo.svg
Description
Download a file, create intermediate destination directories and a user/group if necessary.
If no 'dest' option is provided, the file will be downloaded into '~/Downloads'.
This uses the Ansible get_url module, check it's help for more details.
Resources
Variables
Name | Type | Default | Description |
---|---|---|---|
|
string | -- | The url to download. Required |
|
string | ~/Downloads/ | The destination file (or directory). |
|
boolean | False | Whether to force download/overwrite the target. |
|
string | -- | The group of the target file. |
|
string | -- | The mode the file should have, in octal (e.g. 0755). |
|
string | -- | The owner of the target file. |
Examples
Example 1
Download a file into /tmp
Code
- file-downloaded: url: https://frkl.io/images/frkl-logo-black.svg dest: /tmp/logo.svg
Example 2
Download a file into ~/Downloads
Code
- file-downloaded: url: https://frkl.io/images/frkl-logo-black.svg
Example 3
Download a file, change owner.
Code
- file-downloaded: url: https://frkl.io/images/frkl-logo-black.svg dest: /tmp/logo.svg owner: freckles
Description
The user 'freckles' will be create if not availble on the sytem.
Code
doc: short_help: Download a file. help: | Download a file, create intermediate destination directories and a user/group if necessary. If no 'dest' option is provided, the file will be downloaded into '~/Downloads'. This uses the [Ansible get_url module](https://docs.ansible.com/ansible/latest/modules/get_url_module.html), check it's help for more details. references: '``get_url`` Ansible module': https://docs.ansible.com/ansible/latest/modules/get_url_module.html examples: - title: Download a file into /tmp vars: url: https://frkl.io/images/frkl-logo-black.svg dest: /tmp/logo.svg - title: Download a file into ~/Downloads vars: url: https://frkl.io/images/frkl-logo-black.svg - title: Download a file, change owner. desc: | The user 'freckles' will be create if not availble on the sytem. vars: url: https://frkl.io/images/frkl-logo-black.svg dest: /tmp/logo.svg owner: freckles args: # become: # doc: # short_help: Whether to use root privileges to do the downloading and saving. # type: boolean # default: false # required: false # cli: # is_flag: true url: doc: short_help: The url to download. type: string required: true cli: nargs: 1 metavar: URL param_type: argument dest: doc: short_help: The destination file (or directory). type: string required: false default: ~/Downloads/ cli: metavar: DEST show_default: true owner: doc: short_help: The owner of the target file. type: string required: false empty: true cli: metavar: USER group: doc: short_help: The group of the target file. type: string required: false empty: false cli: metavar: GROUP force: doc: short_help: Whether to force download/overwrite the target. type: boolean required: false default: false cli: is_flag: true mode: doc: short_help: The mode the file should have, in octal (e.g. 0755). type: string required: false cli: metavar: MODE meta: tags: - download - web - featured-frecklecutable frecklets: - folder-exists: path: "{%:: if dest.endswith('/') ::%}{{:: dest ::}}{%:: else ::%}{{:: dest |\ \ dirname ::}}{%:: endif ::%}" owner: '{{:: owner ::}}' group: '{{:: group ::}}' - task: become: '{{:: owner | true_if_not_empty ::}}' frecklet: name: get_url type: ansible-module desc: short: "download '{{:: url ::}}' -> '{{:: dest ::}}'" long: | Download '{{:: url ::}}' to {{:: dest ::}}. {%:: if owner ::%}Change the downloaded files owner to be '{{:: owner ::}}'.{%:: endif ::%}{%:: if group ::%}Change the group for the file to be '{{:: group ::}}'.{%:: endif ::%} {%:: if mode ::%}Change the files mode to '{{:: mode ::}}'.{%:: endif ::%} {%:: if owner ::%}Use root permissions to do all this.{%:: endif ::%} references: "'get_url' Ansible module": https://docs.ansible.com/ansible/latest/modules/get_url_module.html properties: idemportent: true # we assume the remote file doesn't change elevated: '{{:: owner | true_if_not_empty ::}}' internet: true vars: url: '{{:: url ::}}' dest: '{{:: dest ::}}' owner: '{{:: owner ::}}' group: '{{:: group ::}}' force: '{{:: force ::}}' mode: '{{:: mode ::}}'
frecklecute file-downloaded --help Usage: frecklecute file-downloaded [OPTIONS] URL Download a file, create intermediate destination directories and a user/group if necessary. If no 'dest' option is provided, the file will be downloaded into '~/Downloads'. This uses the [Ansible get_url module](https://docs.ansible.com/ansible/la test/modules/get_url_module.html), check it's help for more details. Options: --dest DEST The destination file (or directory). --force / --no-force Whether to force download/overwrite the target. --group GROUP The group of the target file. --mode MODE The mode the file should have, in octal (e.g. 0755). --owner USER The owner of the target file. --help Show this message and exit.
# -*- coding: utf-8 -*- # # module path: pycklets.file_downloaded.FileDownloaded # from dataclasses import dataclass from pyckles import AutoPycklet from typing import * # noqa @dataclass class FileDownloaded(AutoPycklet): """Download a file, create intermediate destination directories and a user/group if necessary. If no 'dest' option is provided, the file will be downloaded into '~/Downloads'. This uses the [Ansible get_url module](https://docs.ansible.com/ansible/latest/modules/get_url_module.html), check it's help for more details. Args: dest: The destination file (or directory). force: Whether to force download/overwrite the target. group: The group of the target file. mode: The mode the file should have, in octal (e.g. 0755). owner: The owner of the target file. url: The url to download. """ FRECKLET_ID = "file-downloaded" dest: str = None force: bool = None group: str = None mode: str = None owner: str = None url: str = None def __post_init__(self): super(FileDownloaded, self).__init__(var_names=["dest", "force", "group", "mode", "owner", "url"]) frecklet_class = FileDownloaded
# -*- coding: utf-8 -*- # # module path: pycklets.file_downloaded.FileDownloaded # from pyckles import AutoPycklet class FileDownloaded(AutoPycklet): """Download a file, create intermediate destination directories and a user/group if necessary. If no 'dest' option is provided, the file will be downloaded into '~/Downloads'. This uses the [Ansible get_url module](https://docs.ansible.com/ansible/latest/modules/get_url_module.html), check it's help for more details. Args: dest: The destination file (or directory). force: Whether to force download/overwrite the target. group: The group of the target file. mode: The mode the file should have, in octal (e.g. 0755). owner: The owner of the target file. url: The url to download. """ FRECKLET_ID = "file-downloaded" def __init__(self, dest="~/Downloads/", force=None, group=None, mode=None, owner=None, url=None): super(FileDownloaded, self).__init__(var_names=["dest", "force", "group", "mode", "owner", "url"]) self._dest = dest self._force = force self._group = group self._mode = mode self._owner = owner self._url = url @property def dest(self): return self._dest @dest.setter def dest(self, dest): self._dest = dest @property def force(self): return self._force @force.setter def force(self, force): self._force = force @property def group(self): return self._group @group.setter def group(self, group): self._group = group @property def mode(self): return self._mode @mode.setter def mode(self, mode): self._mode = mode @property def owner(self): return self._owner @owner.setter def owner(self, owner): self._owner = owner @property def url(self): return self._url @url.setter def url(self, url): self._url = url frecklet_class = FileDownloaded