diff --git a/README.md b/README.md index 00392c9e..c7debbca 100644 --- a/README.md +++ b/README.md @@ -99,8 +99,8 @@ Name | Description | [linode.cloud.firewall_list](./docs/modules/firewall_list.md)|List and filter on Firewalls.| [linode.cloud.image_list](./docs/modules/image_list.md)|List and filter on Images.| [linode.cloud.instance_list](./docs/modules/instance_list.md)|List and filter on Instances.| -[linode.cloud.instance_type_list](./docs/modules/instance_type_list.md)|**NOTE: This module has been deprecated in favor of `type_list`.| -[linode.cloud.lke_version_list](./docs/modules/lke_version_list.md)|List Kubernetes versions available for deployment to a Kubernetes cluster.| +[linode.cloud.instance_type_list](./docs/modules/instance_type_list.md)|**NOTE: This module has been deprecated in favor of `type_list`.**| +[linode.cloud.lke_version_list](./docs/modules/lke_version_list.md)|List and filter on LKE Versions.| [linode.cloud.nodebalancer_list](./docs/modules/nodebalancer_list.md)|List and filter on Node Balancers.| [linode.cloud.object_cluster_list](./docs/modules/object_cluster_list.md)|**NOTE: This module has been deprecated because it relies on deprecated API endpoints. Going forward, `region` will be the preferred way to designate where Object Storage resources should be created.**| [linode.cloud.placement_group_list](./docs/modules/placement_group_list.md)|List and filter on Placement Groups.| diff --git a/docs/modules/firewall_info.md b/docs/modules/firewall_info.md index 162d3334..eb0d6e44 100644 --- a/docs/modules/firewall_info.md +++ b/docs/modules/firewall_info.md @@ -31,8 +31,8 @@ Get info about a Linode Firewall. | Field | Type | Required | Description | |-----------|------|----------|------------------------------------------------------------------------------| -| `label` |
`str`
|
Optional
| The label of the Firewall to resolve. **(Conflicts With: `id`)** | | `id` |
`int`
|
Optional
| The ID of the Firewall to resolve. **(Conflicts With: `label`)** | +| `label` |
`str`
|
Optional
| The label of the Firewall to resolve. **(Conflicts With: `id`)** | ## Return Values diff --git a/docs/modules/image_info.md b/docs/modules/image_info.md index 6ede4285..abf339b4 100644 --- a/docs/modules/image_info.md +++ b/docs/modules/image_info.md @@ -31,8 +31,8 @@ Get info about a Linode Image. | Field | Type | Required | Description | |-----------|------|----------|------------------------------------------------------------------------------| -| `label` |
`str`
|
Optional
| The label of the Image to resolve. **(Conflicts With: `id`)** | | `id` |
`str`
|
Optional
| The ID of the Image to resolve. **(Conflicts With: `label`)** | +| `label` |
`str`
|
Optional
| The label of the Image to resolve. **(Conflicts With: `id`)** | ## Return Values diff --git a/docs/modules/instance.md b/docs/modules/instance.md index 581e93f2..919e66ee 100644 --- a/docs/modules/instance.md +++ b/docs/modules/instance.md @@ -149,6 +149,7 @@ Manage Linode Instances, Configs, and Disks. | `auto_disk_resize` |
`bool`
|
Optional
| Whether implicitly created disks should be resized during a type change operation. **(Default: `False`)** | | `tags` |
`list`
|
Optional
| An array of tags applied to this object. Tags are for organizational purposes only. **(Updatable)** | | [`placement_group` (sub-options)](#placement_group) |
`dict`
|
Optional
| A Placement Group to create this Linode under. | +| `disk_encryption` |
`str`
|
Optional
| The disk encryption status of this Linode. NOTE: Disk encryption may not currently be available to all users. **(Choices: `enabled`, `disabled`)** | | `swap_size` |
`int`
|
Optional
| When deploying from an Image, this field is optional, otherwise it is ignored. This is used to set the swap disk size for the newly-created Linode. | ### configs @@ -274,6 +275,7 @@ Manage Linode Instances, Configs, and Disks. | `authorized_keys` |
`list`
|
Optional
| A list of SSH public key parts to deploy for the root user. | | `authorized_users` |
`list`
|
Optional
| A list of usernames. | | `filesystem` |
`str`
|
Optional
| The filesystem to create this disk with. | +| `disk_encryption` |
`str`
|
Optional
| The disk encryption status of this disk.NOTE: Disk encryption may not currently be available to all users. **(Choices: `enabled`, `disabled`)** | | `image` |
`str`
|
Optional
| An Image ID to deploy the Disk from. | | `root_pass` |
`str`
|
Optional
| The root user’s password on the newly-created Linode. | | `stackscript_id` |
`int`
|
Optional
| The ID of the StackScript to use when creating the instance. See the [Linode API documentation](https://techdocs.akamai.com/linode-api/reference/get-stack-scripts). | @@ -354,6 +356,8 @@ Manage Linode Instances, Configs, and Disks. "placement_group_type": "anti_affinity:local", "placement_group_policy": "strict" } + "disk_encryption": "enabled", + "lke_cluster_id": null } ``` - See the [Linode API response documentation](https://techdocs.akamai.com/linode-api/reference/get-linode-instance) for a list of returned fields @@ -439,7 +443,8 @@ Manage Linode Instances, Configs, and Disks. "label": "Debian 9 Disk", "size": 48640, "status": "ready", - "updated": "2018-01-01T00:01:01" + "updated": "2018-01-01T00:01:01", + "disk_encryption": "enabled" } ] ``` diff --git a/docs/modules/instance_info.md b/docs/modules/instance_info.md index 21c59298..2bb5b53e 100644 --- a/docs/modules/instance_info.md +++ b/docs/modules/instance_info.md @@ -31,8 +31,8 @@ Get info about a Linode Instance. | Field | Type | Required | Description | |-----------|------|----------|------------------------------------------------------------------------------| -| `label` |
`str`
|
Optional
| The label of the Instance to resolve. **(Conflicts With: `id`)** | | `id` |
`int`
|
Optional
| The ID of the Instance to resolve. **(Conflicts With: `label`)** | +| `label` |
`str`
|
Optional
| The label of the Instance to resolve. **(Conflicts With: `id`)** | ## Return Values @@ -89,6 +89,8 @@ Get info about a Linode Instance. "placement_group_type": "anti_affinity:local", "placement_group_policy": "strict" } + "disk_encryption": "enabled", + "lke_cluster_id": null } ``` - See the [Linode API response documentation](https://techdocs.akamai.com/linode-api/reference/get-linode-instance) for a list of returned fields @@ -174,7 +176,8 @@ Get info about a Linode Instance. "label": "Debian 9 Disk", "size": 48640, "status": "ready", - "updated": "2018-01-01T00:01:01" + "updated": "2018-01-01T00:01:01", + "disk_encryption": "enabled" } ] ``` diff --git a/docs/modules/instance_list.md b/docs/modules/instance_list.md index e0b63c07..156a41a3 100644 --- a/docs/modules/instance_list.md +++ b/docs/modules/instance_list.md @@ -94,7 +94,9 @@ List and filter on Instances. ], "type": "g6-standard-1", "updated": "2018-01-01T00:01:01", - "watchdog_enabled": true + "watchdog_enabled": true, + "disk_encryption": "enabled", + "lke_cluster_id": null } ] ``` diff --git a/docs/modules/instance_type_list.md b/docs/modules/instance_type_list.md index f3d18950..c68d9e5f 100644 --- a/docs/modules/instance_type_list.md +++ b/docs/modules/instance_type_list.md @@ -1,8 +1,8 @@ # instance_type_list -**NOTE: This module has been deprecated in favor of `type_list`. +**NOTE: This module has been deprecated in favor of `type_list`.** -List and filter on Linode Instance Types. +List and filter on Instance Types. - [Minimum Required Fields](#minimum-required-fields) - [Examples](#examples) diff --git a/docs/modules/ip_share.md b/docs/modules/ip_share.md index 3a8f6b90..4843f8a0 100644 --- a/docs/modules/ip_share.md +++ b/docs/modules/ip_share.md @@ -31,6 +31,7 @@ WARNING! This module makes use of beta endpoints and requires the C(api_version) |-----------|------|----------|------------------------------------------------------------------------------| | `ips` |
`list`
|
**Required**
| A list of secondary Linode IPs to share with the primary Linode. | | `linode_id` |
`int`
|
**Required**
| The ID of the primary Linode that the addresses will be shared with. | +| `state` |
`str`
|
**Required**
| The desired state of the target. **(Choices: `present`, `absent`)** | ## Return Values diff --git a/docs/modules/lke_cluster.md b/docs/modules/lke_cluster.md index d18469bd..bf02a695 100644 --- a/docs/modules/lke_cluster.md +++ b/docs/modules/lke_cluster.md @@ -57,6 +57,7 @@ Manage Linode LKE clusters. | Field | Type | Required | Description | |-----------|------|----------|------------------------------------------------------------------------------| | `label` |
`str`
|
**Required**
| This Kubernetes cluster’s unique label. | +| `state` |
`str`
|
**Required**
| The desired state of the target. **(Choices: `present`, `absent`)** | | `k8s_version` |
`str`
|
Optional
| The desired Kubernetes version for this Kubernetes cluster in the format of ., and the latest supported patch version will be deployed. A version upgrade requires that you manually recycle the nodes in your cluster. **(Updatable)** | | `region` |
`str`
|
Optional
| This Kubernetes cluster’s location. | | `tags` |
`list`
|
Optional
| An array of tags applied to the Kubernetes cluster. | @@ -87,6 +88,8 @@ Manage Linode LKE clusters. | `count` |
`int`
|
**Required**
| The number of nodes in the Node Pool. **(Updatable)** | | `type` |
`str`
|
**Required**
| The Linode Type for all of the nodes in the Node Pool. | | [`autoscaler` (sub-options)](#autoscaler) |
`dict`
|
Optional
| When enabled, the number of nodes autoscales within the defined minimum and maximum values. **(Updatable)** | +| `labels` |
`dict`
|
Optional
| Key-value pairs added as labels to nodes in the node pool. Labels help classify your nodes and to easily select subsets of objects. **(Updatable)** | +| [`taints` (sub-options)](#taints) |
`list`
|
Optional
| Kubernetes taints to add to node pool nodes. Taints help control how pods are scheduled onto nodes, specifically allowing them to repel certain pods. **(Updatable)** | ### autoscaler @@ -96,6 +99,14 @@ Manage Linode LKE clusters. | `max` |
`int`
|
Optional
| The maximum number of nodes to autoscale to. Defaults to the value provided by the count field. **(Updatable)** | | `min` |
`int`
|
Optional
| The minimum number of nodes to autoscale to. Defaults to the Node Pool’s count. **(Updatable)** | +### taints + +| Field | Type | Required | Description | +|-----------|------|----------|------------------------------------------------------------------------------| +| `key` |
`str`
|
**Required**
| The Kubernetes taint key. **(Updatable)** | +| `value` |
`str`
|
**Required**
| The Kubernetes taint value. **(Updatable)** | +| `effect` |
`str`
|
**Required**
| The Kubernetes taint effect. **(Choices: `NoSchedule`, `PreferNoSchedule`, `NoExecute`; Updatable)** | + ## Return Values - `cluster` - The LKE cluster in JSON serialized form. @@ -139,6 +150,7 @@ Manage Linode LKE clusters. "max": 12, "min": 3 }, + "disk_encryption": "enabled", "count": 6, "disks": [ { diff --git a/docs/modules/lke_cluster_info.md b/docs/modules/lke_cluster_info.md index 3c395fce..23dbfe75 100644 --- a/docs/modules/lke_cluster_info.md +++ b/docs/modules/lke_cluster_info.md @@ -77,6 +77,7 @@ Get info about a Linode LKE cluster. "max": 12, "min": 3 }, + "disk_encryption": "enabled", "count": 6, "disks": [ { diff --git a/docs/modules/lke_node_pool.md b/docs/modules/lke_node_pool.md index 9d9767e7..c86314e2 100644 --- a/docs/modules/lke_node_pool.md +++ b/docs/modules/lke_node_pool.md @@ -61,6 +61,8 @@ Manage Linode LKE cluster node pools. | `type` |
`str`
|
Optional
| The Linode Type for all of the nodes in the Node Pool. Required if `state` == `present`. | | `skip_polling` |
`bool`
|
Optional
| If true, the module will not wait for all nodes in the node pool to be ready. **(Default: `False`)** | | `wait_timeout` |
`int`
|
Optional
| The period to wait for the node pool to be ready in seconds. **(Default: `600`)** | +| `labels` |
`dict`
|
Optional
| Key-value pairs added as labels to nodes in the node pool. Labels help classify your nodes and to easily select subsets of objects. **(Updatable)** | +| [`taints` (sub-options)](#taints) |
`list`
|
Optional
| Kubernetes taints to add to node pool nodes. Taints help control how pods are scheduled onto nodes, specifically allowing them to repel certain pods. **(Updatable)** | ### autoscaler @@ -77,6 +79,14 @@ Manage Linode LKE cluster node pools. | `type` |
`str`
|
**Required**
| This custom disk partition’s filesystem type. **(Choices: `raw`, `ext4`)** | | `size` |
`int`
|
**Required**
| The size of this custom disk partition in MB. | +### taints + +| Field | Type | Required | Description | +|-----------|------|----------|------------------------------------------------------------------------------| +| `key` |
`str`
|
**Required**
| The Kubernetes taint key. **(Updatable)** | +| `value` |
`str`
|
**Required**
| The Kubernetes taint value. **(Updatable)** | +| `effect` |
`str`
|
**Required**
| The Kubernetes taint effect. **(Choices: `NoSchedule`, `PreferNoSchedule`, `NoExecute`; Updatable)** | + ## Return Values - `node_pool` - The Node Pool in JSON serialized form. @@ -89,6 +99,7 @@ Manage Linode LKE cluster node pools. "max": 12, "min": 3 }, + "disk_encryption": "enabled", "count": 6, "disks": [ { diff --git a/docs/modules/lke_version_list.md b/docs/modules/lke_version_list.md index da6f0d54..f7474cc6 100644 --- a/docs/modules/lke_version_list.md +++ b/docs/modules/lke_version_list.md @@ -1,6 +1,6 @@ # lke_version_list -List Kubernetes versions available for deployment to a Kubernetes cluster. +List and filter on LKE Versions. - [Minimum Required Fields](#minimum-required-fields) - [Examples](#examples) @@ -24,12 +24,21 @@ List Kubernetes versions available for deployment to a Kubernetes cluster. | Field | Type | Required | Description | |-----------|------|----------|------------------------------------------------------------------------------| -| `order` |
`str`
|
Optional
| The order to list lke versions in. **(Choices: `desc`, `asc`; Default: `asc`)** | -| `count` |
`int`
|
Optional
| The number of results to return. If undefined, all results will be returned. | +| `order` |
`str`
|
Optional
| The order to list LKE Versions in. **(Choices: `desc`, `asc`; Default: `asc`)** | +| `order_by` |
`str`
|
Optional
| The attribute to order LKE Versions by. | +| [`filters` (sub-options)](#filters) |
`list`
|
Optional
| A list of filters to apply to the resulting LKE Versions. | +| `count` |
`int`
|
Optional
| The number of LKE Versions to return. If undefined, all results will be returned. | + +### filters + +| Field | Type | Required | Description | +|-----------|------|----------|------------------------------------------------------------------------------| +| `name` |
`str`
|
**Required**
| The name of the field to filter on. Valid filterable fields can be found [here](https://techdocs.akamai.com/linode-api/reference/get-lke-versions). | +| `values` |
`list`
|
**Required**
| A list of values to allow for this field. Fields will pass this filter if at least one of these values matches. | ## Return Values -- `lke_versions` - The returned LKE versions. +- `lke_versions` - The returned LKE Versions. - Sample Response: ```json diff --git a/docs/modules/nodebalancer_info.md b/docs/modules/nodebalancer_info.md index ba0e4e2a..587b016c 100644 --- a/docs/modules/nodebalancer_info.md +++ b/docs/modules/nodebalancer_info.md @@ -31,8 +31,8 @@ Get info about a Linode Node Balancer. | Field | Type | Required | Description | |-----------|------|----------|------------------------------------------------------------------------------| -| `label` |
`str`
|
Optional
| The label of the Node Balancer to resolve. **(Conflicts With: `id`)** | | `id` |
`int`
|
Optional
| The ID of the Node Balancer to resolve. **(Conflicts With: `label`)** | +| `label` |
`str`
|
Optional
| The label of the Node Balancer to resolve. **(Conflicts With: `id`)** | ## Return Values diff --git a/docs/modules/nodebalancer_stats.md b/docs/modules/nodebalancer_stats.md index 85db71a7..58b4a262 100644 --- a/docs/modules/nodebalancer_stats.md +++ b/docs/modules/nodebalancer_stats.md @@ -28,8 +28,8 @@ Get info about a Linode Node Balancer Stats. | Field | Type | Required | Description | |-----------|------|----------|------------------------------------------------------------------------------| -| `label` |
`str`
|
Optional
| The label of the Node Balancer Stats to resolve. **(Conflicts With: `id`)** | | `id` |
`int`
|
Optional
| The ID of the Node Balancer Stats to resolve. **(Conflicts With: `label`)** | +| `label` |
`str`
|
Optional
| The label of the Node Balancer Stats to resolve. **(Conflicts With: `id`)** | ## Return Values diff --git a/docs/modules/object_cluster_list.md b/docs/modules/object_cluster_list.md index 35b31ca7..26688d5a 100644 --- a/docs/modules/object_cluster_list.md +++ b/docs/modules/object_cluster_list.md @@ -34,21 +34,21 @@ List and filter on Object Storage Clusters. | Field | Type | Required | Description | |-----------|------|----------|------------------------------------------------------------------------------| -| `order` |
`str`
|
Optional
| The order to list object storage clusters in. **(Choices: `desc`, `asc`; Default: `asc`)** | -| `order_by` |
`str`
|
Optional
| The attribute to order object storage clusters by. | -| [`filters` (sub-options)](#filters) |
`list`
|
Optional
| A list of filters to apply to the resulting object storage clusters. | -| `count` |
`int`
|
Optional
| The number of results to return. If undefined, all results will be returned. | +| `order` |
`str`
|
Optional
| The order to list Object Storage Clusters in. **(Choices: `desc`, `asc`; Default: `asc`)** | +| `order_by` |
`str`
|
Optional
| The attribute to order Object Storage Clusters by. | +| [`filters` (sub-options)](#filters) |
`list`
|
Optional
| A list of filters to apply to the resulting Object Storage Clusters. | +| `count` |
`int`
|
Optional
| The number of Object Storage Clusters to return. If undefined, all results will be returned. | ### filters | Field | Type | Required | Description | |-----------|------|----------|------------------------------------------------------------------------------| -| `name` |
`str`
|
**Required**
| The name of the field to filter on. Valid filterable attributes can be found here: https://techdocs.akamai.com/linode-api/reference/get-object-storage-buckets | +| `name` |
`str`
|
**Required**
| The name of the field to filter on. Valid filterable fields can be found [here](https://techdocs.akamai.com/linode-api/reference/get-object-storage-clusters). | | `values` |
`list`
|
**Required**
| A list of values to allow for this field. Fields will pass this filter if at least one of these values matches. | ## Return Values -- `clusters` - The returned object storage clusters. +- `clusters` - The returned Object Storage Clusters. - Sample Response: ```json diff --git a/docs/modules/placement_group.md b/docs/modules/placement_group.md index b13b551c..e376a0f0 100644 --- a/docs/modules/placement_group.md +++ b/docs/modules/placement_group.md @@ -55,6 +55,7 @@ NOTE: Placement Groups may not currently be available to all users. | Field | Type | Required | Description | |-----------|------|----------|------------------------------------------------------------------------------| +| `state` |
`str`
|
**Required**
| The desired state of the target. **(Choices: `present`, `absent`)** | | `id` |
`int`
|
Optional
| The unique ID of the placement group. | | `label` |
`str`
|
Optional
| The label of the Placement Group. This field can only contain ASCII letters, digits and dashes. | | `region` |
`str`
|
Optional
| The region that the placement group is in. | diff --git a/docs/modules/placement_group_assign.md b/docs/modules/placement_group_assign.md index fcdac1ed..701d3f66 100644 --- a/docs/modules/placement_group_assign.md +++ b/docs/modules/placement_group_assign.md @@ -40,6 +40,7 @@ NOTE: Placement Groups may not currently be available to all users. |-----------|------|----------|------------------------------------------------------------------------------| | `placement_group_id` |
`int`
|
**Required**
| The ID of the Placement Group for this assignment. | | `linode_id` |
`int`
|
**Required**
| The Linode ID to assign or unassign to the Placement Group. | +| `state` |
`str`
|
**Required**
| The desired state of the target. **(Choices: `present`, `absent`)** | ## Return Values diff --git a/docs/modules/ssh_key_info.md b/docs/modules/ssh_key_info.md index 6d193e78..9f1380c7 100644 --- a/docs/modules/ssh_key_info.md +++ b/docs/modules/ssh_key_info.md @@ -31,8 +31,8 @@ Get info about a Linode SSH Key. | Field | Type | Required | Description | |-----------|------|----------|------------------------------------------------------------------------------| -| `label` |
`str`
|
Optional
| The label of the SSH Key to resolve. **(Conflicts With: `id`)** | | `id` |
`int`
|
Optional
| The ID of the SSH Key to resolve. **(Conflicts With: `label`)** | +| `label` |
`str`
|
Optional
| The label of the SSH Key to resolve. **(Conflicts With: `id`)** | ## Return Values diff --git a/docs/modules/stackscript_info.md b/docs/modules/stackscript_info.md index cfcf79e9..94d21905 100644 --- a/docs/modules/stackscript_info.md +++ b/docs/modules/stackscript_info.md @@ -31,8 +31,8 @@ Get info about a Linode StackScript. | Field | Type | Required | Description | |-----------|------|----------|------------------------------------------------------------------------------| -| `label` |
`str`
|
Optional
| The label of the StackScript to resolve. **(Conflicts With: `id`)** | | `id` |
`int`
|
Optional
| The ID of the StackScript to resolve. **(Conflicts With: `label`)** | +| `label` |
`str`
|
Optional
| The label of the StackScript to resolve. **(Conflicts With: `id`)** | ## Return Values diff --git a/docs/modules/token_info.md b/docs/modules/token_info.md index ede98195..94815ecc 100644 --- a/docs/modules/token_info.md +++ b/docs/modules/token_info.md @@ -31,8 +31,8 @@ Get info about a Linode Personal Access Token. | Field | Type | Required | Description | |-----------|------|----------|------------------------------------------------------------------------------| -| `label` |
`str`
|
Optional
| The label of the Personal Access Token to resolve. **(Conflicts With: `id`)** | | `id` |
`int`
|
Optional
| The ID of the Personal Access Token to resolve. **(Conflicts With: `label`)** | +| `label` |
`str`
|
Optional
| The label of the Personal Access Token to resolve. **(Conflicts With: `id`)** | ## Return Values diff --git a/docs/modules/vlan_info.md b/docs/modules/vlan_info.md index c5ef1d98..5104a7e8 100644 --- a/docs/modules/vlan_info.md +++ b/docs/modules/vlan_info.md @@ -26,8 +26,8 @@ Get info about a Linode VLAN. | Field | Type | Required | Description | |-----------|------|----------|------------------------------------------------------------------------------| -| `label` |
`str`
|
Optional
| The label of the VLAN to resolve. **(Conflicts With: `id`)** | | `id` |
`int`
|
Optional
| The ID of the VLAN to resolve. **(Conflicts With: `label`)** | +| `label` |
`str`
|
Optional
| The label of the VLAN to resolve. **(Conflicts With: `id`)** | ## Return Values diff --git a/docs/modules/vpc_info.md b/docs/modules/vpc_info.md index 985047fa..507bf2af 100644 --- a/docs/modules/vpc_info.md +++ b/docs/modules/vpc_info.md @@ -31,8 +31,8 @@ Get info about a Linode VPC. | Field | Type | Required | Description | |-----------|------|----------|------------------------------------------------------------------------------| -| `label` |
`str`
|
Optional
| The label of the VPC to resolve. **(Conflicts With: `id`)** | | `id` |
`int`
|
Optional
| The ID of the VPC to resolve. **(Conflicts With: `label`)** | +| `label` |
`str`
|
Optional
| The label of the VPC to resolve. **(Conflicts With: `id`)** | ## Return Values diff --git a/docs/modules/vpc_subnet_info.md b/docs/modules/vpc_subnet_info.md index 16a76f05..9a3afbf2 100644 --- a/docs/modules/vpc_subnet_info.md +++ b/docs/modules/vpc_subnet_info.md @@ -34,8 +34,8 @@ Get info about a Linode VPC Subnet. | Field | Type | Required | Description | |-----------|------|----------|------------------------------------------------------------------------------| | `vpc_id` |
`int`
|
**Required**
| The ID of the VPC for this resource. | -| `label` |
`str`
|
Optional
| The label of the VPC Subnet to resolve. **(Conflicts With: `id`)** | | `id` |
`int`
|
Optional
| The ID of the VPC Subnet to resolve. **(Conflicts With: `label`)** | +| `label` |
`str`
|
Optional
| The label of the VPC Subnet to resolve. **(Conflicts With: `id`)** | ## Return Values diff --git a/plugins/module_utils/doc_fragments/instance.py b/plugins/module_utils/doc_fragments/instance.py index f13bf3d3..a71d3fa9 100644 --- a/plugins/module_utils/doc_fragments/instance.py +++ b/plugins/module_utils/doc_fragments/instance.py @@ -135,6 +135,8 @@ "placement_group_type": "anti_affinity:local", "placement_group_policy": "strict" } + "disk_encryption": "enabled", + "lke_cluster_id": null }'''] result_configs_samples = ['''[ @@ -206,7 +208,8 @@ "label": "Debian 9 Disk", "size": 48640, "status": "ready", - "updated": "2018-01-01T00:01:01" + "updated": "2018-01-01T00:01:01", + "disk_encryption": "enabled" } ]'''] diff --git a/plugins/module_utils/doc_fragments/instance_list.py b/plugins/module_utils/doc_fragments/instance_list.py index d69ef97c..41191845 100644 --- a/plugins/module_utils/doc_fragments/instance_list.py +++ b/plugins/module_utils/doc_fragments/instance_list.py @@ -53,6 +53,8 @@ ], "type": "g6-standard-1", "updated": "2018-01-01T00:01:01", - "watchdog_enabled": true + "watchdog_enabled": true, + "disk_encryption": "enabled", + "lke_cluster_id": null } ]'''] diff --git a/plugins/module_utils/doc_fragments/lke_cluster.py b/plugins/module_utils/doc_fragments/lke_cluster.py index f9b9ba8f..2a89d0b7 100644 --- a/plugins/module_utils/doc_fragments/lke_cluster.py +++ b/plugins/module_utils/doc_fragments/lke_cluster.py @@ -60,6 +60,7 @@ "max": 12, "min": 3 }, + "disk_encryption": "enabled", "count": 6, "disks": [ { diff --git a/plugins/module_utils/doc_fragments/lke_node_pool.py b/plugins/module_utils/doc_fragments/lke_node_pool.py index d58bb9fd..e7d86544 100644 --- a/plugins/module_utils/doc_fragments/lke_node_pool.py +++ b/plugins/module_utils/doc_fragments/lke_node_pool.py @@ -35,6 +35,7 @@ "max": 12, "min": 3 }, + "disk_encryption": "enabled", "count": 6, "disks": [ { diff --git a/plugins/module_utils/linode_common.py b/plugins/module_utils/linode_common.py index 58218df3..b05dfc95 100644 --- a/plugins/module_utils/linode_common.py +++ b/plugins/module_utils/linode_common.py @@ -70,11 +70,6 @@ "fallback": (env_fallback, ["LINODE_API_URL"]), "default": "https://api.linode.com/", }, - "state": { - "type": "str", - "required": True, - "choices": ["present", "absent"], - }, "ua_prefix": { "type": "str", "description": "An HTTP User-Agent Prefix to prepend in API requests.", @@ -88,21 +83,6 @@ }, } -LINODE_TAG_ARGS = { - "tags": { - "type": "list", - "description": "The tags to assign to this resource.", - }, -} - -LINODE_LABEL_ARGS = { - "label": { - "type": "str", - "required": True, - "description": "The label to assign to this resource.", - }, -} - RESOURCE_NAMES = ( { Image: "image", @@ -130,8 +110,6 @@ class LinodeModuleBase: def __init__( self, module_arg_spec: dict, - supports_tags: bool = True, - has_label: bool = True, bypass_checks: bool = False, no_log: bool = False, mutually_exclusive: Any = None, @@ -145,12 +123,6 @@ def __init__( arg_spec = {} arg_spec.update(LINODE_COMMON_ARGS) - if has_label: - arg_spec.update(LINODE_LABEL_ARGS) - - if supports_tags: - arg_spec.update(LINODE_TAG_ARGS) - arg_spec.update(module_arg_spec) self._client = None diff --git a/plugins/module_utils/linode_common_info.py b/plugins/module_utils/linode_common_info.py index 709b5144..ce5a2a0c 100644 --- a/plugins/module_utils/linode_common_info.py +++ b/plugins/module_utils/linode_common_info.py @@ -124,6 +124,8 @@ def __init__( examples: List[str] = None, description: List[str] = None, requires_beta: bool = False, + deprecated: bool = False, + deprecation_message: Optional[str] = None, ) -> None: self.primary_result = primary_result self.secondary_results = secondary_results or [] @@ -133,6 +135,15 @@ def __init__( f"Get info about a Linode {self.primary_result.display_name}." ] self.requires_beta = requires_beta + self.deprecated = deprecated + self.deprecation_message = ( + deprecation_message or "This module has been deprecated." + ) + + # If this module is deprecated, we should add the deprecation message + # to the module's description. + if self.deprecated: + self.description.insert(0, f"**NOTE: {self.deprecation_message}**") # Singular params should be translated into groups self.param_groups = [ @@ -207,14 +218,7 @@ def spec(self): Returns the ansible-specdoc spec for this module. """ - options = { - "state": SpecField( - type=FieldType.string, required=False, doc_hide=True - ), - "label": SpecField( - type=FieldType.string, required=False, doc_hide=True - ), - } + options = {} # Add params to spec for group in self.param_groups: @@ -274,6 +278,10 @@ def run(self) -> None: """ Initializes and runs the info module. """ + + if self.deprecated: + self.warn(self.deprecation_message) + base_module_args = { "module_arg_spec": self.module_arg_spec, "required_one_of": [], diff --git a/plugins/module_utils/linode_common_list.py b/plugins/module_utils/linode_common_list.py index cc7ba234..7db6a4fb 100644 --- a/plugins/module_utils/linode_common_list.py +++ b/plugins/module_utils/linode_common_list.py @@ -56,6 +56,8 @@ def __init__( description: List[str] = None, result_samples: List[str] = None, requires_beta: bool = False, + deprecated: bool = False, + deprecation_message: Optional[str] = None, ) -> None: self.result_display_name = result_display_name self.result_field_name = result_field_name @@ -69,13 +71,25 @@ def __init__( ] self.result_samples = result_samples or [] self.requires_beta = requires_beta + self.deprecated = deprecated + self.deprecation_message = ( + deprecation_message or "This module has been deprecated." + ) self.module_arg_spec = self.spec.ansible_spec self.results: Dict[str, Any] = {self.result_field_name: []} + # If this module is deprecated, we should add the deprecation message + # to the module's description. + if self.deprecated: + self.description.insert(0, f"**NOTE: {self.deprecation_message}**") + def exec_module(self, **kwargs: Any) -> Optional[dict]: """Entrypoint for list module""" + if self.deprecated: + self.warn(self.deprecation_message) + filter_dict = construct_api_filter(self.module.params) self.results[self.result_field_name] = get_all_paginated( @@ -112,13 +126,6 @@ def spec(self): } options = { - # Disable the default values - "state": SpecField( - type=FieldType.string, required=False, doc_hide=True - ), - "label": SpecField( - type=FieldType.string, required=False, doc_hide=True - ), "order": SpecField( type=FieldType.string, description=[ diff --git a/plugins/module_utils/linode_helper.py b/plugins/module_utils/linode_helper.py index 43124162..f2d69ed4 100644 --- a/plugins/module_utils/linode_helper.py +++ b/plugins/module_utils/linode_helper.py @@ -9,6 +9,7 @@ LinodeClient, LKENodePool, LKENodePoolNode, + LKENodePoolTaint, MappedObject, and_, ) @@ -203,6 +204,7 @@ def jsonify_node_pool(pool: LKENodePool) -> Dict[str, Any]: result = pool._raw_json result["nodes"] = [jsonify_node_pool_node(node) for node in pool.nodes] + result["taints"] = [jsonify_node_pool_taint(taint) for taint in pool.taints] return result @@ -217,6 +219,16 @@ def jsonify_node_pool_node(node: LKENodePoolNode) -> Dict[str, Any]: } +def jsonify_node_pool_taint(taint: LKENodePoolTaint) -> Dict[str, Any]: + """Converts an LKENodePoolTaint into a JSON-compatible dict""" + + return { + "key": taint.key, + "value": taint.value, + "effect": taint.effect, + } + + def validate_required(required_fields: Set[str], params: Dict[str, Any]): """Returns whether the given parameters contain all of the required fields specified.""" diff --git a/plugins/modules/database_engine_list.py b/plugins/modules/database_engine_list.py index 618f5933..65c56676 100644 --- a/plugins/modules/database_engine_list.py +++ b/plugins/modules/database_engine_list.py @@ -49,9 +49,6 @@ } spec = { - # Disable the default values - "state": SpecField(type=FieldType.string, required=False, doc_hide=True), - "label": SpecField(type=FieldType.string, required=False, doc_hide=True), "order": SpecField( type=FieldType.string, description=["The order to list database engine types in."], diff --git a/plugins/modules/database_list.py b/plugins/modules/database_list.py index 321e6fcf..1cceb056 100644 --- a/plugins/modules/database_list.py +++ b/plugins/modules/database_list.py @@ -50,9 +50,6 @@ } spec = { - # Disable the default values - "state": SpecField(type=FieldType.string, required=False, doc_hide=True), - "label": SpecField(type=FieldType.string, required=False, doc_hide=True), "order": SpecField( type=FieldType.string, description=["The order to list databases in."], diff --git a/plugins/modules/database_mysql_info.py b/plugins/modules/database_mysql_info.py index 910a7e4f..156e872d 100644 --- a/plugins/modules/database_mysql_info.py +++ b/plugins/modules/database_mysql_info.py @@ -37,8 +37,6 @@ from linode_api4 import MySQLDatabase spec = { - # Disable the default values - "state": SpecField(type=FieldType.string, required=False, doc_hide=True), "id": SpecField( type=FieldType.string, conflicts_with=["label"], diff --git a/plugins/modules/database_postgresql_info.py b/plugins/modules/database_postgresql_info.py index daa24097..5425180d 100644 --- a/plugins/modules/database_postgresql_info.py +++ b/plugins/modules/database_postgresql_info.py @@ -37,8 +37,6 @@ from linode_api4 import PostgreSQLDatabase spec = { - # Disable the default values - "state": SpecField(type=FieldType.string, required=False, doc_hide=True), "id": SpecField( type=FieldType.string, conflicts_with=["label"], diff --git a/plugins/modules/domain.py b/plugins/modules/domain.py index ca46b6ac..e1ed8ae1 100644 --- a/plugins/modules/domain.py +++ b/plugins/modules/domain.py @@ -29,8 +29,6 @@ from linode_api4 import Domain linode_domain_spec = { - # Unused for domain objects - "label": SpecField(type=FieldType.string, required=False, doc_hide=True), "axfr_ips": SpecField( type=FieldType.list, element_type=FieldType.string, diff --git a/plugins/modules/domain_record.py b/plugins/modules/domain_record.py index afa6a794..a591b1ac 100644 --- a/plugins/modules/domain_record.py +++ b/plugins/modules/domain_record.py @@ -28,8 +28,6 @@ from linode_api4 import Domain, DomainRecord linode_domain_record_spec = { - # Unused for domain record objects - "label": SpecField(type=FieldType.string, required=False, doc_hide=True), "domain_id": SpecField( type=FieldType.integer, description=["The ID of the parent Domain."] ), diff --git a/plugins/modules/instance.py b/plugins/modules/instance.py index eeb38bc6..d7740953 100644 --- a/plugins/modules/instance.py +++ b/plugins/modules/instance.py @@ -83,6 +83,12 @@ type=FieldType.string, description=["The filesystem to create this disk with."], ), + "disk_encryption": SpecField( + type=FieldType.string, + description="The disk encryption status of this disk." + + "NOTE: Disk encryption may not currently be available to all users.", + choices=["enabled", "disabled"], + ), "image": SpecField( type=FieldType.string, description=["An Image ID to deploy the Disk from."], @@ -523,6 +529,12 @@ suboptions=linode_instance_placement_group_spec, description=["A Placement Group to create this Linode under."], ), + "disk_encryption": SpecField( + type=FieldType.string, + description="The disk encryption status of this Linode. " + + "NOTE: Disk encryption may not currently be available to all users.", + choices=["enabled", "disabled"], + ), "swap_size": SpecField( type=FieldType.integer, description=[ diff --git a/plugins/modules/instance_type_list.py b/plugins/modules/instance_type_list.py index 6b60d597..16de88bb 100644 --- a/plugins/modules/instance_type_list.py +++ b/plugins/modules/instance_type_list.py @@ -18,10 +18,8 @@ result_docs_url="https://techdocs.akamai.com/linode-api/reference/get-linode-types", examples=docs.specdoc_examples, result_samples=docs.result_instance_type_samples, - description=[ - "**NOTE: This module has been deprecated in favor of `type_list`.", - "List and filter on Linode Instance Types.", - ], + deprecated=True, + deprecation_message="This module has been deprecated in favor of `type_list`.", ) SPECDOC_META = module.spec diff --git a/plugins/modules/ip_assign.py b/plugins/modules/ip_assign.py index 4d9e5594..0d95eec2 100644 --- a/plugins/modules/ip_assign.py +++ b/plugins/modules/ip_assign.py @@ -35,9 +35,6 @@ } spec = { - # Disable the default values - "state": SpecField(type=FieldType.string, required=False, doc_hide=True), - "label": SpecField(type=FieldType.string, required=False, doc_hide=True), "assignments": SpecField( type=FieldType.list, element_type=FieldType.dict, diff --git a/plugins/modules/ip_rdns.py b/plugins/modules/ip_rdns.py index 4cb85bdf..bbe305f5 100644 --- a/plugins/modules/ip_rdns.py +++ b/plugins/modules/ip_rdns.py @@ -26,8 +26,6 @@ from linode_api4 import ExplicitNullValue, IPAddress ip_rdns_spec = { - # Disable the default values - "label": SpecField(type=FieldType.string, required=False, doc_hide=True), "state": SpecField( type=FieldType.string, choices=["present", "absent"], diff --git a/plugins/modules/ip_share.py b/plugins/modules/ip_share.py index c2740078..a34dcabe 100644 --- a/plugins/modules/ip_share.py +++ b/plugins/modules/ip_share.py @@ -25,9 +25,6 @@ from linode_api4.objects import Instance ip_share_spec = { - # Disable the default values - "label": SpecField(type=FieldType.string, required=False, doc_hide=True), - "state": SpecField(type=FieldType.string, required=False, doc_hide=True), "ips": SpecField( type=FieldType.list, required=True, @@ -42,6 +39,12 @@ "The ID of the primary Linode that the addresses will be shared with." ], ), + "state": SpecField( + type=FieldType.string, + description=["The desired state of the target."], + choices=["present", "absent"], + required=True, + ), } SPECDOC_META = SpecDocMeta( diff --git a/plugins/modules/lke_cluster.py b/plugins/modules/lke_cluster.py index 1fe8ee49..b355e859 100644 --- a/plugins/modules/lke_cluster.py +++ b/plugins/modules/lke_cluster.py @@ -112,6 +112,28 @@ ), } +linode_lke_cluster_taint = { + "key": SpecField( + type=FieldType.string, + description=["The Kubernetes taint key."], + required=True, + editable=True, + ), + "value": SpecField( + type=FieldType.string, + description=["The Kubernetes taint value."], + required=True, + editable=True, + ), + "effect": SpecField( + type=FieldType.string, + description=["The Kubernetes taint effect."], + required=True, + editable=True, + choices=["NoSchedule", "PreferNoSchedule", "NoExecute"], + ), +} + linode_lke_cluster_node_pool_spec = { "count": SpecField( type=FieldType.integer, @@ -133,6 +155,23 @@ ], suboptions=linode_lke_cluster_autoscaler, ), + "labels": SpecField( + type=FieldType.dict, + editable=True, + description=[ + "Key-value pairs added as labels to nodes in the node pool. " + "Labels help classify your nodes and to easily select subsets of objects." + ], + ), + "taints": SpecField( + type=FieldType.list, + editable=True, + description=[ + "Kubernetes taints to add to node pool nodes. Taints help control " + "how pods are scheduled onto nodes, specifically allowing them to repel certain pods." + ], + suboptions=linode_lke_cluster_taint, + ), } linode_lke_cluster_spec = { @@ -199,6 +238,12 @@ ], default=600, ), + "state": SpecField( + type=FieldType.string, + description=["The desired state of the target."], + choices=["present", "absent"], + required=True, + ), } SPECDOC_META = SpecDocMeta( @@ -421,6 +466,7 @@ def _cluster_put_updates(self, cluster: LKECluster) -> None: self._attempt_update_acl(cluster) + # pylint: disable=too-many-statements def _update_cluster(self, cluster: LKECluster) -> None: """Handles all update functionality for the current LKE cluster""" @@ -468,6 +514,32 @@ def _update_cluster(self, cluster: LKECluster) -> None: current_pool.autoscaler = pool.get("autoscaler") current_pool.save() + if ( + "taints" in pool + and current_pool.taints != pool["taints"] + ): + self.register_action( + "Updated taints for Node Pool {}".format( + current_pool.id + ) + ) + + current_pool.taints = pool.get("taints") + current_pool.save() + + if ( + "labels" in pool + and current_pool.labels != pool["labels"] + ): + self.register_action( + "Updated labels for Node Pool {}".format( + current_pool.id + ) + ) + + current_pool.labels = pool.get("labels") + current_pool.save() + pools_handled[k] = True should_keep[i] = True break @@ -510,6 +582,32 @@ def _update_cluster(self, cluster: LKECluster) -> None: existing_pool.autoscaler = pool["autoscaler"] should_update = True + if ( + "taints" in pool + and existing_pool.taints != pool["taints"] + ): + self.register_action( + "Updated taints for Node Pool {}".format( + existing_pool.id + ) + ) + + existing_pool.taints = pool["taints"] + should_update = True + + if ( + "labels" in pool + and existing_pool.labels != pool["labels"] + ): + self.register_action( + "Updated labels for Node Pool {}".format( + existing_pool.id + ) + ) + + existing_pool.labels = pool["labels"] + should_update = True + if should_update: existing_pool.save() @@ -653,7 +751,7 @@ def _handle_absent(self) -> None: self.register_action("Deleted cluster {0}".format(cluster)) def exec_module(self, **kwargs: Any) -> Optional[dict]: - """Entrypoint for Domain module""" + """Entrypoint for LKE Cluster module""" state = kwargs.get("state") if state == "absent": diff --git a/plugins/modules/lke_cluster_info.py b/plugins/modules/lke_cluster_info.py index c5061745..754deff9 100644 --- a/plugins/modules/lke_cluster_info.py +++ b/plugins/modules/lke_cluster_info.py @@ -36,8 +36,6 @@ from linode_api4 import ApiError, LKECluster linode_lke_cluster_info_spec = { - # We need to overwrite attributes to exclude them as requirements - "state": SpecField(type=FieldType.string, required=False, doc_hide=True), "id": SpecField( type=FieldType.integer, required=False, diff --git a/plugins/modules/lke_node_pool.py b/plugins/modules/lke_node_pool.py index f5ec96e5..45531e2d 100644 --- a/plugins/modules/lke_node_pool.py +++ b/plugins/modules/lke_node_pool.py @@ -69,8 +69,29 @@ ), } +linode_lke_pool_taint = { + "key": SpecField( + type=FieldType.string, + description=["The Kubernetes taint key."], + required=True, + editable=True, + ), + "value": SpecField( + type=FieldType.string, + description=["The Kubernetes taint value."], + required=True, + editable=True, + ), + "effect": SpecField( + type=FieldType.string, + description=["The Kubernetes taint effect."], + required=True, + editable=True, + choices=["NoSchedule", "PreferNoSchedule", "NoExecute"], + ), +} + MODULE_SPEC = { - "label": SpecField(type=FieldType.string, required=False, doc_hide=True), "cluster_id": SpecField( type=FieldType.integer, required=True, @@ -140,6 +161,23 @@ ], default=600, ), + "labels": SpecField( + type=FieldType.dict, + editable=True, + description=[ + "Key-value pairs added as labels to nodes in the node pool. " + "Labels help classify your nodes and to easily select subsets of objects." + ], + ), + "taints": SpecField( + type=FieldType.list, + editable=True, + description=[ + "Kubernetes taints to add to node pool nodes. Taints help control " + "how pods are scheduled onto nodes, specifically allowing them to repel certain pods." + ], + suboptions=linode_lke_pool_taint, + ), } SPECDOC_META = SpecDocMeta( @@ -251,6 +289,8 @@ def _update_pool(self, pool: LKENodePool) -> LKENodePool: params.pop("autoscaler") if "autoscaler" in params else None ) new_count = params.pop("count") + new_taints = params.pop("taints") if "taints" in params else None + new_labels = params.pop("labels") if "labels" in params else None try: handle_updates(pool, params, set(), self.register_action) @@ -276,6 +316,16 @@ def _update_pool(self, pool: LKENodePool) -> LKENodePool: pool.autoscaler = new_autoscaler should_update = True + if new_taints is not None and pool.taints != new_taints: + self.register_action("Updated taints for Node Pool") + pool.taints = new_taints + should_update = True + + if new_labels is not None and pool.labels != new_labels: + self.register_action("Updated labels for Node Pool") + pool.labels = new_labels + should_update = True + if should_update: try: pool.save() diff --git a/plugins/modules/lke_version_list.py b/plugins/modules/lke_version_list.py index c0224400..97dbe869 100644 --- a/plugins/modules/lke_version_list.py +++ b/plugins/modules/lke_version_list.py @@ -1,67 +1,28 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -"""This module allows users to list Linode instances.""" -from __future__ import absolute_import, division, print_function +"""This module allows users to list Linode LKE Versions.""" -from typing import Any, Dict, Optional +from __future__ import absolute_import, division, print_function -import ansible_collections.linode.cloud.plugins.module_utils.doc_fragments.lke_version_list as docs -from ansible_collections.linode.cloud.plugins.module_utils.linode_common import ( - LinodeModuleBase, -) -from ansible_collections.linode.cloud.plugins.module_utils.linode_docs import ( - global_authors, - global_requirements, -) -from ansible_collections.linode.cloud.plugins.module_utils.linode_helper import ( - get_all_paginated, +from ansible_collections.linode.cloud.plugins.module_utils.doc_fragments import ( + lke_version_list as docs, ) -from ansible_specdoc.objects import ( - FieldType, - SpecDocMeta, - SpecField, - SpecReturnValue, +from ansible_collections.linode.cloud.plugins.module_utils.linode_common_list import ( + ListModule, ) -spec = { - # Disable the default values - "state": SpecField(type=FieldType.string, required=False, doc_hide=True), - "label": SpecField(type=FieldType.string, required=False, doc_hide=True), - "order": SpecField( - type=FieldType.string, - description=["The order to list lke versions in."], - default="asc", - choices=["desc", "asc"], - ), - "count": SpecField( - type=FieldType.integer, - description=[ - "The number of results to return.", - "If undefined, all results will be returned.", - ], - ), -} - -SPECDOC_META = SpecDocMeta( - description=[ - "List Kubernetes versions available for deployment to a Kubernetes cluster." - ], - requirements=global_requirements, - author=global_authors, - options=spec, +module = ListModule( + result_display_name="LKE Versions", + result_field_name="lke_versions", + endpoint_template="/lke/versions", + result_docs_url="https://techdocs.akamai.com/linode-api/reference/get-lke-versions", + result_samples=docs.result_lke_versions_samples, examples=docs.specdoc_examples, - return_values={ - "lke_versions": SpecReturnValue( - description="The returned LKE versions.", - docs_url="https://techdocs.akamai.com/linode-api/reference/get-lke-versions", - type=FieldType.list, - elements=FieldType.dict, - sample=docs.result_lke_versions_samples, - ) - }, ) +SPECDOC_META = module.spec + DOCUMENTATION = r""" """ EXAMPLES = r""" @@ -69,33 +30,5 @@ RETURN = r""" """ - -class Module(LinodeModuleBase): - """Module for getting a list of Kubernetes versions""" - - def __init__(self) -> None: - self.module_arg_spec = SPECDOC_META.ansible_spec - self.results: Dict[str, Any] = {"lke_versions": []} - - super().__init__(module_arg_spec=self.module_arg_spec) - - def exec_module(self, **kwargs: Any) -> Optional[dict]: - """Entrypoint for lke version list module""" - - self.results["lke_versions"] = get_all_paginated( - self.client, - "/lke/versions", - None, - num_results=self.module.params["count"], - ) - - return self.results - - -def main() -> None: - """Constructs and calls the module""" - Module() - - if __name__ == "__main__": - main() + module.run() diff --git a/plugins/modules/object_cluster_list.py b/plugins/modules/object_cluster_list.py index 277f875a..d857f1b5 100644 --- a/plugins/modules/object_cluster_list.py +++ b/plugins/modules/object_cluster_list.py @@ -1,107 +1,33 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -"""This module allows users to list Object Storage clusters.""" -from __future__ import absolute_import, division, print_function +"""This module allows users to list Linode Object Storage clusters. .""" -from typing import Any, Dict, Optional +from __future__ import absolute_import, division, print_function from ansible_collections.linode.cloud.plugins.module_utils.doc_fragments import ( object_cluster_list as docs, ) -from ansible_collections.linode.cloud.plugins.module_utils.linode_common import ( - LinodeModuleBase, -) -from ansible_collections.linode.cloud.plugins.module_utils.linode_docs import ( - global_authors, - global_requirements, -) -from ansible_collections.linode.cloud.plugins.module_utils.linode_helper import ( - construct_api_filter, - get_all_paginated, -) -from ansible_specdoc.objects import ( - FieldType, - SpecDocMeta, - SpecField, - SpecReturnValue, +from ansible_collections.linode.cloud.plugins.module_utils.linode_common_list import ( + ListModule, ) -spec_filter = { - "name": SpecField( - type=FieldType.string, - required=True, - description=[ - "The name of the field to filter on.", - "Valid filterable attributes can be found here: " - "https://techdocs.akamai.com/linode-api/reference/get-object-storage-buckets", - ], - ), - "values": SpecField( - type=FieldType.list, - element_type=FieldType.string, - required=True, - description=[ - "A list of values to allow for this field.", - "Fields will pass this filter if at least one of these values matches.", - ], - ), -} - -spec = { - # Disable the default values - "state": SpecField(type=FieldType.string, required=False, doc_hide=True), - "label": SpecField(type=FieldType.string, required=False, doc_hide=True), - "order": SpecField( - type=FieldType.string, - description=["The order to list object storage clusters in."], - default="asc", - choices=["desc", "asc"], - ), - "order_by": SpecField( - type=FieldType.string, - description=["The attribute to order object storage clusters by."], - ), - "filters": SpecField( - type=FieldType.list, - element_type=FieldType.dict, - suboptions=spec_filter, - description=[ - "A list of filters to apply to the resulting object storage clusters." - ], - ), - "count": SpecField( - type=FieldType.integer, - description=[ - "The number of results to return.", - "If undefined, all results will be returned.", - ], - ), -} - -SPECDOC_META = SpecDocMeta( - description=[ - "**NOTE: This module has been deprecated because it " - + "relies on deprecated API endpoints. Going forward, `region` will " - + "be the preferred way to designate where Object Storage resources " - + "should be created.**", - "List and filter on Object Storage Clusters.", - ], - requirements=global_requirements, - author=global_authors, - options=spec, +module = ListModule( + result_display_name="Object Storage Clusters", + result_field_name="clusters", + endpoint_template="/object-storage/clusters", + result_docs_url="https://techdocs.akamai.com/linode-api/reference/get-object-storage-clusters", + result_samples=docs.result_object_clusters_samples, examples=docs.specdoc_examples, - return_values={ - "clusters": SpecReturnValue( - description="The returned object storage clusters.", - docs_url="https://techdocs.akamai.com/linode-api/reference/get-object-storage-clusters", - type=FieldType.list, - elements=FieldType.dict, - sample=docs.result_object_clusters_samples, - ) - }, + deprecated=True, + deprecation_message="This module has been deprecated because it " + + "relies on deprecated API endpoints. Going forward, `region` will " + + "be the preferred way to designate where Object Storage resources " + + "should be created.", ) +SPECDOC_META = module.spec + DOCUMENTATION = r""" """ EXAMPLES = r""" @@ -109,41 +35,5 @@ RETURN = r""" """ - -class Module(LinodeModuleBase): - """Module for getting a list of Object Storage Clusters""" - - def __init__(self) -> None: - self.module_arg_spec = SPECDOC_META.ansible_spec - self.results: Dict[str, Any] = {"clusters": []} - - super().__init__(module_arg_spec=self.module_arg_spec) - - def exec_module(self, **kwargs: Any) -> Optional[dict]: - """Entrypoint for object storage cluster list module""" - - self.warn( - "The linode.cloud.object_cluster_list has been deprecated because it relies " - "on deprecated API endpoints.\n" - "Going forward, region will be the preferred way to designate where Object " - "Storage resources should be created." - ) - - filter_dict = construct_api_filter(self.module.params) - - self.results["clusters"] = get_all_paginated( - self.client, - "/object-storage/clusters", - filter_dict, - num_results=self.module.params["count"], - ) - return self.results - - -def main() -> None: - """Constructs and calls the module""" - Module() - - if __name__ == "__main__": - main() + module.run() diff --git a/plugins/modules/placement_group.py b/plugins/modules/placement_group.py index 1c42a1e8..0e26c094 100644 --- a/plugins/modules/placement_group.py +++ b/plugins/modules/placement_group.py @@ -55,6 +55,12 @@ ], choices=["flexible", "strict"], ), + "state": SpecField( + type=FieldType.string, + description=["The desired state of the target."], + choices=["present", "absent"], + required=True, + ), } SPECDOC_META = SpecDocMeta( diff --git a/plugins/modules/placement_group_assign.py b/plugins/modules/placement_group_assign.py index 7c66298f..88cee007 100644 --- a/plugins/modules/placement_group_assign.py +++ b/plugins/modules/placement_group_assign.py @@ -22,8 +22,6 @@ from linode_api4 import PlacementGroup placement_group_assignment_spec = { - # Disable the default values - "label": SpecField(type=FieldType.string, required=False, doc_hide=True), "placement_group_id": SpecField( type=FieldType.integer, required=True, @@ -41,6 +39,12 @@ description=[], doc_hide=True, ), + "state": SpecField( + type=FieldType.string, + description=["The desired state of the target."], + choices=["present", "absent"], + required=True, + ), } SPECDOC_META = SpecDocMeta( diff --git a/plugins/modules/user.py b/plugins/modules/user.py index 1d582ff7..daeb5198 100644 --- a/plugins/modules/user.py +++ b/plugins/modules/user.py @@ -165,11 +165,6 @@ } SPEC = { - # We don't use label for this module - "label": SpecField( - type=FieldType.string, - doc_hide=True, - ), "username": SpecField( type=FieldType.string, required=True, @@ -377,7 +372,8 @@ def _create_user(self) -> Optional[User]: k: v for k, v in params.items() if k - not in list(LINODE_COMMON_ARGS.keys()) + ["grants", "ua_prefix"] + not in list(LINODE_COMMON_ARGS.keys()) + + ["grants", "ua_prefix", "state"] } try: diff --git a/requirements.txt b/requirements.txt index 856067fa..ec5774d6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -linode-api4>=5.20.0 +linode-api4>=5.21.0 polling>=0.3.2 -types-requests==2.32.0.20240712 +types-requests==2.32.0.20240914 ansible-specdoc>=0.0.15 diff --git a/tests/integration/targets/instance_disk_encryption/tasks/main.yaml b/tests/integration/targets/instance_disk_encryption/tasks/main.yaml new file mode 100644 index 00000000..cbb92667 --- /dev/null +++ b/tests/integration/targets/instance_disk_encryption/tasks/main.yaml @@ -0,0 +1,143 @@ +- name: instance_disk_encryption + block: + - set_fact: + r: "{{ 1000000000 | random }}" + + - name: List regions that support Disk Encryption + linode.cloud.region_list: {} + register: all_regions + + - set_fact: + lde_region: '{{ (all_regions.regions | selectattr("capabilities", "search", "Disk Encryption") | list)[0].id }}' + + - name: Create a Linode instance with disk encryption set + linode.cloud.instance: + label: 'ansible-test-disk-encryption-{{ r }}' + region: '{{ lde_region }}' + type: g6-standard-1 + image: linode/ubuntu22.04 + private_ip: true + wait: false + state: present + firewall_id: '{{ firewall_id }}' + disk_encryption: 'enabled' + register: create_instance_with_disk_encryption + + - name: Assert instance created + assert: + that: + - create_instance_with_disk_encryption.changed + - create_instance_with_disk_encryption.instance.disk_encryption == 'enabled' + + - name: Create a Linode instance with explicit disks with disk encryption set + linode.cloud.instance: + label: 'ansible-test-disks-disk-encryption-{{ r }}' + region: '{{ lde_region }}' + type: g6-standard-1 + booted: false + disks: + - label: test-disk + filesystem: ext4 + size: 5000 + state: present + firewall_id: '{{ firewall_id }}' + disk_encryption: 'enabled' + register: create_instance_disks_disk_encryption + + - name: Assert instance created + assert: + that: + - create_instance_disks_disk_encryption.changed + - create_instance_disks_disk_encryption.instance.disk_encryption == 'enabled' + - create_instance_disks_disk_encryption.disks[0].disk_encryption == 'enabled' + + - name: Create a small Linode instance with two disks that sum up to its max size + linode.cloud.instance: + label: 'ansible-test-disks-max-size-{{ r }}' + region: '{{ lde_region }}' + type: g6-nanode-1 + booted: false + disks: + - label: test-disk-1 + filesystem: ext4 + size: 15000 + - label: test-disk-2 + filesystem: ext4 + size: 10000 + state: present + firewall_id: '{{ firewall_id }}' + disk_encryption: 'enabled' + register: create_instance_disks_max_size + + - name: Assert instance created + assert: + that: + - create_instance_disks_max_size.changed + - create_instance_disks_max_size.disks[0].size == 15000 + - create_instance_disks_max_size.disks[1].size == 10000 + + - name: Update the instance to resize test-disk-1 and test-disk-2 + linode.cloud.instance: + label: "{{ create_instance_disks_max_size.instance.label }}" + disks: + - label: test-disk-1 + filesystem: ext4 + size: 14500 + - label: test-disk-2 + filesystem: ext4 + size: 10500 + state: present + register: resize_disks + + - name: Assert instance created + assert: + that: + - resize_disks.changed + - resize_disks.disks[0].size == 14500 + - resize_disks.disks[1].size == 10500 + + always: + - ignore_errors: yes + block: + - name: Delete a Linode instance + linode.cloud.instance: + label: 'ansible-test-disk-encryption-{{ r }}' + state: absent + register: delete_disk_encryption + + - name: Assert instance delete succeeded + assert: + that: + - delete_disk_encryption.changed + - delete_disk_encryption.instance.id == create_instance_with_disk_encryption.instance.id + + - name: Delete a Linode instance + linode.cloud.instance: + label: 'ansible-test-disks-disk-encryption-{{ r }}' + state: absent + register: delete_disks_disk_encryption + + - name: Assert instance delete succeeded + assert: + that: + - delete_disks_disk_encryption.changed + - delete_disks_disk_encryption.instance.id == create_instance_disks_disk_encryption.instance.id + + - name: Delete a Linode instance + linode.cloud.instance: + label: 'ansible-test-disks-max-size-{{ r }}' + state: absent + register: delete_disks_max_size + + - name: Assert instance delete succeeded + assert: + that: + - delete_disks_max_size.changed + - delete_disks_max_size.instance.id == create_instance_disks_max_size.instance.id + + environment: + LINODE_UA_PREFIX: '{{ ua_prefix }}' + LINODE_API_TOKEN: '{{ api_token }}' + LINODE_API_URL: '{{ api_url }}' + LINODE_API_VERSION: '{{ api_version }}' + LINODE_CA: '{{ ca_file or "" }}' \ No newline at end of file diff --git a/tests/integration/targets/lke_cluster_basic/tasks/main.yaml b/tests/integration/targets/lke_cluster_basic/tasks/main.yaml index 3da2258e..203f3eba 100644 --- a/tests/integration/targets/lke_cluster_basic/tasks/main.yaml +++ b/tests/integration/targets/lke_cluster_basic/tasks/main.yaml @@ -16,6 +16,13 @@ # Sometimes only one LKE version is available for provisioning kube_version: '{{ lke_versions[1].id if lke_versions|length > 1 else lke_versions[0].id }}' + - name: List regions that support Disk Encryption + linode.cloud.region_list: {} + register: all_regions + + - set_fact: + lde_region: '{{ (all_regions.regions | selectattr("capabilities", "search", "Disk Encryption") | list)[0].id }}' + - name: Create a Linode LKE cluster linode.cloud.lke_cluster: label: 'ansible-test-{{ r }}' @@ -24,6 +31,13 @@ node_pools: - type: g6-standard-1 count: 3 + labels: + foo.example.com/test: bar + foo.example.com/test2: foo + taints: + - key: foo.example.com/test2 + value: test + effect: NoExecute - type: g6-standard-4 count: 1 autoscaler: @@ -41,6 +55,11 @@ - create_cluster.cluster.region == 'us-southeast' - create_cluster.node_pools[0].type == 'g6-standard-1' - create_cluster.node_pools[0].count == 3 + - create_cluster.node_pools[0].labels['foo.example.com/test'] == 'bar' + - create_cluster.node_pools[0].labels['foo.example.com/test2'] == 'foo' + - create_cluster.node_pools[0].taints[0].key == 'foo.example.com/test2' + - create_cluster.node_pools[0].taints[0].value == 'test' + - create_cluster.node_pools[0].taints[0].effect == 'NoExecute' - create_cluster.node_pools[1].autoscaler.enabled - create_cluster.node_pools[1].autoscaler.min == 1 - create_cluster.node_pools[1].autoscaler.max == 2 @@ -54,6 +73,13 @@ node_pools: - type: g6-standard-1 count: 2 + labels: + foo.example.com/update: updated + foo.example.com/test2: foo + taints: + - key: foo.example.com/update + value: updated + effect: PreferNoSchedule - type: g6-standard-2 count: 1 - type: g6-standard-1 @@ -73,6 +99,12 @@ - update_pools.node_pools[0].count == 2 - update_pools.node_pools[0].id == create_cluster.node_pools[0].id + - update_pools.node_pools[0].labels['foo.example.com/update'] == 'updated' + - update_pools.node_pools[0].labels['foo.example.com/test2'] == 'foo' + - update_pools.node_pools[0].taints[0].key == 'foo.example.com/update' + - update_pools.node_pools[0].taints[0].value == 'updated' + - update_pools.node_pools[0].taints[0].effect == 'PreferNoSchedule' + - update_pools.node_pools[1].type == 'g6-standard-2' - update_pools.node_pools[1].count == 1 - update_pools.node_pools[2].type == 'g6-standard-1' @@ -114,8 +146,8 @@ - name: Get lke_cluster_info about the cluster by id linode.cloud.lke_cluster_info: id: '{{ upgrade.cluster.id }}' - - + + register: info_by_id - name: Assert lke_cluster_info about cluster by id @@ -147,6 +179,23 @@ - info_by_label.node_pools[0].count == 1 - info_by_label.node_pools[0].id == create_cluster.node_pools[0].id + - name: Create a Linode LKE cluster with a pool with disk encryption enabled + linode.cloud.lke_cluster: + label: 'ansible-test-de-{{ r }}' + region: '{{ lde_region }}' + k8s_version: '{{ old_kube_version }}' + node_pools: + - type: g6-standard-1 + count: 3 + skip_polling: true + state: present + register: create_cluster_disk_encryption + + - name: Assert LKE cluster is created + assert: + that: + - create_cluster_disk_encryption.node_pools[0].disk_encryption == 'enabled' + always: - ignore_errors: yes block: @@ -155,6 +204,12 @@ label: '{{ create_cluster.cluster.label }}' state: absent + - name: Delete the LKE cluster + linode.cloud.lke_cluster: + label: '{{ create_cluster_disk_encryption.cluster.label }}' + state: absent + + environment: LINODE_UA_PREFIX: '{{ ua_prefix }}' LINODE_API_TOKEN: '{{ api_token }}' diff --git a/tests/integration/targets/lke_node_pool_basic/tasks/main.yaml b/tests/integration/targets/lke_node_pool_basic/tasks/main.yaml index 92c3cede..52b35ccc 100644 --- a/tests/integration/targets/lke_node_pool_basic/tasks/main.yaml +++ b/tests/integration/targets/lke_node_pool_basic/tasks/main.yaml @@ -10,6 +10,13 @@ - set_fact: kube_version: '{{ lke_versions.lke_versions[0].id }}' + - name: List regions that support Disk Encryption + linode.cloud.region_list: {} + register: all_regions + + - set_fact: + lde_region: '{{ (all_regions.regions | selectattr("capabilities", "search", "Disk Encryption") | list)[0].id }}' + - name: Create a minimal LKE cluster linode.cloud.lke_cluster: label: 'ansible-test-{{ r }}' @@ -37,6 +44,13 @@ tags: ['my-pool'] type: g6-standard-1 count: 2 + labels: + foo.example.com/test: bar + foo.example.com/test2: foo + taints: + - key: foo.example.com/test2 + value: test + effect: NoExecute state: present register: new_pool @@ -47,6 +61,11 @@ - new_pool.node_pool.type == 'g6-standard-1' - new_pool.node_pool.nodes[0].status == 'ready' - new_pool.node_pool.nodes[1].status == 'ready' + - new_pool.node_pool.labels['foo.example.com/test'] == 'bar' + - new_pool.node_pool.labels['foo.example.com/test2'] == 'foo' + - new_pool.node_pool.taints[0].key == 'foo.example.com/test2' + - new_pool.node_pool.taints[0].value == 'test' + - new_pool.node_pool.taints[0].effect == 'NoExecute' - name: Attempt to update an invalid field on the node pool linode.cloud.lke_node_pool: @@ -71,6 +90,13 @@ enabled: true min: 1 max: 3 + labels: + foo.example.com/update: updated + foo.example.com/test2: foo + taints: + - key: foo.example.com/update + value: updated + effect: PreferNoSchedule state: present register: update_pool @@ -82,6 +108,49 @@ - update_pool.node_pool.autoscaler.enabled - update_pool.node_pool.autoscaler.min == 1 - update_pool.node_pool.autoscaler.max == 3 + - update_pool.node_pool.labels['foo.example.com/update'] == 'updated' + - update_pool.node_pool.labels['foo.example.com/test2'] == 'foo' + - update_pool.node_pool.taints[0].key == 'foo.example.com/update' + - update_pool.node_pool.taints[0].value == 'updated' + - update_pool.node_pool.taints[0].effect == 'PreferNoSchedule' + + - name: Create a minimal LKE cluster + linode.cloud.lke_cluster: + label: 'ansible-test-de-{{ r }}' + region: '{{ lde_region }}' + k8s_version: '{{ kube_version }}' + node_pools: + - type: g6-standard-1 + count: 1 + skip_polling: true + state: present + register: create_cluster_de + + - name: Assert minimal LKE cluster is created + assert: + that: + - create_cluster_de.cluster.k8s_version == kube_version + - create_cluster_de.node_pools[0].type == 'g6-standard-1' + - create_cluster_de.node_pools[0].count == 1 + + - name: Add a node pool to the cluster + linode.cloud.lke_node_pool: + cluster_id: '{{ create_cluster_de.cluster.id }}' + + tags: ['my-pool'] + type: g6-standard-1 + count: 2 + state: present + register: new_pool_de + + - name: Assert node pool is added to cluster + assert: + that: + - new_pool_de.node_pool.count == 2 + - new_pool_de.node_pool.type == 'g6-standard-1' + - new_pool_de.node_pool.disk_encryption == 'enabled' + - new_pool_de.node_pool.nodes[0].status == 'ready' + - new_pool_de.node_pool.nodes[1].status == 'ready' always: - ignore_errors: yes @@ -95,6 +164,15 @@ linode.cloud.lke_cluster: label: '{{ create_cluster.cluster.label }}' state: absent + - name: Delete the LKE cluster node pool + linode.cloud.lke_node_pool: + cluster_id: '{{ create_cluster_de.cluster.id }}' + tags: ['my-pool'] + state: absent + - name: Delete the LKE cluster + linode.cloud.lke_cluster: + label: '{{ create_cluster_de.cluster.label }}' + state: absent environment: LINODE_UA_PREFIX: '{{ ua_prefix }}' diff --git a/tests/integration/targets/object_cluster_list/tasks/main.yaml b/tests/integration/targets/object_cluster_list/tasks/main.yaml index 49acd90d..2bced3f2 100644 --- a/tests/integration/targets/object_cluster_list/tasks/main.yaml +++ b/tests/integration/targets/object_cluster_list/tasks/main.yaml @@ -10,18 +10,6 @@ # - assert: # that: # - no_filter.clusters | length >= 1 -# -# - name: List regions with filter on region -# linode.cloud.object_cluster_list: -# filters: -# - name: region -# values: us-ord -# register: filter -# -# - assert: -# that: -# - filter.clusters | length >= 1 -# - filter.clusters[0].region == 'us-ord' environment: LINODE_UA_PREFIX: '{{ ua_prefix }}'