Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/checkout@v4
-
name: Run Labeler
uses: crazy-max/ghaction-github-labeler@31674a3852a9074f2086abcf1c53839d466a47e7
uses: crazy-max/ghaction-github-labeler@24d110aa46a59976b8a7f35518cb7f14f434c916
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
yaml-file: .github/labels.yml
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ name: Run Unit test

jobs:
run-tests:

# TODO:
# Upgrade back to ubuntu-latest when the permission issue fixed
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.9','3.10','3.11', '3.12' ]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Name | Description |
[linode.cloud.ip_info](./docs/modules/ip_info.md)|Get info about a Linode IP.|
[linode.cloud.ipv6_range_info](./docs/modules/ipv6_range_info.md)|Get info about a Linode IPv6 range.|
[linode.cloud.lke_cluster_info](./docs/modules/lke_cluster_info.md)|Get info about a Linode LKE cluster.|
[linode.cloud.lke_version_info](./docs/modules/lke_version_info.md)|Get info about a Linode LKE Version.|
[linode.cloud.nodebalancer_info](./docs/modules/nodebalancer_info.md)|Get info about a Linode Node Balancer.|
[linode.cloud.object_cluster_info](./docs/modules/object_cluster_info.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_info](./docs/modules/placement_group_info.md)|Get info about a Linode Placement Group.|
Expand Down
3 changes: 2 additions & 1 deletion docs/modules/lke_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ Manage Linode LKE clusters.
| `k8s_version` | <center>`str`</center> | <center>Optional</center> | The desired Kubernetes version for this Kubernetes cluster in the format of <major>.<minor>, and the latest supported patch version will be deployed. A version upgrade requires that you manually recycle the nodes in your cluster. **(Updatable)** |
| `region` | <center>`str`</center> | <center>Optional</center> | This Kubernetes cluster’s location. |
| `tags` | <center>`list`</center> | <center>Optional</center> | An array of tags applied to the Kubernetes cluster. |
| `high_availability` | <center>`bool`</center> | <center>Optional</center> | Defines whether High Availability is enabled for the Control Plane Components of the cluster. **(Default: `False`; Updatable)** |
| `high_availability` | <center>`bool`</center> | <center>Optional</center> | Defines whether High Availability is enabled for the Control Plane Components of the cluster. **(Updatable)** |
| [`acl` (sub-options)](#acl) | <center>`dict`</center> | <center>Optional</center> | The ACL configuration for this cluster's control plane. **(Updatable)** |
| [`node_pools` (sub-options)](#node_pools) | <center>`list`</center> | <center>Optional</center> | A list of node pools to configure the cluster with **(Updatable)** |
| `skip_polling` | <center>`bool`</center> | <center>Optional</center> | If true, the module will not wait for all nodes in the cluster to be ready. **(Default: `False`)** |
| `wait_timeout` | <center>`int`</center> | <center>Optional</center> | The period to wait for the cluster to be ready in seconds. **(Default: `600`)** |
| `apl_enabled` | <center>`bool`</center> | <center>Optional</center> | Whether this cluster should use APL. NOTE: This endpoint is in beta. **(Default: `False`)** |
| `tier` | <center>`str`</center> | <center>Optional</center> | The desired tier of the LKE Cluster. NOTE: LKE Enterprise may not currently be available to all users and can only be used with v4beta. **(Choices: `standard`, `enterprise`)** |

### acl

Expand Down
2 changes: 2 additions & 0 deletions docs/modules/lke_node_pool.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Manage Linode LKE cluster node pools.
| `wait_timeout` | <center>`int`</center> | <center>Optional</center> | The period to wait for the node pool to be ready in seconds. **(Default: `600`)** |
| `labels` | <center>`dict`</center> | <center>Optional</center> | 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) | <center>`list`</center> | <center>Optional</center> | 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)** |
| `k8s_version` | <center>`str`</center> | <center>Optional</center> | The desired Kubernetes version for this Kubernetes Node Pool in the format of <major>.<minor>, and the latest supported patch version. NOTE: Only available for LKE Enterprise to support node pool upgrades. This field may not currently be available to all users and is under v4beta. **(Updatable)** |
| `update_strategy` | <center>`str`</center> | <center>Optional</center> | Upgrade strategy describes the available upgrade strategies. NOTE: Only available for LKE Enterprise to support node pool upgrades. This field may not currently be available to all users and is under v4beta. **(Choices: `rolling_update`, `on_recycle`; Updatable)** |

