文件级别的 Elastic Beanstalk leader_only

Elastic Beanstalk leader_only at files level

我想知道如何在文件级别定义 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"

我从文档中了解到我只能在 container_commands 级别定义 leader_only: true,例如在 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"

您需要解决给定的情况,因为命令是在文件部分之后执行的,创建一个 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