StackScript doesn't get executed when Linode instance created via Ansible

I try to create my infrastructure using Linode Ansible collection. I would like to create a Linode with StackScript that I have created earlier, but with custom disk and network setup. It's all working fine but the StackScript just doesn't execute once the Linode is up. There's no trace in root directory, no log, nothing. My task:

tasks:
- name: Create Linode server
linode.cloud.instance:
api_token: '...'
label: '...'
type: 'g6-nanode-1'
region: '...'
private_ip: true
root_pass: '...'
boot_config_label: boot-config
disks:
- label: boot
image: '...'
stackscript_id: '...'
stackscript_data: '...'
size: 20000
root_pass: '...'
- label: logs
size: 4000
filesystem: ext4
- label: swap
size: 512
filesystem: swap
configs:
- label: boot-config
root_device: /dev/sda
devices:
sda:
disk_label: boot
sdb:
disk_label: logs
sdc:
disk_label: swap
interfaces:
- purpose: public
primary: true
- purpose: vlan
label: Primary
ipam_address: "10.0.0.1/24"
booted: true
state: present

If I remove the stackscript_id and stackscript_data from disks and put it in the main config, I get
Error from Linode API: [400] StackScripts must be associated with at least one image or distro
If I leave it in disks config, everything goes smoothly, there is no error but the stackscript is just not invoked.
Any ideas?

1 Reply

I was able to recreate the issue you are seeing when trying to deploy an instance with a StackScript. I brought this up to the administrators of the Linode Ansible Collection and they confirmed an issue with the collection. They are now in the process of creating a fix which should be shipped soon. I'll make sure to follow up here when the fix is live.

For reference, this is my .yml file:

- name: Create Linode Instance
  hosts: localhost
  tasks:
    - name: Create Linode server
      linode.cloud.instance:
        api_token: '$my-token'
        label: 'django-test'
        region: 'us-east'
        type: 'g6-standard-1'
        booted: true
        private_ip: true
        boot_config_label: boot-config
        state: present
        disks:
          - label: boot
            image: linode/ubuntu22.04
            size: 20000
            root_pass: '$my-password'
            stackscript_id: '609175'
            stackscript_data:
              variable: {"user_name": "tlambert", "disable_root": "No", "soa_email_address": "$my-email-address@example.com", "django_user": "tlambert"}
          - label: logs
            size: 4000
            filesystem: ext4
          - label: swap
            size: 512
            filesystem: swap
        configs:
          - label: boot-config
            root_device: /dev/sda
            devices:
              sda:
                disk_label: boot
              sdb:
                disk_label: logs
              sdc:
                disk_label: swap
            interfaces:
              - purpose: public
                primary: True
              - purpose: vlan
                label: Primary
                ipam_address: "10.0.0.1/24"
        state: present

The StackScript I used is the Django deployment from the App Marketplace.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct