suzuki-shunsuke/go-graylog

fork/exec error when executing terraform with linux

Closed this issue · 16 comments

Hi,

I'm trying to use your terraform provider but I have a strange error when executing Terraform:

Terraform init is working:

 terraform init

Initializing provider plugins...

The following providers do not have any version constraints in configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, it is recommended to add version = "..." constraints to the
corresponding provider blocks in configuration, with the constraint strings
suggested below.

* provider.graylog: version = "~> 6.1"

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

But when running terraform apply

terraform apply

Error: Error asking for user input: 1 error occurred:
	* provider.graylog: fork/exec /home/fgzx6022/.terraform.d/plugins/linux_amd64/terraform-provider-graylog_v6.1.2: no such file or directory

To install the provider, I have done this:

wget https://github.com/suzuki-shunsuke/go-graylog/releases/download/v6.1.2/terraform-provider-graylog_v6.1.2_linux_amd64.gz
gzip -d https://github.com/suzuki-shunsuke/go-graylog/releases/download/v6.1.2/terraform-provider-graylog_v6.1.2_linux_amd64.gz
mv terraform-provider-graylog_v6.1.2_linux_amd64 ~/.terraform.d/plugins/linux_amd64/terraform-provider-graylog_v6.1.2
chmod +x ~/.terraform.d/plugins/linux_amd64/terraform-provider-graylog_v6.1.2

My tf file:

provider "graylog" {
  web_endpoint_uri = "http://graylog/api"
  auth_name = "admin"
  auth_password = "password"
  api_version      = "v3"
}

resource "graylog_input" "test" {
  title = "terraform test"
  type = "org.graylog2.inputs.syslog.udp.SyslogUDPInput"
  attributes = {
    bind_address = "0.0.0.0"
    port = 514
    recv_buffer_size = 262144
  }
}

My terraform version:

terraform version
Terraform v0.11.14
+ provider.graylog v6.1.2

Did I miss someting ?

Your install path seems to be correct, and terraform-provider-graylog v6.1.2 works well for me on Linux.

https://www.terraform.io/docs/extend/how-terraform-works.html#plugin-locations

Please tell us your environment.

  • Graylog version
  • Host OS and version
  • Do you run Terraform on Docker?
  • If you run Terraform on Docker
    • Docker image
    • docker-compose.yml if you use Docker Compose

Thanks.

Informations about my environment:

  • Graylog version: 3.0.2+168693
  • Host OS and version: Ubuntu 18.04
  • Terraform on Docker: no

Terraform debug output:

OS_DEBUG=1 TF_LOG=DEBUG terraform apply 
2019/07/31 08:52:13 [INFO] Terraform version: 0.11.14  
2019/07/31 08:52:13 [INFO] Go runtime version: go1.12.4
2019/07/31 08:52:13 [INFO] CLI args: []string{"/usr/local/bin/terraform", "apply"}
2019/07/31 08:52:13 [DEBUG] Attempting to open CLI config file: /home/fgzx6022/.terraformrc
2019/07/31 08:52:13 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2019/07/31 08:52:13 [INFO] CLI command args: []string{"apply"}
2019/07/31 08:52:13 [INFO] command: empty terraform config, returning nil
2019/07/31 08:52:13 [DEBUG] command: no data state file found for backend config
2019/07/31 08:52:13 [DEBUG] New state was assigned lineage "1a0d736e-2bd8-12a1-f91e-5ae71543d1aa"
2019/07/31 08:52:13 [INFO] command: backend initialized: <nil>
2019/07/31 08:52:13 [DEBUG] checking for provider in "."
2019/07/31 08:52:13 [DEBUG] checking for provider in "/usr/local/bin"
2019/07/31 08:52:13 [DEBUG] checking for provider in ".terraform/plugins/linux_amd64"
2019/07/31 08:52:13 [DEBUG] checking for provider in "/home/fgzx6022/.terraform.d/plugins"
2019/07/31 08:52:13 [DEBUG] checking for provider in "/home/fgzx6022/.terraform.d/plugins/linux_amd64"
2019/07/31 08:52:13 [DEBUG] found provider "terraform-provider-graylog_v6.1.2"
2019/07/31 08:52:13 [DEBUG] found valid plugin: "graylog", "6.1.2", "/home/fgzx6022/.terraform.d/plugins/linux_amd64/terraform-provider-graylog_v6.1.2"
2019/07/31 08:52:13 [DEBUG] checking for provisioner in "."
2019/07/31 08:52:13 [DEBUG] checking for provisioner in "/usr/local/bin"
2019/07/31 08:52:13 [DEBUG] checking for provisioner in ".terraform/plugins/linux_amd64"
2019/07/31 08:52:13 [DEBUG] checking for provisioner in "/home/fgzx6022/.terraform.d/plugins"
2019/07/31 08:52:13 [DEBUG] checking for provisioner in "/home/fgzx6022/.terraform.d/plugins/linux_amd64"
2019/07/31 08:52:13 [INFO] command: backend <nil> is not enhanced, wrapping in local
2019/07/31 08:52:13 [INFO] backend/local: starting Apply operation
2019/07/31 08:52:13 [INFO] terraform: building graph: GraphTypeInput
2019/07/31 08:52:13 [DEBUG] Resource state not found for "graylog_input.test": graylog_input.test
2019/07/31 08:52:13 [DEBUG] resource graylog_input.test using provider provider.graylog
2019/07/31 08:52:13 [DEBUG] Starting graph walk: walkInput
2019-07-31T08:52:13.345+0200 [DEBUG] plugin: starting plugin: path=/home/fgzx6022/.terraform.d/plugins/linux_amd64/terraform-provider-graylog_v6.1.2 args=[/home/fgzx6022/.terraform.d/plugins/linux_amd64/terraform-provider-graylog_v6.1.2]
2019/07/31 08:52:13 [ERROR] root: eval: *terraform.EvalInitProvider, err: fork/exec /home/fgzx6022/.terraform.d/plugins/linux_amd64/terraform-provider-graylog_v6.1.2: no such file or directory
2019/07/31 08:52:13 [ERROR] root: eval: *terraform.EvalSequence, err: fork/exec /home/fgzx6022/.terraform.d/plugins/linux_amd64/terraform-provider-graylog_v6.1.2: no such file or directory
2019/07/31 08:52:13 [DEBUG] plugin: waiting for all plugin processes to complete...

