【问题标题】:Openstack Heat Template output for powershell commandPowershell 命令的 Openstack Heat 模板输出
【发布时间】:2018-06-21 12:40:05
【问题描述】:

我使用 Powershell 命令创建了 Heat 模板,但我的模板在添加部署部分后没有得到执行。我已添加此部分以获取命令的输出。下面显示了我正在使用的模板:

heat_template_version: 2016-10-14

description: Template to install HyperV Feature in Server

resources:
   floating_ip:
      type: OS::Neutron::FloatingIP
      properties:
         floating_network: Net_External_16

   instance:
      type: OS::Nova::Server
      properties:
         name: machine2
         flavor: LARGE
         networks:
            - network: 71xxxx85-8a24-475b-9xxc-169xxxxxbb0
         security_groups:
            - default
            - all_open
         block_device_mapping_v2:
            - device_name: /dev/vpa
              volume_id: {get_resource: volume}
              delete_on_termination: "true"
   volume:
      type: OS::Cinder::Volume
      properties:
         size: 25
         image: 51xxxxxbe-44e6-4206-920c-xxxxxxxxxx
         name: {get_param: volumename}

   ps_script:
      type: OS::Heat::SoftwareConfig
      properties:
         group: ungrouped
         config:
            str_replace:
               template: |
                  #ps1_sysnative
                  $log = New-Item "C:\check_file.txt" -Type File
                  start-sleep -s 20
                  install-windowsfeature -Name DNS -IncludeManagementTools
                  start-sleep -s 60
                  $pass = "_parameter_1_"
                  Add-content $log $pass

               params:
                  _parameter_1_: {get_param: parameter1}

   association:
      type: OS::Neutron::FloatingIPAssociation
      properties:
         floatingip_id: {get_resource: floating_ip}
         port_id: {get_attr: [instance, addresses, 71xxxxx85-8a24-4xxb-9xxc-16xxxx84bb0, 0, port]}

   deployment:
      type: OS::Heat::SoftwareDeployment
      properties:
         config: {get_resource: ps_script}
         server: {get_resource: instance }

outputs:
   instance_ip:
      description: Ipaddress
      value: {get_attr: [instance,addresses]}
   result:
     description: Checkoutput
     value: {get_attr: [deployent]}

如果有人尝试过同样的方法或他们可以提供的任何其他解决方案来获取从 Template 执行的 powershell 命令的输出。

【问题讨论】:

  • 你得到了什么确切的错误?
  • 当您尝试启动堆栈时,您收到的错误消息是什么?
  • 我没有得到确切的错误。堆栈创建开始,但它保持在进行状态。如果您有任何示例模板可以在 heat 模板中获取 powershell 命令的输出,请分享。这将非常有帮助。
  • 我很难找到有关如何执行此操作的明确资源。你的帖子帮助了我,我确实使用下面的 kvmahesh 答案让它工作了。

标签: openstack openstack-heat


【解决方案1】:

OS::Nova::Server 属性下添加user_data_format: SOFTWARE_CONFIG 行:

instance:
  type: OS::Nova::Server
  properties:
     name: machine2
     flavor: LARGE
     networks:
        - network: 71xxxx85-8a24-475b-9xxc-169xxxxxbb0
     security_groups:
        - default
        - all_open
     block_device_mapping_v2:
        - device_name: /dev/vpa
          volume_id: {get_resource: volume}
          delete_on_termination: "true"
     user_data_format: SOFTWARE_CONFIG

当有其他软件配置资源时,此行是必需的。

输出部分deployent -> deployment

outputs:
  instance_ip:
    description: Ipaddress
    value: { get_attr: [instance,addresses] }
  result:
   description: Checkoutput
   value: { get_attr: [deployment] }

注意:在{之后和}之前添加space。例如:

 { get_resource: volume }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-25
    • 1970-01-01
    • 2018-10-31
    • 1970-01-01
    相关资源
    最近更新 更多