【问题标题】:Elastic Bean Stalk - Failed to add userElastic Beanstalk - 添加用户失败
【发布时间】:2017-05-09 10:43:21
【问题描述】:

我正在尝试将 celery 服务添加到弹性豆茎环境。所以我决定创建第一个用户和组“芹菜”。我按照页面http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#linux-users 的说明进行操作,并创建了配置:

groups:
  celery:
    gid: "101"

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

但在部署过程中,我收到错误:

[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)

我还修改了 homeDir、uid、login 和 gruop id,但没有帮助。如何解决?或者如何通过弹性豆茎调试用户添加?

【问题讨论】:

    标签: amazon-elastic-beanstalk


    【解决方案1】:

    404pio 的解决方法提供了一个解决方案,但将 ignoreErrors 设置为 true 可以隐藏意外错误。

    我对该答案发表了评论,但格式有限且难以理解。这是一种改进错误情况的方法:

    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 是默认值,也可以省略。

    【讨论】:

      【解决方案2】:

      命令部分的解决方法:

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

      【讨论】:

      • 我更喜欢将ignoreErrors 设置为false 以避免意外。那么,要使脚本工作,您可以依赖 test 选项。只需在命令部分添加类似test: test ! "id -u celery 2> /dev/null" 的内容。
      猜你喜欢
      • 2017-08-03
      • 2021-08-15
      • 2014-10-27
      • 2015-12-15
      • 1970-01-01
      • 2019-04-20
      • 2015-12-17
      • 2017-05-04
      • 2015-07-29
      相关资源
      最近更新 更多