community.general.cs_snapshot_policy (0.1.1) — module

Manages volume snapshot policies on Apache CloudStack based clouds.

Authors: René Moser (@resmo)

stableinterface | supported by community

Install collection

Install with ansible-galaxy collection install community.general:==0.1.1


Add to requirements.yml

  collections:
    - name: community.general
      version: 0.1.1

Description

Create, update and delete volume snapshot policies.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: ensure a snapshot policy daily at 1h00 UTC
  cs_snapshot_policy:
    volume: ROOT-478
    schedule: '00:1'
    max_snaps: 3
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: ensure a snapshot policy daily at 1h00 UTC on the second DATADISK of VM web-01
  cs_snapshot_policy:
    vm: web-01
    volume_type: DATADISK
    device_id: 2
    schedule: '00:1'
    max_snaps: 3
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: ensure a snapshot policy hourly at minute 5 UTC
  cs_snapshot_policy:
    volume: ROOT-478
    schedule: '5'
    interval_type: hourly
    max_snaps: 1
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: ensure a snapshot policy weekly on Sunday at 05h00, TZ Europe/Zurich
  cs_snapshot_policy:
    volume: ROOT-478
    schedule: '00:5:1'
    interval_type: weekly
    max_snaps: 1
    time_zone: 'Europe/Zurich'
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: ensure a snapshot policy is absent
  cs_snapshot_policy:
    volume: ROOT-478
    interval_type: hourly
    state: absent
  delegate_to: localhost

Inputs

    
vm:
    description:
    - Name of the instance to select the volume from.
    - Use I(volume_type) if VM has a DATADISK and ROOT volume.
    - In case of I(volume_type=DATADISK), additionally use I(device_id) if VM has more
      than one DATADISK volume.
    - Either I(volume) or I(vm) is required.
    type: str

vpc:
    description:
    - Name of the vpc the instance is deployed in.
    type: str

state:
    choices:
    - present
    - absent
    default: present
    description:
    - State of the snapshot policy.
    type: str

domain:
    description:
    - Domain the volume is related to.
    type: str

volume:
    description:
    - Name of the volume.
    - Either I(volume) or I(vm) is required.
    type: str

account:
    description:
    - Account the volume is related to.
    type: str

api_key:
    description:
    - API key of the CloudStack API.
    - If not given, the C(CLOUDSTACK_KEY) env variable is considered.
    - As the last option, the value is taken from the ini config file, also see the notes.
    type: str

api_url:
    description:
    - URL of the CloudStack API e.g. https://cloud.example.com/client/api.
    - If not given, the C(CLOUDSTACK_ENDPOINT) env variable is considered.
    - As the last option, the value is taken from the ini config file, also see the notes.
    type: str

project:
    description:
    - Name of the project the volume is related to.
    type: str

schedule:
    description:
    - Time the snapshot is scheduled. Required if I(state=present).
    - 'Format for I(interval_type=HOURLY): C(MM)'
    - 'Format for I(interval_type=DAILY): C(MM:HH)'
    - 'Format for I(interval_type=WEEKLY): C(MM:HH:DD (1-7))'
    - 'Format for I(interval_type=MONTHLY): C(MM:HH:DD (1-28))'
    type: str

device_id:
    description:
    - ID of the device on a VM the volume is attached to.
    - This will only be considered if VM has multiple DATADISK volumes.
    type: int

max_snaps:
    aliases:
    - max
    default: 8
    description:
    - Max number of snapshots.
    type: int

time_zone:
    aliases:
    - timezone
    default: UTC
    description:
    - Specifies a timezone for this command.
    type: str

api_region:
    default: cloudstack
    description:
    - Name of the ini section in the C(cloustack.ini) file.
    - If not given, the C(CLOUDSTACK_REGION) env variable is considered.
    type: str

api_secret:
    description:
    - Secret key of the CloudStack API.
    - If not set, the C(CLOUDSTACK_SECRET) env variable is considered.
    - As the last option, the value is taken from the ini config file, also see the notes.
    type: str

api_timeout:
    description:
    - HTTP timeout in seconds.
    - If not given, the C(CLOUDSTACK_TIMEOUT) env variable is considered.
    - As the last option, the value is taken from the ini config file, also see the notes.
    - Fallback value is 10 seconds if not specified.
    type: int

volume_type:
    choices:
    - DATADISK
    - ROOT
    description:
    - Type of the volume.
    type: str

interval_type:
    aliases:
    - interval
    choices:
    - hourly
    - daily
    - weekly
    - monthly
    default: daily
    description:
    - Interval of the snapshot.
    type: str

api_http_method:
    choices:
    - get
    - post
    description:
    - HTTP method used to query the API endpoint.
    - If not given, the C(CLOUDSTACK_METHOD) env variable is considered.
    - As the last option, the value is taken from the ini config file, also see the notes.
    - Fallback value is C(get) if not specified.
    type: str

Outputs

account:
  description: Account the volume is related to.
  returned: success
  sample: example account
  type: str
domain:
  description: Domain the volume is related to.
  returned: success
  sample: example domain
  type: str
id:
  description: UUID of the snapshot policy.
  returned: success
  sample: a6f7a5fc-43f8-11e5-a151-feff819cdc9f
  type: str
interval_type:
  description: interval type of the snapshot policy.
  returned: success
  sample: daily
  type: str
max_snaps:
  description: maximum number of snapshots retained.
  returned: success
  sample: 10
  type: int
project:
  description: Name of project the volume is related to.
  returned: success
  sample: Production
  type: str
schedule:
  description: schedule of the snapshot policy.
  returned: success
  sample: null
  type: str
time_zone:
  description: the time zone of the snapshot policy.
  returned: success
  sample: Etc/UTC
  type: str
volume:
  description: the volume of the snapshot policy.
  returned: success
  sample: Etc/UTC
  type: str
zone:
  description: Name of zone the volume is related to.
  returned: success
  sample: ch-gva-2
  type: str