Elastic Beanstalk Leader_only 在文件级别

Fai*_*Ali 3 amazon-web-services amazon-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"
Run Code Online (Sandbox Code Playgroud)

我从文档中了解到,我只能在级别leader_only: true上 定义container_commands,例如在文档页面上考虑这一点:

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"
Run Code Online (Sandbox Code Playgroud)

b.b*_*4rd 6

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