Fix cloudflare_dns proxied change detection
diff --git a/lib/ansible/modules/net_tools/cloudflare_dns.py b/lib/ansible/modules/net_tools/cloudflare_dns.py
index f3fcc1fffe1f88..97e22082267626 100644
--- a/lib/ansible/modules/net_tools/cloudflare_dns.py
+++ b/lib/ansible/modules/net_tools/cloudflare_dns.py
@@ -557,6 +557,8 @@ def ensure_dns_record(self, **kwargs):
                 do_update = True
             if (params['priority'] is not None) and ('priority' in cur_record) and (cur_record['priority'] != params['priority']):
                 do_update = True
+            if ('proxied' in new_record) and ('proxied' in cur_record) and (cur_record['proxied'] != params['proxied']):
+                do_update = True
             if ('data' in new_record) and ('data' in cur_record):
                 if (cur_record['data'] != new_record['data']):
                     do_update = True
diff --git a/test/legacy/roles/test_cloudflare_dns/tasks/a_record.yml b/test/legacy/roles/test_cloudflare_dns/tasks/a_record.yml
index 6f52bf9992b712..6ee621b9c2a6cb 100644
--- a/test/legacy/roles/test_cloudflare_dns/tasks/a_record.yml
+++ b/test/legacy/roles/test_cloudflare_dns/tasks/a_record.yml
@@ -178,3 +178,153 @@
     that:
       - cloudflare_dns is successful
       - cloudflare_dns is not changed
+
+- name: "Test: proxiable A record creation"
+  cloudflare_dns:
+    account_email: "{{ cloudflare_email }}"
+    account_api_token: "{{ cloudflare_api_token }}"
+    zone: "{{ cloudflare_zone }}"
+    record: "{{ cloudflare_dns_record  }}"
+    type: A
+    value: 192.0.2.47
+    ttl: 150
+  register: cloudflare_dns
+
+- name: "Validate: proxiable A record creation"
+  assert:
+    that:
+      - cloudflare_dns is successful
+      - cloudflare_dns is changed
+      - cloudflare_dns.result.record.content == '192.0.2.47'
+      - cloudflare_dns.result.record.proxiable == true
+      - cloudflare_dns.result.record.ttl == 150
+      - cloudflare_dns.result.record.type == 'A'
+      - cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
+      - cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
+
+- name: "Test: proxiable A record creation succeeded"
+  cloudflare_dns:
+    account_email: "{{ cloudflare_email }}"
+    account_api_token: "{{ cloudflare_api_token }}"
+    zone: "{{ cloudflare_zone }}"
+    record: "{{ cloudflare_dns_record  }}"
+    type: A
+    value: 192.0.2.47
+    ttl: 150
+  register: cloudflare_dns
+
+- name: "Validate: proxiable A record creation succeeded"
+  assert:
+    that:
+      - cloudflare_dns is successful
+      - cloudflare_dns is not changed
+
+- name: "Test: Enable A record proxied status"
+  cloudflare_dns:
+    account_email: "{{ cloudflare_email }}"
+    account_api_token: "{{ cloudflare_api_token }}"
+    zone: "{{ cloudflare_zone }}"
+    record: "{{ cloudflare_dns_record  }}"
+    type: A
+    value: 192.0.2.47
+    proxied: yes
+  register: cloudflare_dns
+
+- name: "Validate: Enable A record proxied status"
+  assert:
+    that:
+      - cloudflare_dns is successful
+      - cloudflare_dns is changed
+      - cloudflare_dns.result.record.content == '192.0.2.47'
+      - cloudflare_dns.result.record.proxied == true
+      - cloudflare_dns.result.record.type == 'A'
+      - cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
+      - cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
+
+- name: "Test: Enable A record proxied status succeeded"
+  cloudflare_dns:
+    account_email: "{{ cloudflare_email }}"
+    account_api_token: "{{ cloudflare_api_token }}"
+    zone: "{{ cloudflare_zone }}"
+    record: "{{ cloudflare_dns_record  }}"
+    type: A
+    value: 192.0.2.47
+    proxied: yes
+  register: cloudflare_dns
+
+- name: "Validate: Enable A record proxied status succeeded"
+  assert:
+    that:
+      - cloudflare_dns is successful
+      - cloudflare_dns is not changed
+
+- name: "Test: Disable A record proxied status"
+  cloudflare_dns:
+    account_email: "{{ cloudflare_email }}"
+    account_api_token: "{{ cloudflare_api_token }}"
+    zone: "{{ cloudflare_zone }}"
+    record: "{{ cloudflare_dns_record  }}"
+    type: A
+    value: 192.0.2.47
+    proxied: no
+  register: cloudflare_dns
+
+- name: "Validate: Enable A record proxied status"
+  assert:
+    that:
+      - cloudflare_dns is successful
+      - cloudflare_dns is changed
+      - cloudflare_dns.result.record.content == '192.0.2.47'
+      - cloudflare_dns.result.record.proxied == false
+      - cloudflare_dns.result.record.type == 'A'
+      - cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
+      - cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
+
+- name: "Test: Disable A record proxied status succeeded"
+  cloudflare_dns:
+    account_email: "{{ cloudflare_email }}"
+    account_api_token: "{{ cloudflare_api_token }}"
+    zone: "{{ cloudflare_zone }}"
+    record: "{{ cloudflare_dns_record  }}"
+    type: A
+    value: 192.0.2.47
+    proxied: no
+  register: cloudflare_dns
+
+- name: "Validate: Enable A record proxied status succeeded"
+  assert:
+    that:
+      - cloudflare_dns is successful
+      - cloudflare_dns is not changed
+
+- name: "Test: Full A record deletion"
+  cloudflare_dns:
+    account_email: "{{ cloudflare_email }}"
+    account_api_token: "{{ cloudflare_api_token }}"
+    zone: "{{ cloudflare_zone }}"
+    record: "{{ cloudflare_dns_record  }}"
+    type: A
+    state: absent
+  register: cloudflare_dns
+
+- name: "Validate: Full A record deletion"
+  assert:
+    that:
+      - cloudflare_dns is successful
+      - cloudflare_dns is changed
+
+- name: "Test: Full A record deletion succeeded"
+  cloudflare_dns:
+    account_email: "{{ cloudflare_email }}"
+    account_api_token: "{{ cloudflare_api_token }}"
+    zone: "{{ cloudflare_zone }}"
+    record: "{{ cloudflare_dns_record  }}"
+    type: A
+    state: absent
+  register: cloudflare_dns
+
+- name: "Validate: Full A record deletion succeeded"
+  assert:
+    that:
+      - cloudflare_dns is successful
+      - cloudflare_dns is not changed
diff --git a/test/legacy/roles/test_cloudflare_dns/tasks/aaaa_record.yml b/test/legacy/roles/test_cloudflare_dns/tasks/aaaa_record.yml
index eaa8a860991c8a..d4cae8d5b5db83 100644
--- a/test/legacy/roles/test_cloudflare_dns/tasks/aaaa_record.yml
+++ b/test/legacy/roles/test_cloudflare_dns/tasks/aaaa_record.yml
@@ -178,3 +178,153 @@
     that:
       - cloudflare_dns is successful
       - cloudflare_dns is not changed
