In Cloudflare dashboard UI, we can change settings for a Zone. One of the settings we can change is the SSL setting that is used for that Zone.
The Cloudflare API exposes access to this SSL setting (and other settings). See the docs.
We would like an Ansible module that will allow us to fetch (state: fetched), create (state: present), and update (state: present) the ssl setting for a Zone using the Cloudflare API.
Here is an example (using curl) of how you can currently use the Cloudflare API to get settings.
# List your zones. Use the `name` query param to retrieve your zone by name.
curl --request GET \
--url https://api.cloudflare.com/client/v4/zones?name={ YOUR_DOMAIN_NAME } \
--header 'Authorization: Bearer { YOUR_TOKEN_HERE }' \
--header 'Content-Type: application/json'
# List all the Zone's settings (not needed if only wanting to edit `ssl`, but helpful to visualize). Use the Zone ID from the previous request.
curl --request GET \
--url https://api.cloudflare.com/client/v4/zones/{ YOUR_ZONE_ID_HERE }/settings \
--header 'Authorization: Bearer { YOUR_TOKEN_HERE }' \
--header 'Content-Type: application/json'
# Get the Zone's SSL setting
curl --request GET \
--url https://api.cloudflare.com/client/v4/zones/{ YOUR_ZONE_ID_HERE }/settings/ssl \
--header 'Authorization: Bearer { YOUR_TOKEN_HERE }' \
--header 'Content-Type: application/json'
# Update the Zone's SSL setting to `full`.
curl --request PATCH \
--url https://api.cloudflare.com/client/v4/zones/{ YOUR_ZONE_ID_HERE }/settings/ssl \
--header 'Authorization: Bearer { YOUR_TOKEN_HERE }' \
--header 'Content-Type: application/json' \
--data '{
"value": "full"
}'
[ ] Read through the existing community.general.cloudflare_dnsmodule's code to understand how they handle authentication to Cloudflare's API
[ ] Manually create a Cloudflare account
[ ] Manually create a Cloudflare zone
[ ] Create an API token in Cloudflare that has access to Edit that Zone
[ ] Create an Ansible module inside this collection named cloudflare_zone_settings_ssl
[ ] It should accept these params at a minimum: zone (name, not ID), api_token, state (one of fetched|present), value (one of full|flexible|strict|off.
[ ] It should use Cloudflare's REST API to fetch or change the SSL settings on a Zone.
[ ] It should not use curl - please try to use ansible.module_utils.urls.fetch_url first, and then Python's Requests package if that doesn't pan out.
In Cloudflare dashboard UI, we can change settings for a Zone. One of the settings we can change is the SSL setting that is used for that Zone.
The Cloudflare API exposes access to this SSL setting (and other settings). See the docs.
We would like an Ansible module that will allow us to fetch (
state: fetched
), create (state: present
), and update (state: present
) thessl
setting for a Zone using the Cloudflare API.Here is an example (using
curl
) of how you can currently use the Cloudflare API to get settings.community.general.cloudflare_dns
module's code to understand how they handle authentication to Cloudflare's APIEdit
that Zonezone
(name, not ID),api_token
,state
(one offetched|present
),value
(one offull|flexible|strict|off
.curl
- please try to useansible.module_utils.urls.fetch_url
first, and then Python's Requests package if that doesn't pan out.Thanks!