> /etc/data-6ren">
gpt4 book ai didi

amazon-web-services - 将行添加到文件的命令的 cloud-init runcmd syntx

转载 作者:行者123 更新时间:2023-12-05 01:41:45 27 4
gpt4 key购买 nike

我正在尝试执行这个简单的命令,但它总是失败:

 echo "secret_backend_command: /home/ec2-user/dd-get-secrets.py" >> /etc/datadog-agent/datadog.yaml"

我尝试了以下所有方法:

        - [ sh, -c, echo "secret_backend_command: /home/ec2-user/dd-get-secrets.py" >> /etc/datadog-agent/datadog.yaml ]

- 'sh -c "echo \"secret_backend_command: /home/ec2-user/dd-get-secrets.py\" >> /etc/datadog-agent/datadog.yaml"'

- sh -c "echo 'secret_backend_command: /home/ec2-user/dd-get-secrets.py' >> /etc/datadog-agent/datadog.yaml

知道如何修复这个引号吗?

note I tested with another file rather than datadpg.yaml because I'm getting Permission denied for this one.

我在 here 中找到的示例没用

最佳答案

我改变了这样做的方式,而不是将它放在 runcmds 的 yaml 列表中,我创建了一个脚本,而是将这个命令放在里面并在 runcmds 中调用脚本。通过这样做,我摆脱了 cloud-init 中对“:”和引号的棘手处理。

  UserData:
'Fn::Base64': !Sub |
#cloud-config
write_files:
- path: /home/ec2-user/update-datadog-config.sh
permissions: 0744
owner: root
content: |
#!/usr/bin/env bash
set -e
echo "secret_backend_command: /home/ec2-user/dd-get-secrets.py" >> /etc/datadog-agent/datadog.yaml
runcmd:
- bash /home/ec2-user/update-datadog-config.sh

关于amazon-web-services - 将行添加到文件的命令的 cloud-init runcmd syntx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53749376/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com