Error: Error asking for user input: 1 error occurred:
	* provider.graylog: fork/exec /home/fgzx6022/.terraform.d/plugins/linux_amd64/terraform-provider-graylog_v6.1.2: no such file or directory

Thank you for your information.
I will check it with Vagrant.

Sorry, my question was ambiguous.
I want to know about the environment not where you run Graylog but where you execute the command "terraform apply".
So please let me know again to prevent misunderstanding.

Do you execute the command "terraform apply" on Ubuntu 18.04?

Thanks.

Yes, I'm running terraform from a Ubuntu 18.04 desktop.

Thanks for your reply.
I will try to reproduce it.

I've tried from a Ubuntu 16.04 vagrantbox and got the same error.

I can reproduce it. I will investigate this.

vagrant@vagrant:/vagrant$ terraform version
Terraform v0.11.14
+ provider.graylog v6.1.2

vagrant@vagrant:/vagrant$ terraform plan

Error: Error asking for user input: 1 error occurred:
        * provider.graylog: fork/exec /home/vagrant/.terraform.d/plugins/linux_amd64/terraform-provider-graylog_v6.1.2: no such file or directory

I build the binaries on Mac OSX and Ubuntu and test them on Ubuntu then the problem doesn't occur ("terraform plan" is success).

gox -output="dist/v6.1.2/terraform-provider-graylog_v6.1.2_{{.OS}}_{{.Arch}}" -osarch="linux/amd64" ./terraform/

I run a Docker Container suzukishunsuke/gox:1.0.1__0.1.0 on Ubuntu and build the binary on the container and test the binary on Ubuntu then the problem occurs.

I set the environment variable CGO_ENABLED=0 when I build the binary on the Docker Container suzukishunsuke/gox:1.0.1__0.1.0 then the problem doesn't occur.

CGO_ENABLED=0 gox -output="dist/v6.1.2/terraform-provider-graylog_v6.1.2_{{.OS}}_{{.Arch}}" -osarch="linux/amd64" ./terraform/

https://github.com/suzuki-shunsuke/go-graylog/releases/download/v6.1.2/terraform-provider-graylog_v6.1.2_linux_amd64.gz is a dynamic.

vagrant@vagrant:~$ ldd terraform-provider-graylog_v6.1.2_linux_amd64
        linux-vdso.so.1 (0x00007ffcd46d5000)
        libc.musl-x86_64.so.1 => not found

On the other hand, the binary built with CGO_ENABLED=0 is a static.

vagrant@vagrant:~/.terraform.d/plugins/linux_amd64$ ldd terraform-provider-graylog_v6.1.2
        not a dynamic executable

I think this is a root cause.

I have created the pull request #145 .

I have released the pre-release version v6.1.3-0 and it works well.
Please check it.
I will release v6.1.3 if v6.1.3-0 works well.

https://github.com/suzuki-shunsuke/go-graylog/releases/tag/v6.1.3-0

vagrant@vagrant:~$ ldd terraform-provider-graylog_v6.1.2_linux_amd64
        linux-vdso.so.1 (0x00007ffdc3363000)
        libc.musl-x86_64.so.1 => not found
vagrant@vagrant:~$ ldd terraform-provider-graylog_v6.1.3-0_linux_amd64
        not a dynamic executable

$ cp terraform-provider-graylog_v6.1.3-0_linux_amd64 ~/.terraform.d/plugins/linux_amd64/terraform-provider-graylog_v6.1.3-0
$ chmod a+x ~/.terraform.d/plugins/linux_amd64/terraform-provider-graylog_v6.1.3-0

I tested your pre-release and it works. No error and I was able to create resources.

Thank you !

Thank you for your test.
I have released v6.1.3 and close this issue.

https://github.com/suzuki-shunsuke/go-graylog/releases/tag/v6.1.3

Thank you.