> /v-6ren">
gpt4 book ai didi

amazon-ec2 - Cloudformation userdata 脚本不适用于每个命令

转载 作者:行者123 更新时间:2023-12-03 07:39:58 27 4
gpt4 key购买 nike

  UserData:
Fn::Base64:
!Sub |
#!/bin/bash
echo "Start" >> /var/log/test.txt
sudo touch /etc/sysconfig/network-scripts/ifcfg-ens6
sudo echo -e "DEVICE=ens6\nTYPE=Ethernet\nIPADDR=SECONDARY-IP-ADREDD\nNETMASK=255.255.255.xxx\nMTU=9001\nGATEWAY=1xx.7x.2xx.1xx\nIPV6INIT=yes\nIPV6_AUTOCONF=no\nONBOOT=yes\nPEERDNS=no\nNOZEROCONF=yes\nUSERCTL=no\nNM_CONTROLLED=no" >> /etc/sysconfig/network-scripts/ifcfg-ens6
echo "Stop" >> /var/log/test.txt
-------------

I am passing this userscript in one of my instance using CF and every command works except this two :
sudo touch /etc/sysconfig/network-scripts/ifcfg-ens6
sudo echo -e "DEVICE=ens6\nTYPE=Ethernet\nIPADDR=SECONDARY-IP-ADREDD\nNETMASK=255.255.255.xxx\nMTU=9001\nGATEWAY=1xx.7x.2xx.1xx\nIPV6INIT=yes\nIPV6_AUTOCONF=no\nONBOOT=yes\nPEERDNS=no\nNOZEROCONF=yes\nUSERCTL=no\nNM_CONTROLLED=no" >> /etc/sysconfig/network-scripts/ifcfg-ens6

请让我知道我做错了什么。

我收到以下信息:找不到文件或目录:cat/etc/sysconfig/network-scripts/ifcfg-ens6

操作系统:Redhat 7

CF File snippet

最佳答案

当您使用 CloudFormation 脚本对容器运行脚本时,您已经是该容器的 root 用户。如果已经是 root 用户,则无需使用 sudo

关于amazon-ec2 - Cloudformation userdata 脚本不适用于每个命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71391471/

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