What I’m trying to do: I have set up a self hosted gitlab instance, and I’m working on automating the terraform process with GitLab CI, for which I have to set up a terraform backend. I followed the steps in the official documentation, but unfortunately I run into an error when running the pipeline. This code is found in my .gitlab-ci.yml file, so it runs on my GitLab runner, which uses a docker image based on python:3.9-buster (Debian)
Here is the code in question, of course I edited out the IP address:
- terraform init
-backend-config="address=http://ipaddress//api/v4/projects/3/terraform/state/terraform-state/"
-backend-config="lock_address=http://ipaddress//api/v4/projects/3/terraform/state/terraform-state/lock"
-backend-config="unlock_address=http://ipaddress//api/v4/projects/3/terraform/state/terraform-state/lock"
-backend-config="username=root"
-backend-config="password=$ACCESSTOKEN"
-backend-config="lock_method=POST"
-backend-config="unlock_method=DELETE"
-backend-config="retry_wait_min=5"
Unfortunately I’m getting this error when the above command gets executed:
Too many command line arguments. Did you mean to use -chdir?
2
Answers
Just in case anyone would get stuck on a similar issue and happens to find this post, changing my script to this format solved the issue:
Block Scalar also works