+
+- name: "Test: proxiable AAAA record creation"
+  cloudflare_dns:
+    account_email: "{{ cloudflare_email }}"
+    account_api_token: "{{ cloudflare_api_token }}"
+    zone: "{{ cloudflare_zone }}"
+    record: "{{ cloudflare_dns_record  }}"
+    type: AAAA
+    value: 2001:db8::47
+    ttl: 150
+  register: cloudflare_dns
+
+- name: "Validate: proxiable AAAA record creation"
+  assert:
+    that:
+      - cloudflare_dns is successful
+      - cloudflare_dns is changed
+      - cloudflare_dns.result.record.content == '2001:db8::47'
+      - cloudflare_dns.result.record.proxiable == true
+      - cloudflare_dns.result.record.ttl == 150
+      - cloudflare_dns.result.record.type == 'AAAA'
+      - cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
+      - cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
+
+- name: "Test: proxiable AAAA record creation succeeded"
+  cloudflare_dns:
+    account_email: "{{ cloudflare_email }}"
+    account_api_token: "{{ cloudflare_api_token }}"
+    zone: "{{ cloudflare_zone }}"
+    record: "{{ cloudflare_dns_record  }}"
+    type: AAAA
+    value: 2001:db8::47
+    ttl: 150
+  register: cloudflare_dns
+
+- name: "Validate: proxiable AAAA record creation succeeded"
+  assert:
+    that:
+      - cloudflare_dns is successful
+      - cloudflare_dns is not changed
+
+- name: "Test: Enable AAAA record proxied status"
+  cloudflare_dns:
+    account_email: "{{ cloudflare_email }}"
+    account_api_token: "{{ cloudflare_api_token }}"
+    zone: "{{ cloudflare_zone }}"
+    record: "{{ cloudflare_dns_record  }}"
+    type: AAAA
+    value: 2001:db8::47
+    proxied: yes
+  register: cloudflare_dns
+
+- name: "Validate: Enable AAAA record proxied status"
+  assert:
+    that:
+      - cloudflare_dns is successful
+      - cloudflare_dns is changed
+      - cloudflare_dns.result.record.content == '2001:db8::47'
+      - cloudflare_dns.result.record.proxied == true
+      - cloudflare_dns.result.record.type == 'AAAA'
+      - cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
+      - cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
+
+- name: "Test: Enable AAAA record proxied status succeeded"
+  cloudflare_dns:
+    account_email: "{{ cloudflare_email }}"
+    account_api_token: "{{ cloudflare_api_token }}"
+    zone: "{{ cloudflare_zone }}"
+    record: "{{ cloudflare_dns_record  }}"
+    type: AAAA
+    value: 2001:db8::47
+    proxied: yes
+  register: cloudflare_dns
+
+- name: "Validate: Enable AAAA record proxied status succeeded"
+  assert:
+    that:
+      - cloudflare_dns is successful
+      - cloudflare_dns is not changed
+
+- name: "Test: Disable AAAA record proxied status"
+  cloudflare_dns:
+    account_email: "{{ cloudflare_email }}"
+    account_api_token: "{{ cloudflare_api_token }}"
+    zone: "{{ cloudflare_zone }}"
+    record: "{{ cloudflare_dns_record  }}"
+    type: AAAA
+    value: 2001:db8::47
+    proxied: no
+  register: cloudflare_dns
+
+- name: "Validate: Enable AAAA record proxied status"
+  assert:
+    that:
+      - cloudflare_dns is successful
+      - cloudflare_dns is changed
+      - cloudflare_dns.result.record.content == '2001:db8::47'
+      - cloudflare_dns.result.record.proxied == false
+      - cloudflare_dns.result.record.type == 'AAAA'
+      - cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
+      - cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
+
+- name: "Test: Disable AAAA record proxied status succeeded"
+  cloudflare_dns:
+    account_email: "{{ cloudflare_email }}"
+    account_api_token: "{{ cloudflare_api_token }}"
+    zone: "{{ cloudflare_zone }}"
+    record: "{{ cloudflare_dns_record  }}"
+    type: AAAA
+    value: 2001:db8::47
+    proxied: no
+  register: cloudflare_dns
+
+- name: "Validate: Enable AAAA record proxied status succeeded"
+  assert:
+    that:
+      - cloudflare_dns is successful
+      - cloudflare_dns is not changed
+
+- name: "Test: Full AAAA record deletion"
+  cloudflare_dns:
+    account_email: "{{ cloudflare_email }}"
+    account_api_token: "{{ cloudflare_api_token }}"
+    zone: "{{ cloudflare_zone }}"
+    record: "{{ cloudflare_dns_record  }}"
+    type: AAAA
+    state: absent
+  register: cloudflare_dns
+
+- name: "Validate: Full AAAA record deletion"
+  assert:
+    that:
+      - cloudflare_dns is successful
+      - cloudflare_dns is changed
+
+- name: "Test: Full AAAA record deletion succeeded"
+  cloudflare_dns:
+    account_email: "{{ cloudflare_email }}"
+    account_api_token: "{{ cloudflare_api_token }}"
+    zone: "{{ cloudflare_zone }}"
+    record: "{{ cloudflare_dns_record  }}"
+    type: AAAA
+    state: absent
+  register: cloudflare_dns
+
+- name: "Validate: Full AAAA record deletion succeeded"
+  assert:
+    that:
+      - cloudflare_dns is successful
+      - cloudflare_dns is not changed

##### SUMMARY

Resolves #35190

##### ISSUE TYPE
 - Bugfix Pull Request

##### COMPONENT NAME
cloudflare_dns

##### ANSIBLE VERSION
```
ansible 2.7.0.dev0 (devel fdf51f2a43) last updated 2018/07/20 16:39:25 (GMT +200)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/andreas/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/andreas/labs/ansible/devel/lib/ansible
  executable location = /home/andreas/labs/ansible/devel/bin/ansible
  python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]
```