Join us for a virtual Nutanix User Group meeting with Jarian Gibson as he covers Nutanix Cloud Clusters (NC2) on Azure and AWS with Citrix. <\/span><\/p>

Jarian will take a deep dive into NC2 on Azure architecture and Citrix on NC2 on Azure\u00a0that helps you strengthen your business continuity and disaster recovery position. He\u2019ll also provide the latest updates for NC2 on AWS.<\/span><\/p>

Plus, we're\u00a0giving away a Nutanix suitcase to one lucky winner!\u00a0Opt-in when you register\u00a0to be entered to win.\u00a0<\/p>","author":{"id":113632,"url":"\/members\/karlie-beil-113632","name":"Karlie Beil","avatar":"https:\/\/uploads-us-west-2.insided.com\/nutanix-us\/icon\/200x200\/1581aab3-bcf6-49f4-b2fb-3d11e8c010dc.png","userTitle":"Community Manager","rank":{"isBold":false,"isItalic":false,"isUnderline":false,"name":"Community Manager","color":"#0873ba"},"userLevel":4},"type":"Webinar","url":"https:\/\/next.nutanix.com\/events\/global-nug-nc2-on-azure-and-aws-with-citrix-151","image":"https:\/\/uploads-us-west-2.insided.com\/nutanix-us\/attachment\/f9693b5b-436b-427a-9b98-531b4040ff24_thumb.png","location":"","startsAt":1678298400,"endsAt":1678302000,"contentType":"event","attendees":[],"attendeeCount":0,"isLoggedInUserAttendee":false,"createdAt":"1675974969"},"phrases":{"Forum":{"{n} year|{n} years":"{n} year|{n} years","{n} month|{n} months":"{n} month|{n} months","{n} day|{n} days":"{n} day|{n} days","{n} hour|{n} hours":"{n} hour|{n} hours","{n} minute|{n} minutes":"{n} minute|{n} minutes","just":"just now","{plural} ago":"{plural} ago"}}}">

解决了

将变量传递到平静中的云点脚本?


UserLevel 2
徽章 +5
我知道在平静下您可以在服务中创建变量,然后在整个配置中使用@@ {service.variable} @@使用这些变量。但是,似乎您可以使用云脚本中的那些。我希望能够传递用户在部署时设置的变量(IP地址),然后将其在云中脚本中使用。



我尝试了这样的事情,无济于事:



代码:
#Cloud-Config
主机名:haproxy1
fqdn:haproxy1.domain.com
SSH_PWAUTH:是的
write_files:
- 路径:/etc/sysconfig/network-scripts/ifcfg-eth0
内容:|
设备= ETH0
bootproto =“无”
ipaddr =“ @@ {haproxy1.ip_address} @@”
前缀=“ 24”
网关=“ 172.25.51.254”
domain =“ vipcustomers.com vtinfo.com”
defroute =“是”
ONBOOT =“是”
DNS1 =“ 172.25.51.10”
dns2 =“ 172.25.51.2”
ipv4_failure_fatal =“是”
ipv6init =“否”
runcmd:
- [ifdown,eth0]
- [ifup,eth0]




其中haproxy1.ip_address是用户定义的变量。关于我如何实现这一目标有什么想法吗?
图标

最好的答案钱德鲁2018年5月25日,08:06

@JoeLemaire<\/user-mention> on PC versions below 5.7 @@{service.variable}@@ is not working inside guest customization scripts due to a bug. As an alternate you can define the variable in the Application profile and use it in your cloud init scripts. Instructions are below for configuring the variables in Application profile,
\r\n
\r\nhttps:\/\/portal.nutanix.com\/#\/page\/docs\/details?targetId=Nutanix-Calm-Admin-Operations-Guide-v57:nuc-adding-configure-application-profile-t.html
\r\n
\r\nYou should have a default Application Profile already in the blueprint, you can configure the variable in the default Application profile.
\r\n
\r\nWhen you define variables in the Application profile you need to just refer to the variable as @@{variable}@@ in the scripts. So, in your case if your variable is IP_Address then just refer to it in the Cloudinit script as @@{IP_Address}@@.","className":"post__content__best_answer"}">
查看原件

该主题已关闭以供评论

7个答复

Userlevel 1
徽章 +6
你好,



它应该起作用。我从Kubernetes蓝图中发现了这个片段,我几次使用了。您能指定您正在使用的版本吗?PC,AOS,AHV/VMware等?



此致,

托马斯



#Cloud-Config

用户:

- 名称:Kube

SSH授权 - 凯斯:

- @@ {instance_public_key} @@

sudo:['all =(all)nopasswd:all']
UserLevel 2
徽章 +5
感谢回复 @tfindelk。我正在使用PC 5.5.2,AOS 5.5.0.6(下周升级到5.5.2)和AHV 20170830.94。
Userlevel 1
徽章 +6
MHH ..用户定义的变量包含一个“”。点。也许您可以解释为什么这是?我定义的变量没有点。
UserLevel 3
徽章 +13
@joelemaire我已经在5.7.0.1 PC上测试了您的蓝图,并且该变量正常。在您的5.5.2版本上,您是否看到已部署VM,但未能设置IP地址或VM部署失败而错误?
UserLevel 3
徽章 +13
@joelemaire在低于5.7 @@ {service.variable} @@的PC版本上,由于错误而无法在访客自定义脚本内部工作。作为替代方案,您可以在应用程序配置文件中定义变量,并在云初始脚本中使用它。下面的说明用于配置应用程序配置文件中的变量,



https://portal.nutanix.com/#/page/docs/details?targetId= nutanix-calm-admin-operations-guide-v57:nuc-adding-configure-application-profile-profile-profile-p.html



您应该在蓝图中已经有一个默认的应用程序配置文件,可以在默认应用程序配置文件中配置变量。



当您在应用程序配置文件中定义变量时,您需要将变量称为@@ {variable} @@在脚本中。因此,在您的情况下,如果您的变量为ip_address,则只需在CloudInit脚本中参考@@ {ip_address} @@。
UserLevel 2
徽章 +5
@chandru感谢您的提示。实际上,这最终解决了我的问题!



出于好奇,是否有好处(在此错误围绕此错误之外)来定义应用程序配置文件与服务本身中的变量?更好的是一种方式还是另一种方式?只是为“最佳实践”感到好奇。



另外,谢谢 @tfindelk为此,您的协助也是如此!
@joelemaire取决于用例等,将其视为在蓝图中对象上变量的范围。因此,根据您想要使用的位置等,您可能需要在不同的级别上定义它。
Learn more about our cookies.<\/a>","cookiepolicy.button":"Accept cookies","cookiepolicy.button.deny":"Deny all","cookiepolicy.link":"Cookie settings","cookiepolicy.modal.title":"Cookie settings","cookiepolicy.modal.content":"We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.<\/a>","cookiepolicy.modal.level1":"Basic
Functional","cookiepolicy.modal.level2":"Normal
Functional + analytics","cookiepolicy.modal.level3":"Complete
Functional + analytics + social media + embedded videos"}}}">
Baidu