Skip to content

Commit

Permalink
Merge pull request #632 from linode/dev
Browse files Browse the repository at this point in the history
v0.33.0
  • Loading branch information
ezilber-akamai authored Dec 10, 2024
2 parents d1ba3a5 + 9729ec7 commit 95db231
Show file tree
Hide file tree
Showing 17 changed files with 206 additions and 109 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Run Documentation Validation

on: pull_request

env:
DEFAULT_PYTHON_VERSION: "3.10"

jobs:
test-templated-docs:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -66,7 +69,7 @@ jobs:
- name: setup python 3
uses: actions/setup-python@v5
with:
python-version: '3.x'
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}

- name: install dependencies
run: make deps
Expand Down
83 changes: 27 additions & 56 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,61 +194,32 @@ jobs:

steps:
- name: Notify Slack
uses: slackapi/slack-github-action@v1.27.0
uses: slackapi/slack-github-action@v2.0.0
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":rocket: *${{ github.workflow }} Completed in: ${{ github.repository }}* :white_check_mark:"
}
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Build Result:*\n${{ needs.integration-tests.result == 'success' && ':large_green_circle: Build Passed' || ':red_circle: Build Failed' }}"
},
{
"type": "mrkdwn",
"text": "*Branch:*\n`${{ github.ref_name }}`"
}
]
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Commit Hash:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>"
},
{
"type": "mrkdwn",
"text": "*Run URL:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run Details>"
}
]
},
{
"type": "divider"
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Triggered by: :bust_in_silhouette: `${{ github.actor }}`"
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
channel: ${{ secrets.SLACK_CHANNEL_ID }}
blocks:
- type: section
text:
type: mrkdwn
text: ":rocket: *${{ github.workflow }} Completed in: ${{ github.repository }}* :white_check_mark:"
- type: divider
- type: section
fields:
- type: mrkdwn
text: "*Build Result:*\n${{ needs.integration-tests.result == 'success' && ':large_green_circle: Build Passed' || ':red_circle: Build Failed' }}"
- type: mrkdwn
text: "*Branch:*\n`${{ github.ref_name }}`"
- type: section
fields:
- type: mrkdwn
text: "*Commit Hash:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>"
- type: mrkdwn
text: "*Run URL:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run Details>"
- type: divider
- type: context
elements:
- type: mrkdwn
text: "Triggered by: :bust_in_silhouette: `${{ github.actor }}`"
88 changes: 88 additions & 0 deletions .github/workflows/nightly-smoke-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Nightly Smoke Tests

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
inputs:
sha:
description: 'Commit SHA to test'
required: false
default: ''
type: string

jobs:
smoke_tests:
if: github.repository == 'linode/ansible_linode' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
env:
EXIT_STATUS: 0
defaults:
run:
working-directory: .ansible/collections/ansible_collections/linode/cloud
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
path: .ansible/collections/ansible_collections/linode/cloud
fetch-depth: 0
submodules: 'recursive'

- name: Update packages
run: sudo apt-get update -y

- name: Setup Python 3
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.run-eol-python-version == 'true' && env.EOL_PYTHON_VERSION || inputs.python-version || env.DEFAULT_PYTHON_VERSION }}

- name: Install dependencies
run: make deps

- name: Install ansible dependencies
run: ansible-galaxy collection install amazon.aws:==6.0.1

- name: Install Collection
run: make install

- name: Replace Existing Keys
run: rm -rf ~/.ansible/test && mkdir -p ~/.ansible/test && ssh-keygen -m PEM -q -t rsa -N '' -f ~/.ansible/test/id_rsa

- name: Run smoke tests
id: smoke_tests
run: |
make smoketest
env:
LINODE_API_TOKEN: ${{ secrets.DX_LINODE_TOKEN }}

