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