英文:
Ansible amazon.aws.s3_object download object with wildcard or pattern?
问题
I'm using an Ansible playbook to download file(s) from AWS S3. The problem is the file name can change so I need to find it with a wildcard. When I tried including a wildcard in the path it threw a "no object found" error.
我正在使用Ansible playbook从AWS S3下载文件。问题是文件名可能会更改,所以我需要使用通配符找到它。当我尝试在路径中包含通配符时,它抛出了“未找到对象”的错误。
I tried the prefix
parameter, but it threw an error that object
is required. I looked at the s3_object
documentation as well as s3_object_info
and I can't find anything about using wild cards.
我尝试了prefix
参数,但它抛出了要求object
的错误。我查看了s3_object
文档以及s3_object_info
,但找不到关于使用通配符的信息。
Is this possible, or is there a better way to accomplish it?
这是否可能,或者有没有更好的方法来实现这个目标?
英文:
I'm using an Ansible playbook to download file(s) from AWS S3. The problem is the file name can change so I need to find it with a wildcard. When I tried including a wildcard in the path it threw a "no object found" error.
I tried the prefix
parameter, but it threw an error that object
is required. I looked at the s3_object
documentation as well as s3_object_info
and I can't find anything about using wild cards.
Is this possible, or is there a better way to accomplish it?
答案1
得分: 0
我最终使用 list
作为 mode
参数,以获取具有指定 prefix
的项目列表,然后在第二个任务中下载了这些项目:
- name: 获取项目列表
amazon.aws.s3_object:
bucket: "{{ bucket }}"
region: "{{ region }}"
prefix: /object/path/prefix
object: /object/path
mode: list
register: files
- name: 下载项目
amazon.aws.s3_object:
bucket: "{{ bucket }}"
region: "{{ region }}"
object: "{{ item }}"
mode: get
loop: "{{ files.s3_keys }}"
英文:
I ended up using list
for the mode
parameter to get a list of items with a specified prefix
, then in a second task downloaded those items:
- name: Get list of items
amazon.aws.s3_object:
bucket: "{{ bucket }}"
region: "{{ region }}"
prefix: /object/path/prefix
object: /object/path
mode: list
register: files
- name: Download items
amazon.aws.s3_object:
bucket: "{{ bucket }}"
region: "{{ region }}"
object: "{{ item }}"
mode: get
loop: "{{ files.s3_keys }}"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论