Skip to content

marmorag/chunk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chunk

Ansible Galaxy collection repository.
Easily chunk your array to the size you want.

My use case

While trying to remove objects from a S3 bucket, DeleteObjects directive limit to 1000 objects per call. Since the ListObjectsV2 return the whole list of objects, I needed to chunk my objects list in smaller (in that case 5*1000 objects).

Install


Install it via ansible-galaxy (recommended):

ansible-galaxy collection install marmorag.chunk

Usage


- name: your list
  set_fact:
    your_list: [0,1,2,3,4]

- name: chunk list
  chunk:
    src: "{{ your_list }}"
    size: 2
  register: chunked

- name: process
  command: "echo {{ item }}"
  loop: "{{ chunked.chunks }}"

Output format :

{
    "chunks": [[0,1], [2,3], [4]],
    "changed": true,
    "failed": false
}

Releases

No releases published

Packages

No packages published

Languages