404pio
404pio

Reputation: 1032

Elastic Bean Stalk - Failed to add user

I'm trying to add celery service to elastic bean stalk environment. So I decided to create first user and group "celery". I follow instructions from page http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#linux-users, and I created config:

groups:
  celery:
    gid: "101"

users:
  celery:
    groups:
      - celery
    uid: "1501"
    homeDir: "/opt/python/celery"

But during deploy, I get error:

[2017-02-10T08:59:23.899Z] INFO  [16595] - [Application update app-43a4-170210_095832@474/AppDeployStage0/EbExtensionPreBuild/Infra-EmbeddedPreBuild] : Activity execution failed, because: Failed to add user celery (ElasticBeanstalk::ExternalInvocationError)

I also was modifing homeDir, and uid, and login, and gruop id, but it doesn't help. How to fix it? Or how to debug useradding by elastic bean stalk?

Upvotes: 2

Views: 480

Answers (2)

Eric Platon
Eric Platon

Reputation: 10152

The workaround by 404pio offers a solution, but the ignoreErrors set to true can hide surprise errors.

I commented on that answer, but formatting is limited and gets hard to understand. Here is a way to improve on error cases:

groups:
  celery:
    gid: "101"

commands:
  command 00_add_user_celery:
    test: test ! "`id -u celery 2> /dev/null`"
    command: useradd -d /opt/python/celery -g celery -u 1501 celery
    ignoreErrors: false

ignoreErrors: false is the default and could also be omitted.

Upvotes: 2

404pio
404pio

Reputation: 1032

Workaround with commands sections:

groups:
  celery:
    gid: "101"

commands:
  command 00_add_user_celery:
    command: useradd -d /opt/python/celery -g celery -u 1501 celery
    ignoreErrors: true

Upvotes: 1

Related Questions