 - name: Create record to {{domaine_ext}} and proxy through Cloudflare's network
   hosts: localhost
   connection: local
   tasks:
      - name: CNAME add
        community.general.cloudflare_dns:
          record: "{{ item }}"
          zone: "{{domaine_ext}}"
          type: CNAME
          value: server.{{domaine_ext}}
          proxied: no
          account_email: 'dvsthibaut@gmail.com'
          account_api_key: '75d6440ffb38a5ce7a99bf0e10ec720d1737a'
          state: present
        when: m_cloudflare_add_cname is defined
        with_items:
        - "{{ m_cloudflare_add_cname }}"

      - name: Create TXT record with value to allow OVH
        community.general.cloudflare_dns:
          domain: "{{ domaine_ext }}"
          record: "{{ domaine_ext }}"
          type: TXT
          value: v=spf1 +a +mx include:mx.ovh.com ~all
          solo: true
          account_email: 'dvsthibaut@gmail.com'
          account_api_key: '75d6440ffb38a5ce7a99bf0e10ec720d1737a'
          state: present

      - name: CNAME Clean
        community.general.cloudflare_dns:
          record: "{{ item }}"
          zone: "{{domaine_ext}}"
          type: CNAME
          value: server.{{domaine_ext}}
          proxied: no
          account_email: 'dvsthibaut@gmail.com'
          account_api_key: '75d6440ffb38a5ce7a99bf0e10ec720d1737a'
          state: absent
        when: m_cloudflare_add_cname_clean is defined
        with_items:
        - "{{ m_cloudflare_add_cname_clean }}"