Pass data to a Stack Script using 'linode-cli'?

Linode Staff

We're moving from the deprecated Linode CLI tool to the new "linode-cli", and I'm having issues trying to figure out how to pass the required data into a call to rebuild a linode using a stackscript.

Can you provide an example of how to format the data like "fqdn" into the stackscript_data parameter?

1 Reply

In order to pass data to the --stackscript_data parameter in the current linode-cli, you can use a command following the basic form:

linode-cli linodes create \
  --label linode123 \
  --root_pass [email protected] \
  --booted true \
  --stackscript_id 10079 \
  --stackscript_data '{"gh_username": "linode"}' \
  --region us-east \
  --type g6-standard-2 \
  --authorized_keys "ssh-rsa AAAA_valid_public_ssh_key_123456785== [email protected]"

The relevant line here is --stackscript_data '{"gh_username": "linode"}' \ and you should be able to substitute "gh_username" with the name of the value you are passing data to (e.g. 'fqdn') and "linode" with the data you are passing (e.g. 'www.example.com'). It is worth noting that the '\' at the end of each line is only necessary if you are breaking the command up into multiple lines, but you could also format it as:

linode-cli linodes create --label linode123 --root_pass [email protected] --booted true --stackscript_id 10079 --stackscript_data '{"gh_username": "linode"}' --region us-east --type g6-standard-2 --authorized_keys "ssh-rsa AAAA_valid_public_ssh_key_123456785== [email protected]"

I recommend using the former format for the sake of readability, particularly if writing the command into a script, as it will dramatically simplify any troubleshooting/debugging later on if you find that the script contains errors.

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