<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>linode-cli - Architect the cloud</title>
	<atom:link href="https://blog.slepcevic.net/tag/linode-cli/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.slepcevic.net</link>
	<description></description>
	<lastBuildDate>Mon, 03 Jul 2023 08:28:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>
	<item>
		<title>Deploying Linode Marketplace StackScripts with Terraform</title>
		<link>https://blog.slepcevic.net/deploying-linode-marketplace-stackscripts-with-terraform/</link>
					<comments>https://blog.slepcevic.net/deploying-linode-marketplace-stackscripts-with-terraform/#respond</comments>
		
		<dc:creator><![CDATA[Alesandro Slepčević]]></dc:creator>
		<pubDate>Thu, 29 Jun 2023 08:22:00 +0000</pubDate>
				<category><![CDATA[Akamai Connected Cloud]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Linode]]></category>
		<category><![CDATA[linode-cli]]></category>
		<category><![CDATA[Terraform]]></category>
		<guid isPermaLink="false">http://172.233.40.105/blog.slepcevic.net/?p=146</guid>

					<description><![CDATA[<p>Recently, I needed to deploy a 3 node Redis Cluster from Linode&#8217;s Marketplace. Quick glance at Linode&#8217;s Terraform provider shows that we can deploy instances using StackScripts, but in order to do that, we need to specify the StackScript ID....</p>
<p>The post <a href="https://blog.slepcevic.net/deploying-linode-marketplace-stackscripts-with-terraform/">Deploying Linode Marketplace StackScripts with Terraform</a> first appeared on <a href="https://blog.slepcevic.net">Architect the cloud</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Recently, I needed to deploy a 3 node Redis Cluster from Linode&#8217;s Marketplace. </p>



<p>Quick glance at Linode&#8217;s Terraform provider shows that we can deploy instances using StackScripts, but in order to do that, we need to specify the StackScript ID. If we are deploying from our own StackScript, it&#8217;s easy, you just reference it like this and you&#8217;re good to go.</p>



<pre class="wp-block-code"><code>resource "linode_stackscript" "foo" {
  label = "foo"
  description = "Installs a Package"
  script = &lt;&lt;EOF
#!/bin/bash
# &lt;UDF name="package" label="System Package to Install" example="nginx" default=""&gt;
apt-get -q update &amp;&amp; apt-get -q -y install $PACKAGE
EOF
  images = &#091;"linode/ubuntu18.04", "linode/ubuntu16.04lts"]
  rev_note = "initial version"
}

resource "linode_instance" "foo" {
  image  = "linode/ubuntu18.04"
  label  = "foo"
  region = "us-east"
  type   = "g6-nanode-1"
  authorized_keys    = &#091;"..."]
  root_pass      = "..."

  <strong>stackscript_id = linode_stackscript.foo.id</strong>
  stackscript_data = {
    "package" = "nginx"
  }
}</code></pre>



<p>&#8220;Problem&#8221; comes when we want to deploy a product from the marketplace, in order to do that we need to collect a few things first. </p>



<ol class="wp-block-list">
<li>ID of the StackScript you want to deploy</li>



<li>List of supported OS images</li>



<li>Check which variables we need to provide to the StackScript. </li>
</ol>



<p>Step 1 &#8211; Fetching the StackScript ID. In this case, I&#8217;ll do it using linode-cli, but you&#8217;re free to use any other method</p>



<pre class="wp-block-code"><code>linode-cli stackscripts list --label "Redis Sentinel Cluster One-Click"
</code></pre>



<p>Output of this command looks like this</p>



<p><img fetchpriority="high" decoding="async" width="958" height="161" class="wp-image-150" style="width: 1000px" src="https://blog.slepcevic.net/wp-content/uploads/2023/07/Screenshot-2023-07-03-100015.png" alt="" srcset="https://blog.slepcevic.net/wp-content/uploads/2023/07/Screenshot-2023-07-03-100015.png 958w, https://blog.slepcevic.net/wp-content/uploads/2023/07/Screenshot-2023-07-03-100015-300x50.png 300w, https://blog.slepcevic.net/wp-content/uploads/2023/07/Screenshot-2023-07-03-100015-768x129.png 768w" sizes="(max-width: 958px) 100vw, 958px" /></p>



<p>From here, we need to write down the ID of the script, and check the list of supported images. In this case, I&#8217;ll deploy a stackscript with the ID 1132204 which is owned by Linode. </p>



<p>Next step is to check which variables we need to provide to the StackScript. We can easily see that by running the following Powershell command:</p>



<pre class="wp-block-code"><code>$stackscripts = ((wget https://cloud.linode.com/api/v4/linode/stackscripts?page_size=500).Content | convertfrom-json)
$stackscripts.data | where {$_.id -like "1132204"} | select -expand user_defined_fields
name                   label
----                   -----
token_password         Your Linode API token
sudo_username          The limited sudo user to be created in the cluster
sslheader              SSL Information
country_name           Details for self-signed SSL certificates: Country or Region
state_or_province_name State or Province
locality_name          Locality
organization_name      Organization
email_address          Email Address
ca_common_name         CA Common Name
common_name            Common Name
clusterheader          Cluster Settings
add_ssh_keys           Add Account SSH Keys to All Nodes?
cluster_size           Redis cluster size</code></pre>



<p>And finally put all of those variables into our Terraform code, which in end looks something like this: </p>



<pre class="wp-block-code"><code>resource "linode_instance" "redis" {
        image = "linode/ubuntu22.04"
        label = "RedisCluster"
        group = "Redis"
        tags = &#091; "stage:dev" ]
        region = "eu-central"
        type = "g6-standard-1"
        authorized_users = &#091; "yourUsername" ]
        root_pass = "SuperRandomPassW0rd.123!"
<strong>        stackscript_id = <em>1132204</em>
        stackscript_data = {
            "token_password" = "yourLinodeToken"
            "sudo_username" = "myuser"
            "sslheader" = "Yes" #Default YES
            "country_name" = "NL"  #Two letter country code
            "state_or_province_name" = "South Holland" 
            "locality_name" = "Rotterdam" 
            "organization_name" = "Org Name" 
            "email_address" = "yourEmail@here.com" 
            "ca_common_name" = "Redis CA" 
            "clusterheader" = "Yes" 
            "add_ssh_keys" = "no" #yes or no
            "cluster_size" = "3" #3 or 5</strong>
        }
}
</code></pre>



<p>Notice we are required to provide our Linode token in order to deploy this cluster; this can be the same token you&#8217;re using for your existing Terraform code, so you can simple reference a environment variable in your code and off you go <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f600.png" alt="😀" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<p>Cheers, Alex. </p><p>The post <a href="https://blog.slepcevic.net/deploying-linode-marketplace-stackscripts-with-terraform/">Deploying Linode Marketplace StackScripts with Terraform</a> first appeared on <a href="https://blog.slepcevic.net">Architect the cloud</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://blog.slepcevic.net/deploying-linode-marketplace-stackscripts-with-terraform/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)

Served from: blog.slepcevic.net @ 2026-01-06 11:35:27 by W3 Total Cache
-->