summaryrefslogtreecommitdiffstats
path: root/tools/cicdansible/heat/instance.yaml
blob: 30d8eea0c72ea6a6b15b19eb50e706148fa42f25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#Template for instances.
heat_template_version: 2017-02-24
description: "template instantiating and configuring a single instance (any)"
parameters:
  instance_name:
    type: string
  network:
    type: string
  subnet:
    type: string
  image_name:
    type: string
  flavor_name:
    type: string
  key_name:
    type: string
  notify_command:
    type: string
  security_group:
    type: string
  scheduler_hints:
    type: json
    default: {}
  demo_network:
    type: string
    default: ""
  availability_zone:
    type: string
conditions:
  #Condition for demo network connection
  connect_demo_net:
    not:
      equals:
        - get_param: demo_network
        - ""
#Resources.
resources:
  #This is the network port to attach instance to.
  port:
    type: OS::Neutron::Port
    properties:
      network: { get_param: network }
      security_groups: [ { get_param: security_group } ]
      fixed_ips:
        - { subnet: { get_param: subnet }}
  #cloudinit configuration stuff.
  config:
    type: OS::Heat::SoftwareConfig
    properties:
      config:
        str_replace_strict:
          template: { get_file: config.yaml }
          params:
            "%{NOTIFY_COMMAND}": { get_param: notify_command }
  #Actual instance to create.
  instance:
    type: OS::Nova::Server
    properties:
      name: { get_param: instance_name }
      image: { get_param: image_name }
      flavor: { get_param: flavor_name }
      availability_zone: { get_param: availability_zone }
      key_name: { get_param: key_name }
      config_drive: true
      networks:
        if:
        - "connect_demo_net"
        - - port: { get_resource: port }
          - network: { get_param: demo_network }
        - - port: { get_resource: port }
      user_data_format: SOFTWARE_CONFIG
      user_data: { get_resource: config }
      scheduler_hints: { get_param: scheduler_hints }
outputs:
  OS::stack_id:
    value: { get_resource: instance }
  port_id:
    value: { get_resource: port }
  ip:
    value: { get_attr: ["port", "fixed_ips", 0, "ip_address"] }