我想从.ebextentions / td-agent.conf归档到/etc/td-agent/td-agent.conf。但它无法正常工作,并且出现错误。
如果您看到附件图像,则.ebextensions中有3个文件。我已经将复制命令放在01-main.config中。
---
container_commands:
01_cron_job:
command: "touch /tmp/is_leader"
leader_only: true
01_tdconfcopy_job:
command: "yes | cp .ebextensions/td-agent.conf /etc/td-agent/td-agent.conf"
错误如下
Command failed on instance. Return code: 1 Output: cp: cannot create regular file '/etc/td-agent/td-agent.conf': No such file or directory
问题是您正在将文件复制到不存在的目录。您应该先创建输出目录,然后复制配置文件。
它将是:
---
container_commands:
01_cron_job:
command: "touch /tmp/is_leader"
leader_only: true
01_create_dir:
command: "sudo mkdir -p /etc/td-agent/"
02_tdconfcopy_job:
command: "yes | cp .ebextensions/td-agent.conf /etc/td-agent/td-agent.conf"
或者,您可以直接使用files
命令在服务器上创建文件。
files:
"/etc/td-agent/td-agent.conf":
mode: "000644"
owner: root
group: root
content: |
content of your config file that you want to copy