hashicorp / terraform-aws-consul

A Terraform Module for how to run Consul on AWS using Terraform and Packer
Apache License 2.0
401 stars 488 forks source link

On Amazon Linux AMI consul not seen when run as sudo #67

Open jchannon opened 6 years ago

jchannon commented 6 years ago

I am trying to add a supervisorctl config so that it starts consul as part of a packer image however the packer image is run as ec2-user which can't seem to run supervisorctl and results in error: <class 'socket.error'>, [Errno 13] Permission denied: file: /usr/lib64/python2.7/socket.py line: 228 so I could fix the supervisorctl permissions. However, if I set my scripts to use sudo supervisorctl, the root user then can't see consul for some reason so I was wondering what your recommendation would be?

Thanks

brikis98 commented 6 years ago

I am trying to add a supervisorctl config so that it starts consul

This is exactly what the run-consul module already does. Any reason you can't just use that?

However, if I set my scripts to use sudo supervisorctl, the root user then can't see consul for some reason

By "see", do you mean find the consul binary? If so, it's in /opt/consul/bin by default, so you can either add that to $PATH or call Consul via an absolute path (i.e., /opt/consul/bin/consul).

jchannon commented 6 years ago

Ah interesting I've just checked and we're using 0.1.0 so I'm guessing some improvements have been made. Here's what we use to execute:

      - "git clone --branch v{{user `consul_module_version`}} https://github.com/hashicorp/terraform-aws-consul.git /tmp/terraform-aws-consul"
      - "/tmp/terraform-aws-consul/modules/install-consul/install-consul --version {{user `consul_version`}}"

Looking at your links I could upload my json and conf files and hopefully all will be well when the agent starts

brikis98 commented 6 years ago

Please read the docs and look at the examples. You execute install-consul in a Packer template to create an AMI with Consul and all its dependencies installed. You then execute run-consul as part of User Data to provide runtime configurations to Consul and boot it up using supervisor.

jchannon commented 6 years ago

Yup understood, the above sample code of mine is in a packer yml file