Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Translate stackscript_data to kwargs during disk creation #488

Merged
merged 3 commits into from
Apr 1, 2024

Conversation

lgarber-akamai
Copy link
Contributor

@lgarber-akamai lgarber-akamai commented Mar 29, 2024

📝 Description

This change resolves a bug that prevented stackscript_data from being properly embedded in instance module disk creation requests.

This is necessary because linode_api4 expects StackScript data to be specified as kwargs during disk creation: https://github.com/linode/linode_api4-python/blob/dev/linode_api4/objects/linode.py#L1161

✔️ How to Test

The following test steps assume you have pulled down this PR locally.

Integration Testing

make test TEST_ARGS="-v instance_disk_stackscript"

Manual Testing

  1. In an Ansible Collection sandbox environment (e.g. dx-devenv), run the following playbook:
- name: Create Linode Instance
  hosts: localhost
  tasks:
    - linode.cloud.stackscript:
        label: "test-stackscript"
        images:
          - "linode/alpine3.19"
        script: |
          #!/bin/ash
          # <UDF name="package" label="System Package to Install" example="nginx">
          apk add $PACKAGE
        state: present
      register: stackscript_create

    - linode.cloud.instance:
        label: "test-instance"
        region: us-mia
        type: g6-nanode-1
        booted: false
        disks:
          - label: test-disk
            size: 1024
            image: linode/alpine3.19
            stackscript_id: "{{ stackscript_create.stackscript.id }}"
            stackscript_data:
              package: cowsay
        state: present
      register: instance_create

    - linode.cloud.stackscript_info:
        label: "{{ stackscript_create.stackscript.label }}"
      register: stackscript_info

    - debug:
        var: stackscript_info.stackscript.deployments_active
  1. Ensure the debug output contains the following, implying the StackScript was successfully deployed to the disk:
ok: [localhost] => {
    "stackscript_info.stackscript.deployments_active": 1
}

📷 Preview

If applicable, include a screenshot or code snippet of this change. Otherwise, please remove this section.

@lgarber-akamai lgarber-akamai requested a review from a team as a code owner March 29, 2024 20:06
@lgarber-akamai lgarber-akamai requested review from zliang-akamai and ykim-akamai and removed request for a team March 29, 2024 20:06
Copy link
Member

@zliang-akamai zliang-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Tested and worked well.

@ykim-akamai
Copy link
Contributor

LG, Tested locally

@lgarber-akamai lgarber-akamai merged commit 6e81059 into linode:dev Apr 1, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants