blob: 3636a49e3701d64f7563bbbf13f3ec1148e02862 [file] [log] [blame]
Oleg Basov5c426192019-02-05 17:00:35 +01001heat_template_version: 2013-05-23
2
3description:
4 This Heat template creates a new Neutron network, a router to the external
5 network and plugs instances into this new network. All instances are located
6 in the same L2 domain.
7
8parameters:
9 image:
10 type: string
11 description: Name of image to use for servers
12 flavor:
13 type: string
14 description: Flavor to use for servers
15 external_net:
16 type: string
17 description: ID or name of external network
18 server_endpoint:
19 type: string
20 description: Server endpoint address
21 dns_nameservers:
22 type: comma_delimited_list
23 description: DNS nameservers for the subnet
24
25resources:
26 private_net:
27 type: OS::Neutron::Net
28 properties:
29 name: {{ unique }}_net
30
31 private_subnet:
32 type: OS::Neutron::Subnet
33 properties:
34 network_id: { get_resource: private_net }
35 cidr: 10.0.0.0/16
36 dns_nameservers: { get_param: dns_nameservers }
37
38 router:
39 type: OS::Neutron::Router
40 properties:
41 external_gateway_info:
42 network: { get_param: external_net }
43
44 router_interface:
45 type: OS::Neutron::RouterInterface
46 properties:
47 router_id: { get_resource: router }
48 subnet_id: { get_resource: private_subnet }
49
50 server_security_group:
51 type: OS::Neutron::SecurityGroup
52 properties:
53 rules: [
54 {remote_ip_prefix: 0.0.0.0/0,
55 protocol: tcp,
56 port_range_min: 1,
57 port_range_max: 65535},
58 {remote_ip_prefix: 0.0.0.0/0,
59 protocol: udp,
60 port_range_min: 1,
61 port_range_max: 65535},
62 {remote_ip_prefix: 0.0.0.0/0,
63 protocol: icmp}]
64
65{% for agent in agents.values() %}
66
67 {{ agent.id }}:
68 type: OS::Nova::Server
69 properties:
70 name: {{ agent.id }}
Oleg Basov06e9bd32019-02-15 10:19:41 +010071 image: { get_param: image }
Oleg Basov5c426192019-02-05 17:00:35 +010072 flavor: { get_param: flavor }
73 availability_zone: "{{ agent.availability_zone }}"
74 networks:
75 - port: { get_resource: {{ agent.id }}_port }
76 user_data_format: RAW
77 user_data:
78 str_replace:
79 template: |
80 #!/bin/sh
81 screen -dmS shaker-agent-screen shaker-agent --server-endpoint=$SERVER_ENDPOINT --agent-id=$AGENT_ID
82 params:
83 "$SERVER_ENDPOINT": { get_param: server_endpoint }
84 "$AGENT_ID": {{ agent.id }}
85
86 {{ agent.id }}_port:
87 type: OS::Neutron::Port
88 properties:
89 network_id: { get_resource: private_net }
90 fixed_ips:
91 - subnet_id: { get_resource: private_subnet }
92 security_groups: [{ get_resource: server_security_group }]
93
94{% endfor %}
95
96outputs:
97{% for agent in agents.values() %}
98 {{ agent.id }}_instance_name:
99 value: { get_attr: [ {{ agent.id }}, instance_name ] }
100 {{ agent.id }}_ip:
101 value: { get_attr: [ {{ agent.id }}, networks, { get_attr: [private_net, name] }, 0 ] }
102{% endfor %}