Ansible 下载大文件
Ansible Downloading large files
我正在尝试从我的网站下载备份文件。我的剧本结构如下:
site_vars.yml
保存我的变量:
website_backup_download:
- name: ftp://username:userpassword@ftp.mysite1.com/backups/mysite1backup.tgz
path: mysites/backups/www
- name: ftp://username:userpassword@ftp.mysite2.com/backups/mysite2backup.tgz
path: mysites/backups/www
- name: ftp://username:userpassword@ftp.mysite3.com/backups/mysite3backup.tgz
path: mysites/backups/www
- 实际下载程序手册:
# Downloader
task:
- name: Download backups from FTP's
get_url:
url: "{{ item.name }}"
dest: "{{ item.path }}"
mode: 0750
no_log: false
ignore_errors: True
with_items:
- "{{ website_backup_download }}"
这实际上工作得很好,但问题始于备份文件很大,任务需要 运行 直到备份文件被正确下载。
我无法重复完成一个或多个未完成文件的任务。 :)
尝试过另一种解决方案,这对单个站点也很有效,但不能用于多个下载:(
- name: Download backups
command: wget -c ftp://username:userpassword@ftp.mysite1.com/backups/mysite1backup.tgz
args:
chdir: "{{ down_path }}"
warn: false
register: task_result
retries: 10
delay: 1
until: task_result.rc == 0
ignore_errors: True
感谢您的帮助。
我已经通过添加timeout parameter for runtime, additionally added the until参数修改了任务,等待下载完成,并重试并延迟参数重试直到它满足条件。
目前有效:)
谢谢大家。
# Downloader
task:
- name: Download backups from FTP's
get_url:
url: "{{ item.name }}"
dest: "{{ item.path }}"
mode: 0750
timeout: 1800
retries: 10
delay: 3
register: result
until: result is succeeded
no_log: false
ignore_errors: True
with_items:
- "{{ website_backup_download }}"
我正在尝试从我的网站下载备份文件。我的剧本结构如下:
site_vars.yml
保存我的变量:
website_backup_download:
- name: ftp://username:userpassword@ftp.mysite1.com/backups/mysite1backup.tgz
path: mysites/backups/www
- name: ftp://username:userpassword@ftp.mysite2.com/backups/mysite2backup.tgz
path: mysites/backups/www
- name: ftp://username:userpassword@ftp.mysite3.com/backups/mysite3backup.tgz
path: mysites/backups/www
- 实际下载程序手册:
# Downloader
task:
- name: Download backups from FTP's
get_url:
url: "{{ item.name }}"
dest: "{{ item.path }}"
mode: 0750
no_log: false
ignore_errors: True
with_items:
- "{{ website_backup_download }}"
这实际上工作得很好,但问题始于备份文件很大,任务需要 运行 直到备份文件被正确下载。
我无法重复完成一个或多个未完成文件的任务。 :)
尝试过另一种解决方案,这对单个站点也很有效,但不能用于多个下载:(
- name: Download backups
command: wget -c ftp://username:userpassword@ftp.mysite1.com/backups/mysite1backup.tgz
args:
chdir: "{{ down_path }}"
warn: false
register: task_result
retries: 10
delay: 1
until: task_result.rc == 0
ignore_errors: True
感谢您的帮助。
我已经通过添加timeout parameter for runtime, additionally added the until参数修改了任务,等待下载完成,并重试并延迟参数重试直到它满足条件。
目前有效:) 谢谢大家。
# Downloader
task:
- name: Download backups from FTP's
get_url:
url: "{{ item.name }}"
dest: "{{ item.path }}"
mode: 0750
timeout: 1800
retries: 10
delay: 3
register: result
until: result is succeeded
no_log: false
ignore_errors: True
with_items:
- "{{ website_backup_download }}"