---
- name: Ensure CloudFlare A record is updated
  cloudflare_dns:
    zone: "{{ hosts[item].dns_zone }}"
    record: "{{ hosts[item].dns_record }}"
    type: A
    value: "{{ hosts[item].ip_address }}"
    solo: true
    state: present
    account_email: "{{ cloudflare_email }}"
    account_api_token: "{{ cloudflare_api_token }}"
  when:
    - hosts[item].dns_zone is defined
    - hosts[item].dns_record is defined
    - hosts[item].ip_address is defined
