Ansible loop control

How has it taken me this long?! Sometimes I feel tremendously silly for overlooking the simplest of answers.

I've used loop_control to change the default loop variable, but I've never noticed loop_control can also change the loop label. This is a game changer! Previously, I've mangled data objects to trim them down, or just set no_log: true when loops get to chatty, but all that extra effort was for naught. There's a far simpler answer!

- name: query AWS inventory
  tags: aws
  ec2_instance_info:
    region: "{{ aws_region }}"
    filters:
      instance-state-name: running
      "tag:Platform":
        - Some-Platform
        - Some-Other-Platform
  register: res_ec2_info
- name: Add controller to hosts
  tags: aws
  changed_when: false
  no_log: true #Very chatty with little benefit.
  add_host:
    name: "{{ item.tags.Name |lower |regex_replace('^(.+?) .+', '\\1') }}"
    groups: runtime
    ansible_host : "{{ item.private_ip_address }}"
    platform     : "{{ item.tags.Platform }}"
  loop: "{{ res_ec2_info.instances }}"

See – not ideal. I just shut off the log because it was too verbose as it iterated over ec2 instances and spammed out all their details. Consider the above in comparison to the below!

- name: query AWS inventory
  tags: aws
  ec2_instance_info:
    region: "{{ aws_region }}"
    filters:
      instance-state-name: running
      "tag:Platform":
        - Some-Platform
        - Some-Other-Platform
  register: res_ec2_info
- name: Add controller to hosts
  tags: aws
  changed_when: false
  loop_control:
    label: "{{ item.tags.Name }}"
  add_host:
    name: "{{ item.tags.Name |lower |regex_replace('^(.+?) .+', '\\1') }}"
    groups: runtime
    ansible_host : "{{ item.private_ip_address }}"
    platform     : "{{ item.tags.Platform }}"
  loop: "{{ res_ec2_info.instances }}"

Reference