Elastic Beanstalk Leader_only仅在文件级别

时间:2018-07-28 22:13:35

标签: amazon-web-services elastic-beanstalk devops

我想知道如何在文件级别定义leader_only(如果我仅需在领导者上创建该文件)。考虑下面的代码,例如:

files:
 "/etc/cron.d/mycron":
   mode: "000644"
   owner: root
   group: root
   content: |

      #to keep the segments current.


commands:
  remove_old_cron:
    command: "rm -f /etc/cron.d/*.bak"

我从文档中知道,我只能在leader_only: true级别定义container_commands,例如在docs page上考虑一下:

container_commands:
  collectstatic:
    command: "django-admin.py collectstatic --noinput"
  01syncdb:
    command: "django-admin.py syncdb --noinput"
    leader_only: true
  02migrate:
    command: "django-admin.py migrate"
    leader_only: true
  99customize:
    command: "scripts/customize.sh"

1 个答案:

答案 0 :(得分:3)

由于命令将在文件部分之后执行,因此您将需要解决给定的情况,创建一个template,它将仅为领导者重命名:

files:
  "/tmp/mycron.template":
  mode: "000644"
  owner: root
  group: root
  content: |
    #to keep the segments current.

container_commands:
  enable_cron:
    command: "mv /tmp/mycron.template /etc/cron.d/mycron"
    leader_only: true