### autoscaler

Expand Down
62 changes: 62 additions & 0 deletions docs/modules/lke_version_info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# lke_version_info

Get info about a Linode LKE Version.

- [Minimum Required Fields](#minimum-required-fields)
- [Examples](#examples)
- [Parameters](#parameters)
- [Return Values](#return-values)

## Minimum Required Fields
| Field | Type | Required | Description |
|-------------|-------|--------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `api_token` | `str` | **Required** | The Linode account personal access token. It is necessary to run the module. <br/>It can be exposed by the environment variable `LINODE_API_TOKEN` instead. <br/>See details in [Usage](https://github.com/linode/ansible_linode?tab=readme-ov-file#usage). |

## Examples

```yaml
- name: Get info about an LKE version by ID
linode.cloud.lke_cluster_info:
id: '1.31'

```

```yaml
- name: Get info about an LKE version by tier and ID
linode.cloud.lke_cluster_info:
tier: 'standard'
id: '1.31'

```


## Parameters

| Field | Type | Required | Description |
|-----------|------|----------|------------------------------------------------------------------------------|
| `id` | <center>`str`</center> | <center>**Required**</center> | The ID of the LKE Version to resolve. |
| `tier` | <center>`str`</center> | <center>Optional</center> | Specifies the service tier for retrieving LKE version details. NOTE: LKE Enterprise may not currently be available to all users and can only be used with v4beta. **(Choices: `standard`, `enterprise`)** |

## Return Values

- `lke_version` - The returned LKE Version.

- Sample Response:
```json

{
"id": "1.31"
}

```
```json

{
"id": "1.31",
"tier": "standard"
}

```
- See the [Linode API response documentation](https://techdocs.akamai.com/linode-api/reference/get-lke-version) for a list of returned fields


41 changes: 34 additions & 7 deletions docs/modules/lke_version_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ List and filter on LKE Versions.
## Examples

```yaml
- name: List all Kubernetes versions available for deployment to a Kubernetes cluster
linode.cloud.lke_version_list: {}
- name: List all Kubernetes versions available for deployment to a Kubernetes cluster
linode.cloud.lke_version_list:

```

```yaml
- name: List all enterprise-tier Kubernetes versions available for deployment to a Kubernetes cluster
linode.cloud.lke_version_list:
tier: "enterprise"

```


Expand All @@ -28,6 +36,7 @@ List and filter on LKE Versions.
| `order_by` | <center>`str`</center> | <center>Optional</center> | The attribute to order LKE Versions by. |
| [`filters` (sub-options)](#filters) | <center>`list`</center> | <center>Optional</center> | A list of filters to apply to the resulting LKE Versions. |
| `count` | <center>`int`</center> | <center>Optional</center> | The number of LKE Versions to return. If undefined, all results will be returned. |
| `tier` | <center>`str`</center> | <center>Optional</center> | Specifies the service tier for retrieving LKE version details. NOTE: LKE Enterprise may not currently be available to all users and can only be used with v4beta. **(Choices: `standard`, `enterprise`)** |

### filters

Expand All @@ -42,11 +51,29 @@ List and filter on LKE Versions.

- Sample Response:
```json
[
{
"id": "1.25"
}
]

[
{
"id": "1.32"
},
{
"id": "1.31"
},
{
"id": "1.30"
}
]

```
```json

[
{
"id": "v1.31.1+lke1",
"tier": "enterprise"
}
]

```
- See the [Linode API response documentation](https://techdocs.akamai.com/linode-api/reference/get-lke-versions) for a list of returned fields

Expand Down
28 changes: 28 additions & 0 deletions plugins/module_utils/doc_fragments/lke_version_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Documentation fragments for the lke_version_info module"""

specdoc_examples = [
'''
- name: Get info about an LKE version by ID
linode.cloud.lke_cluster_info:
id: '1.31'
''', '''
- name: Get info about an LKE version by tier and ID
linode.cloud.lke_cluster_info:
tier: 'standard'
id: '1.31'
'''
]

result_lke_version_samples = [
'''
{
"id": "1.31"
}
''',
'''
{
"id": "1.31",
"tier": "standard"
}
'''
]
41 changes: 33 additions & 8 deletions plugins/module_utils/doc_fragments/lke_version_list.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
"""Documentation fragments for the lke_version_list module"""

specdoc_examples = ['''
- name: List all Kubernetes versions available for deployment to a Kubernetes cluster
linode.cloud.lke_version_list: {}''']
specdoc_examples = [
'''
- name: List all Kubernetes versions available for deployment to a Kubernetes cluster
linode.cloud.lke_version_list:
''', '''
- name: List all enterprise-tier Kubernetes versions available for deployment to a Kubernetes cluster
linode.cloud.lke_version_list:
tier: "enterprise"
'''
]

result_lke_versions_samples = ['''[
{
"id": "1.25"
}
]''']
result_lke_versions_samples = [
'''
[
{
"id": "1.32"
},
{
"id": "1.31"
},
{
"id": "1.30"
}
]
''',
'''
[
{
"id": "v1.31.1+lke1",
"tier": "enterprise"
}
]
'''
]
6 changes: 6 additions & 0 deletions plugins/module_utils/linode_common_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def __init__(
requires_beta: bool = False,
deprecated: bool = False,
deprecation_message: Optional[str] = None,
custom_options: Optional[Dict[str, SpecField]] = None,
) -> None:
self.primary_result = primary_result
self.secondary_results = secondary_results or []
Expand All @@ -145,6 +146,9 @@ def __init__(
if self.deprecated:
self.description.insert(0, f"**NOTE: {self.deprecation_message}**")

# Store custom options if provided
self.custom_options = custom_options or {}

# Singular params should be translated into groups
self.param_groups = [
(
Expand Down Expand Up @@ -220,6 +224,8 @@ def spec(self):

options = {}

options.update(self.custom_options)

# Add params to spec
for group in self.param_groups:
param_names = {param.name for param in group.params}
Expand Down
16 changes: 16 additions & 0 deletions plugins/module_utils/linode_common_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ListModule(
): # pylint: disable=too-many-instance-attributes
"""A common module for listing API resources given a set of filters."""

# pylint: disable=too-many-positional-arguments
def __init__(
self,
result_display_name: str,
Expand All @@ -58,11 +59,16 @@ def __init__(
requires_beta: bool = False,
deprecated: bool = False,
deprecation_message: Optional[str] = None,
custom_options: Optional[Dict[str, SpecField]] = None,
custom_field_resolver: Optional[callable] = None,
) -> None:
self.result_display_name = result_display_name
self.result_field_name = result_field_name
self.endpoint_template = endpoint_template

# Store the custom field resolver, if provided
self.custom_field_resolver = custom_field_resolver

self.result_docs_url = (
result_docs_url
or "https://techdocs.akamai.com/linode-api/reference/api"
Expand All @@ -79,6 +85,9 @@ def __init__(
deprecation_message or "This module has been deprecated."
)

# Store custom options if provided
self.custom_options = custom_options or {}

self.module_arg_spec = self.spec.ansible_spec
self.results: Dict[str, Any] = {self.result_field_name: []}

Expand All @@ -95,6 +104,11 @@ def exec_module(self, **kwargs: Any) -> Optional[dict]:

filter_dict = construct_api_filter(self.module.params)

# Dynamically resolve fields if custom logic is provided
if self.custom_field_resolver:
docs = self.custom_field_resolver(self.module.params)
self.endpoint_template = docs["endpoint_template"]

self.results[self.result_field_name] = get_all_paginated(
self.client,
self.endpoint_template.format(**self.module.params),
Expand Down Expand Up @@ -160,6 +174,8 @@ def spec(self):
),
}

options.update(self.custom_options)

# Add the parent fields to the spec
for param in self.params:
options[param.name] = SpecField(
Expand Down
Loading
Loading