- name: Notify Slack
if: (success() || failure()) && github.repository == 'linode/ansible_linode'
uses: slackapi/[email protected]
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ secrets.SLACK_CHANNEL_ID }}
blocks:
- type: section
text:
type: mrkdwn
text: ":rocket: *${{ github.workflow }} Completed in: ${{ github.repository }}* :white_check_mark:"
- type: divider
- type: section
fields:
- type: mrkdwn
text: "*Build Result:*\n${{ steps.smoke_tests.outcome == 'success' && ':large_green_circle: Build Passed' || ':red_circle: Build Failed' }}"
- type: mrkdwn
text: "*Branch:*\n`${{ github.ref_name }}`"
- type: section
fields:
- type: mrkdwn
text: "*Commit Hash:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>"
- type: mrkdwn
text: "*Run URL:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run Details>"
- type: divider
- type: context
elements:
- type: mrkdwn
text: "Triggered by: :bust_in_silhouette: `${{ github.actor }}`"
36 changes: 9 additions & 27 deletions .github/workflows/release-notify-slack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,14 @@ jobs:
steps:
- name: Notify Slack - Main Message
id: main_message
uses: slackapi/slack-github-action@v1.27.0
uses: slackapi/slack-github-action@v2.0.0
with:
channel-id: ${{ secrets.DEV_DX_SLACK_CHANNEL_ID }}
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*New Release Published: _ansible_linode_ - ${{ github.event.release.tag_name }} is now live!* :tada:"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

