An argument definition must end with a newline


Subject: Help Needed: “Argument definition must end with a newline” Error in Terraform

Hi everyone,

I’m new to Terraform and have been working on a configuration that uses the remote-exec provisioner. However, I’m encountering an error during terraform validate:

Error: Argument definition must end with a newline

Here is the snippet of my Terraform code:

  provisioner "remote-exec" {
    inline = [
      "sudo tee -a /etc/ssh/ssh_config <<EOF",
      "Host 10.10.5.*",
      "   StrictHostKeyChecking no",
      "   UserKnownHostsFile=/dev/null",
      "EOF",
      "chmod 600 /home/${var.username}/.ssh/id_rsa",
      "sudo apt update",
      "sudo apt install -y ansible",
      "cd /home/${var.username}/ansible-k8s-setup",
      "mkdir -p roles",
      "ansible-galaxy init roles/kubernetes",
      "ansible-galaxy init roles/common",
      "ansible-galaxy init roles/containerd",
      "ansible-galaxy init roles/networking",
      "ansible-galaxy init roles/master",
      "ansible-galaxy init roles/worker",
      "ansible-galaxy init roles/ansible",
      "chown -R ${var.username}:${var.username} /home/${var.username}/ansible-k8s-setup",
      "cd /home/${var.username}/ansible-k8s-setup",
      "ansible-playbook -i inventory.ini playbook.yml",
      "cd /home/$(set -x; cd \"$(mktemp -d)\" && OS=\"$(uname | tr '[:upper:]' '[:lower:]')\" && ARCH=\"$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\\(arm\\)\\(64\\)\\?.*/\\1\\2/' -e 's/aarch64$/arm64/')\" && KREW=\"krew-${OS}_${ARCH}\" && curl -fsSLO \"https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz\" && tar zxvf \"${KREW}.tar.gz\" && ./${KREW} install krew)", 
 "export PATH=\"$${KREW_ROOT:-$HOME/.krew}/bin:$PATH\" >> .bashrc",

  ]}  

I’m not quite sure what’s causing the issue. Any suggestions on what might be wrong or how to fix it would be greatly appreciated.

Thanks in advance for your help!

hi @RimDammak,

The problem here is the end of the inline argument, which is a list of strings and should end in a single ] character before the next line. Moving the closing } from the provisioner block to a new line will allow it to be parsed correctly.

1 Like

It works now! Thank you.