damex.cloudflare.cloudflare_zone module – Ensure Cloudflare zones

Note

This module is part of the damex.cloudflare collection (version 1.0.6).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install damex.cloudflare. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: damex.cloudflare.cloudflare_zone.

Synopsis

Requirements

The below requirements are needed on the host that executes this module.

  • python3-cloudflare >= 2.11.1

Parameters

Parameter

Comments

account_api_key

string

Cloudflare account API key.

Required together with account_email if api_token is not provided.

account_email

string

Cloudflare account email.

Required together with account_api_key if api_token is not provided.

account_name

string / required

Cloudflare account name.

always_https

boolean

Always HTTPS redirect.

Choices:

  • false

  • true

api_token

string

Cloudflare API token.

Required if account_email and account_api_key are not provided.

Can be specified in CLOUDFLARE_TOKEN environment variable.

jump_start

boolean

Zone jump start.

Choices:

  • false ← (default)

  • true

min_tls_version

string

Minimum TLS version.

Choices:

  • "1.0"

  • "1.1"

  • "1.2"

  • "1.3"

name

string / required

Zone domain name.

ssl_mode

string

SSL mode.

Choices:

  • "off"

  • "flexible"

  • "full"

  • "strict"

  • "origin_pull"

state

string

Zone state.

Choices:

  • "absent"

  • "present" ← (default)

type

string

Zone type.

Choices:

  • "full" ← (default)

  • "partial"

  • "secondary"

universal_ssl

boolean

Universal SSL.

Choices:

  • false

  • true

Attributes

Attribute

Support

Description

check_mode

Support: full

Supports check mode.

diff_mode

Support: none

Does not support diff mode.

Examples

- name: Ensure zone using API token
  damex.cloudflare.cloudflare_zone:
    name: example.com
    account_name: my-account
    api_token: "{{ cloudflare_api_token }}"
    state: present

- name: Ensure zone with jump start
  damex.cloudflare.cloudflare_zone:
    name: example.com
    account_name: my-account
    api_token: "{{ cloudflare_api_token }}"
    jump_start: true

- name: Ensure zone absent
  damex.cloudflare.cloudflare_zone:
    name: example.com
    account_name: my-account
    api_token: "{{ cloudflare_api_token }}"
    state: absent

- name: Ensure zone using legacy auth
  damex.cloudflare.cloudflare_zone:
    name: example.com
    account_name: my-account
    account_email: user@example.com
    account_api_key: "{{ cloudflare_api_key }}"
    state: present

- name: Ensure zone with security settings
  damex.cloudflare.cloudflare_zone:
    name: example.com
    account_name: my-account
    api_token: "{{ cloudflare_api_token }}"
    ssl_mode: full
    always_https: true
    min_tls_version: "1.2"
    universal_ssl: true

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

zone

dictionary

The zone object from the Cloudflare API.

Returned: when state is present, or state is absent with check_mode

account

dictionary

The account the zone belongs to.

Returned: success

Sample: {"id": "023e105f4ecef8ad9ca31a8372d0c353", "name": "my-account"}

id

string

The zone ID.

Returned: success

Sample: "023e105f4ecef8ad9ca31a8372d0c353"

name

string

The zone domain name.

Returned: success

Sample: "example.com"

status

string

The zone status.

Returned: success

Sample: "active"

type

string

The zone type.

Returned: success

Sample: "full"

Authors

  • Roman Kuzmitskii (@damex)