gcore.cloud.lifecycle_policy (1.0.1) — module

Manages lifecycle policies.

Authors: GCore (@GCore)

Install collection

Install with ansible-galaxy collection install gcore.cloud:==1.0.1


Add to requirements.yml

  collections:
    - name: gcore.cloud
      version: 1.0.1

Description

Create, update or delete lifecycle policy.

Add or remove schedules to the policy.

Add or remove volumes to the policy.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create blank policy
  gcore.cloud.lifecycle_policy:
    api_token: "{{ api_token }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: create
    name: "my-policy"
    action: "volume_snapshot"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update policy
  gcore.cloud.lifecycle_policy:
    api_token: "{{ api_token }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: update
    lifecycle_policy_id: "{{ lifecycle_policy_id }}"
    name: "new-name"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add volume to policy
  gcore.cloud.lifecycle_policy:
    api_token: "{{ api_token }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: add_volumes
    lifecycle_policy_id: "{{ lifecycle_policy_id }}"
    volume_ids: ["{{ volume_id }}"]
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove volume from policy
  gcore.cloud.lifecycle_policy:
    api_token: "{{ api_token }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: remove_volumes
    lifecycle_policy_id: "{{ lifecycle_policy_id }}"
    volume_ids: ["{{ volume_id }}"]
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add schedules to policy
  gcore.cloud.lifecycle_policy:
    api_token: "{{ api_token }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: add_schedules
    lifecycle_policy_id: "{{ lifecycle_policy_id }}"
    schedules: ["{{ schedules }}"]
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove schedules from policy
  gcore.cloud.lifecycle_policy:
    api_token: "{{ api_token }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: remove_schedules
    lifecycle_policy_id: "{{ lifecycle_policy_id }}"
    schedule_ids: ["{{ schedule_id }}"]
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete schedules from policy
  gcore.cloud.lifecycle_policy:
    api_token: "{{ api_token }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: delete
    lifecycle_policy_id: "{{ lifecycle_policy_id }}"

Inputs

    
name:
    description:
    - Policy name.
    - Required if I(command) is create.
    - Used if I(command) is update.
    required: false
    type: str

action:
    choices:
    - volume_snapshot
    description:
    - Policy action.
    - Used if I(command) is create.
    required: false
    type: str

status:
    choices:
    - active
    - paused
    description:
    - Lifecycle policys status.
    - Used if I(command) is create or update.
    required: false
    type: str

api_key:
    description:
    - GCore API auth key
    - Can be passed as I(CLOUD_API_KEY) environment variable.
    type: str

command:
    choices:
    - create
    - update
    - delete
    - add_schedules
    - remove_schedules
    - add_volumes
    - remove_volumes
    description:
    - Operation to perform.
    required: true
    type: str

api_host:
    default: https://api.gcore.com/cloud
    description:
    - GCore API base host
    - Can be passed as I(CLOUD_API_HOST) environment variable.
    type: str

region_id:
    description:
    - GCore API region ID
    - Required if I(region_name) is not passed
    - Can be passed as I(CLOUD_REGION_ID) environment variable.
    type: int

schedules:
    description:
    - Schedules.
    - Used if I(command) is create.
    - Required if I(command) is add_schedules.
    elements: dict
    required: false
    type: list

project_id:
    description:
    - GCore API project ID
    - Required if I(project_name) is not passed
    - Can be passed as I(CLOUD_PROJECT_ID) environment variable.
    type: int

volume_ids:
    description:
    - Ids of volumes which should be archived.
    - Used if I(command) is create.
    - Required if I(command) is add_volumes or remove_volumes.
    elements: str
    required: false
    type: list

api_timeout:
    default: 30
    description:
    - Timeout in seconds to polling GCore API
    type: int

region_name:
    description:
    - GCore API region name
    - Required if I(region_id) is not passed
    - Can be passed as I(CLOUD_REGION_NAME) environment variable.
    type: str

project_name:
    description:
    - GCore API project name
    - Required if I(project_id) is not passed
    - Can be passed as I(CLOUD_PROJECT_NAME) environment variable.
    type: str

schedule_ids:
    description:
    - Schedule ids list.
    - Required if I(command) is remove_schedules.
    elements: str
    required: false
    type: list

lifecycle_policy_id:
    description:
    - Lifecycle policy ID.
    - Required for some operations.
    required: false
    type: str

Outputs

lifecycle_policy:
  contains:
    action:
      description: Policy action
      returned: always
      sample: volume_snapshot
      type: str
    id:
      description: Policy ID
      returned: always
      sample: 1
      type: str
    name:
      description: Policy name
      returned: always
      sample: schedule_1
      type: str
    project_id:
      description: Project ID
      returned: always
      sample: 1
      type: int
    region_id:
      description: Region ID
      returned: always
      sample: 1
      type: int
    schedules:
      description: Flavor ID
      elements: dict
      returned: always
      sample:
      - day_of_week: '*'
        hour: 0, 10, 20
        id: 1488e2ce-f906-47fb-ba32-c25a3f63df4f
        max_quantity: 2
        minute: '30'
        owner: lifecycle_policy
        owner_id: 1
        resource_name_template: reserve snap of the volume volume_id
        type: cron
        user_id: 12
      type: list
    status:
      description: Lifecycle policys status
      returned: always
      sample: active
      type: str
    user_id:
      description: User created the policy.
      returned: always
      sample: 11
      type: int
  description:
  - Resouce dictionary.
  returned: always
  type: complex

See also