Ansible amazon.aws.s3_object 下载带通配符或模式的对象?

huangapple go评论68阅读模式
英文:

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 }}"

huangapple
  • 本文由 发表于 2023年5月18日 13:07:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76277892.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定