# Declarative Changes

## Object Identification

With the introduction of the declarative tasks update (Version 7.0.0), module parameters have been revised to allow identification of objects using a single parameter that can accept either the name or the ID of the object. This replaces the need for multiple parameters previously used for object identification.

Example: Instead of using separate `id` and `name` parameters to identify a `datacenter`, a new parameter (`datacenter`) is now used, which accepts either the ID or the name of the datacenter.

This change applies to various other parameters used for identification, not limited to the resource created by the module.

Example: For `nic` identification, apart from the `nic` parameter, other resources like `datacenter`, `server`, and `lan` will be utilized.

> ***NOTE:*** For this mechanism to function properly, ansible now assumes unique names for objects. If multiple objects with the same names are found, the operation will fail.

## State Behavior for Modules

The update introduces changes in how states will work for the modules:

```yaml
    present:
        Looks for the object:
            - If it does not exist, create it.
            - If it already exists, it will function in the same way as the update state.

    update:
        - Updates the object if no unchangeable properties are modified.
        - Replaces the object if unchangeable properties are modified, creating a new object and removing the old one.
        - If `allow_replace` is set to false, the module will fail instead of replacing the object to avoid resource loss.

    absent:
        - Looks for the object:
            - If it does not exist, the operation is successful.
            - If it exists, delete it.
```

### The allow\_replace parameter

Defaults to `false`

* If set to `true`, the replace behavior is allowed.
* If set to `false`, when a resource would be replaced, an error will be thrown instead.

## List of Parameters Triggering Resource Replacement

The following parameters, when changed or set, trigger resource replacement:

| Module                 | Replace if Changed                                                                                       | Replace if Set                         |
| ---------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------- |
| backupunit             | name                                                                                                     | -                                      |
| certificate            | certificate\_file, certificate\_chain\_file                                                              | private\_key\_file                     |
| cube\_server           | template\_uuid, availability\_zone                                                                       | -                                      |
| datacenter             | location                                                                                                 | -                                      |
| ipblock                | size, location                                                                                           | -                                      |
| k8s\_nodepool          | name, cpu\_family, cores\_count, ram\_size, availability\_zone, storage\_type, storage\_size, datacenter | -                                      |
| mongo\_cluster         | mongo\_db\_version, location                                                                             | -                                      |
| postgres\_cluster      | connections, backup\_location, location, synchronization\_mode, storage\_type                            | -                                      |
| registry\_token        | name                                                                                                     | -                                      |
| registry               | name, location                                                                                           | -                                      |
| volume                 | image, size, disk\_type, availability\_zone, licence\_type, user\_data                                   | backupunit, image\_password, ssh\_keys |
| vm\_autoscaling\_group | datacenter                                                                                               | -                                      |

> ***NOTE:*** The following parameters used to have default values which have been removed to avoid triggering a replacement without a value being set by the user (the former default value is in parentheses) :

* cube\_server:
  * availability\_zone ('AUTO')
* datacenter:
  * location ('us/las')
* ipblock:
  * size (1)
* volume:
  * size (10)
  * ssh\_keys (\[])
  * disk\_type ('HDD')
  * licence\_type ('UNKNOWN')

## List of Parameter Changes

The update involves changes in parameter names, removal of parameters, and addition of new parameters for various modules. Here is the detailed list:

**application\_load\_balancer:**

* datacenter\_id -> datacenter
* application\_load\_balancer\_id -> application\_load\_balancer

**application\_load\_balancer\_flowlog:**

* datacenter\_id -> datacenter
* application\_load\_balancer\_id -> application\_load\_balancer
* flowlog\_id -> flowlog

**application\_load\_balancer\_forwardingrule:**

* datacenter\_id -> datacenter
* application\_load\_balancer\_id -> application\_load\_balancer
* forwarding\_rule\_id -> forwarding\_rule

**backupunit:**

* backupunit\_id -> backupunit

**certificate:**

* certificate\_id -> certificate

**datacenter:**

* removed id
* added datacenter

**firewall\_rule:**

* added firewall\_rule

**group:**

* added group

**ipblock:**

* added ipblock

**k8s\_cluster:**

* k8s\_cluster\_id -> k8s\_cluster

**k8s\_nodepool:**

* removed nodepool\_id
* added k8s\_nodepool
* k8s\_cluster\_id -> k8s\_cluster
* datacenter\_id -> datacenter
* lan\_ids -> lans
* nodepool\_name -> name

**lan:**

* added lan
* pcc\_id -> pcc

**mongo\_cluster\_user:**

* mongo\_cluster\_id -> mongo\_cluster

**nat\_gateway:**

* nat\_gateway\_id -> nat\_gateway
* datacenter\_id -> datacenter

**nat\_gateway\_flowlog:**

* nat\_gateway\_id -> nat\_gateway
* datacenter\_id -> datacenter
* flowlog\_id -> flowlog

**nat\_gateway\_rule:**

* nat\_gateway\_id -> nat\_gateway
* datacenter\_id -> datacenter
* nat\_gateway\_rule\_id -> nat\_gateway\_rule

**network\_load\_balancer:**

* network\_load\_balancer\_id -> network\_load\_balancer
* datacenter\_id -> datacenter

**network\_load\_balancer\_flowlog:**

* network\_load\_balancer\_id -> network\_load\_balancer
* datacenter\_id -> datacenter
* flowlog\_id -> flowlog

**network\_load\_balancer\_flowlog:**

* network\_load\_balancer\_id -> network\_load\_balancer
* datacenter\_id -> datacenter
* forwarding\_rule\_id -> forwarding\_rule

**nic:**

* removed id
* added nic

**nic\_flowlog:**

* datacenter\_id -> datacenter
* server\_id -> server
* nic\_id -> nic
* flowlog\_id -> flowlog

**pcc:**

* pcc\_id -> pcc

**registry:**

* registry\_id -> registry

**registry\_token:**

* removed token\_id
* added registry\_token
* registry\_id -> registry

**registry\_token\_info:**

* registry\_id -> registry

**s3\_key:**

* user\_id -> user

**s3\_key\_info:**

* user\_id -> user

**server:**

* remove template\_uuid and type, use cube\_server

**snapshot:**

* added snapshot

**target\_group:**

* target\_group\_id -> target\_group

**user:**

* removed s3\_canonical\_user\_id
* added user

**volume:**

* backupunit\_id -> backupunit
