Deploying stackscript image using terraform

Terraform code as below, where I have mentioned stackscripts_id

resource "linode_instance" "mysqlmariadb" {
image = "linode/centos7"
label = "linux-01-mysql"
region = "ap-northeast"
type = "g6-standard-1"
stackscript_id = "16516"

Getting below error

linode_instance.mysqlmariadb: Creating…

Error: Error creating a Linode Instance: [400] [db_root_password] A value for the UDF db_root_password is required.

==============================================

So I mentioned db_root_password = "xyz" (some other password I mentioned)

now below message -

An argument named "db_root_password" is not expected here

???

3 Replies

Hi @siddharthdex

I was able to test this out on my end and get it working!

Here is the test StackScript I made based off of your script mentioned in your other community post

StackScript

### Added UDFs to test/confirm they work
# <UDF name="mysqluser" Label="Mysql User" example="username" />
# <UDF name="mysqluserpassword" Label="MySQL Password" example="Pass" />

### Enable logging for the StackScript (Just added for testing)
set -xo pipefail
exec 1> >(tee -a "/var/log/stackscript.log") 2>&1

### Commands
sudo yum update -y
sudo yum install wget -y
sudo yum install tar -y
cd /root
sudo wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
sudo yum install mysql-server -y
sudo systemctl start mysqld
sudo systemctl status mysqld

echo "DONE...."

Terraform config

provider "linode" {
  token = "$APITOKEN"
}

resource "linode_instance" "mysqlmariadb_community" {
image = "linode/centos7"
label = "linux-01-mysql"
region = "ap-northeast"
type = "g6-standard-1"
stackscript_id = "$stackscriptID"
root_pass = "$SEcRET"

stackscript_data = {
    "mysqluser" = "$SEcRET"
    "mysqluserpassword" = "$SEcRET"
  }
}

Once the Linode is provisioned you can 'tail -f /var/log/stackscript.log' on the Linode and watch the StackScript execute.

Hope that works for you!

On CentOS 7, there was no /var/log/stackscript.log.

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