- name: Notify Slack - Threaded Release Notes
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.DEV_DX_SLACK_CHANNEL_ID }}
payload: |
{
"thread_ts": "${{ steps.main_message.outputs.ts }}",
"text": "*<${{ github.event.release.html_url }}| ${{ github.event.release.tag_name }} Release notes>*"
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
channel: ${{ secrets.DEV_DX_SLACK_CHANNEL_ID }}
blocks:
- type: section
text:
type: mrkdwn
text: "*New Release Published: _ansible_linode_ <${{ github.event.release.html_url }}|${{ github.event.release.tag_name }}> is now live!* :tada:"
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ install: build
ansible-galaxy collection install *.tar.gz --force -p $(COLLECTIONS_PATH)

deps:
pip install -r requirements.txt -r requirements-dev.txt --upgrade
pip install -r requirements.txt -r requirements-dev.txt --force

lint:
pylint plugins
Expand Down Expand Up @@ -91,7 +91,7 @@ delete-e2e-firewall: update-test-submodules
echo "$$OUTPUT"; \
exit 1; \
else \
echo "E2E Cloud firewall created successfully."; \
echo "E2E Cloud firewall deleted successfully."; \
fi

update-test-submodules:
Expand All @@ -102,6 +102,9 @@ test: integration-test
testall:
./scripts/test_all.sh

smoketest:
./scripts/test_basic_smoke.sh

unittest:
ansible-test units --target-python default

Expand Down
16 changes: 8 additions & 8 deletions docs/inventory/instance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,19 @@ Parameters


**parent_group (type=str):**
\• parent group for keyed group
\• parent group for keyed group.


**prefix (type=str):**
\• A keyed group name will start with this prefix
\• A keyed group name will start with this prefix.


**separator (type=str, default=_):**
\• separator used to build the keyed group name
\• separator used to build the keyed group name.


**key (type=str):**
\• The key from input dictionary used to generate groups
\• The key from input dictionary used to generate groups.


**default_value (type=str):**
Expand All @@ -98,7 +98,7 @@ Parameters


**trailing_separator (type=bool, default=True):**
\• Set this option to :literal:`False` to omit the :literal:`keyed\_groups[].separator` after the host variable when the value is an empty string.
\• Set this option to :literal:`false` to omit the :literal:`keyed\_groups[].separator` after the host variable when the value is an empty string.

\• This option is mutually exclusive with :literal:`keyed\_groups[].default\_value`.

Expand All @@ -109,13 +109,13 @@ Parameters


**leading_separator (type=boolean, default=True):**
\• Use in conjunction with keyed\_groups.
\• Use in conjunction with :literal:`keyed\_groups`.

\• By default, a keyed group that does not have a prefix or a separator provided will have a name that starts with an underscore.

\• This is because the default prefix is "" and the default separator is "\_".
\• This is because the default prefix is :literal:`""` and the default separator is :literal:`"\_"`.

\• Set this option to False to omit the leading underscore (or other separator) if no prefix is given.
\• Set this option to :literal:`false` to omit the leading underscore (or other separator) if no prefix is given.

\• If the group name is derived from a mapping the separator is still used to concatenate the items.

Expand Down
2 changes: 1 addition & 1 deletion docs/modules/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Manage a Linode Image.
| `wait` | <center>`bool`</center> | <center>Optional</center> | Wait for the image to have status `available` before returning. **(Default: `True`)** |
| `wait_timeout` | <center>`int`</center> | <center>Optional</center> | The amount of time, in seconds, to wait for an image to have status `available`. **(Default: `600`)** |
| `tags` | <center>`list`</center> | <center>Optional</center> | A list of customized tags of this new Image. **(Updatable)** |
| `replica_regions` | <center>`list`</center> | <center>Optional</center> | A list of regions that customer wants to replicate this image in. At least one available region must be provided and only core regions allowed. Existing images in the regions not passed will be removed. NOTE: Image replication may not currently be available to all users. **(Updatable)** |
| `replica_regions` | <center>`list`</center> | <center>Optional</center> | A list of regions that customer wants to replicate this image in. At least one available region must be provided and only core regions allowed. Existing images in the regions not passed will be removed. **(Updatable)** |
| `wait_for_replications` | <center>`bool`</center> | <center>Optional</center> | Wait for the all the replications `available` before returning. **(Default: `False`)** |

## Return Values
Expand Down
1 change: 1 addition & 0 deletions docs/modules/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ Manage Linode Instances, Configs, and Disks.
| `region` | <center>`str`</center> | <center>Optional</center> | The location to deploy the instance in. See the [Linode API documentation](https://api.linode.com/v4/regions). |
| `image` | <center>`str`</center> | <center>Optional</center> | The image ID to deploy the instance disk from. **(Conflicts With: `disks`,`configs`)** |
| `authorized_keys` | <center>`list`</center> | <center>Optional</center> | A list of SSH public key parts to deploy for the root user. |
| `authorized_users` | <center>`list`</center> | <center>Optional</center> | A list of usernames. |
| `root_pass` | <center>`str`</center> | <center>Optional</center> | The password for the root user. If not specified, one will be generated. This generated password will be available in the task success JSON. |
| `stackscript_id` | <center>`int`</center> | <center>Optional</center> | 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). |
| `stackscript_data` | <center>`dict`</center> | <center>Optional</center> | An object containing arguments to any User Defined Fields present in the StackScript used when creating the instance. Only valid when a stackscript_id is provided. See the [Linode API documentation](https://techdocs.akamai.com/linode-api/reference/get-stack-scripts). |
Expand Down
3 changes: 1 addition & 2 deletions plugins/module_utils/linode_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import polling
from ansible_collections.linode.cloud.plugins.module_utils.linode_helper import (
format_api_error,
format_generic_error,
)

Expand Down Expand Up @@ -159,7 +158,7 @@ def __init__(
res = self.exec_module(**self.module.params)
except ApiError as err:
# We don't want to return a stack trace for an API error
self.fail(msg=format_api_error(err))
self.fail(msg=f"Error from Linode API: {str(err)}")
except polling.TimeoutException as err:
self.fail(
msg="failed to wait for condition: timeout period expired"
Expand Down
7 changes: 0 additions & 7 deletions plugins/module_utils/linode_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import linode_api4
import polling
from linode_api4 import (
ApiError,
LinodeClient,
LKENodePool,
LKENodePoolNode,
Expand Down Expand Up @@ -329,12 +328,6 @@ def get_all_paginated(
return result


def format_api_error(err: ApiError) -> str:
"""Formats an API error into a readable string"""

return f"Error from Linode API: [{err.status}] {';'.join(err.errors)}"


def format_generic_error(err: Exception) -> str:
"""Formats a generic error into a readable string"""

Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@
description=[
"A list of regions that customer wants to replicate this image in. "
"At least one available region must be provided and only core regions allowed. "
"Existing images in the regions not passed will be removed. "
"NOTE: Image replication may not currently be available to all users.",
"Existing images in the regions not passed will be removed. ",
],
),
"wait_for_replications": SpecField(
Expand Down
5 changes: 5 additions & 0 deletions plugins/modules/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@
"A list of SSH public key parts to deploy for the root user."
],
),
"authorized_users": SpecField(
type=FieldType.list,
element_type=FieldType.string,
description=["A list of usernames."],
),
"root_pass": SpecField(
type=FieldType.string,
no_log=True,
Expand Down
Loading

0 comments on commit 95db231

Please sign in to comment.