To share the labour of copying and processing lists of repositories on remote systems, I want to dynamically assign IPs to folders.
Goal is to have the following:
app/_data/repo-list-0 copies to 10.0.0.1
app/_data/repo-list-1 copies to 10.0.0.2
app/_data/repo-list-2 copies to 10.0.0.3
etc..
# ansible/hosts
10.0.0.1
10.0.0.2
10.0.0.3
etc..
my source structure is like so where each directory contains ~10 json files
app/_data/repo-list-0/repo-list-[1-10].json
app/_data/repo-list-1/repo-list-[2-20].json
app/_data/repo-list-2/repo-list-[3-30].json
etc..
Copy Data Task
# ansible/playbooks/copy_data.yml
---
  - name: Copy Data
    hosts: all
    user: ec2-user
    vars:
      app: ...
    tasks:
     - name: copy repo-range to hosts
       copy:
         src: "app/_data/repo-list-0"
         dest: "{{ ansible_env.HOME }}/{{ app }}/_data"
       when: inventory_hostname == "10.0.0.1"
     - name: copy repo-range to hosts
       copy:
         src: "app/_data/repo-list-1"
         dest: "{{ ansible_env.HOME }}/{{ app }}/_data"
       when: inventory_hostname == "10.0.0.2"
     - name: copy repo-range to hosts
       copy:
         src: "app/_data/repo-list-2"
         dest: "{{ ansible_env.HOME }}/{{ app }}/_data"
       when: inventory_hostname == "10.0.0.3"
etc..
When the entire application is launched, new instances are deployed in AWS, and I have to manually modify each IP address. This is why I dynamically transfer the data.
When the host changed, I attempted to make a global variable and increment the source.