4b97495e2e4fae4848e655bc79191e165c53d473
[snaps.git] / snaps / openstack / tests / heat / agent-group.yaml
1 ##############################################################################
2 # Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs")
3 #                    and others.  All rights reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at:
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 ##############################################################################
17 heat_template_version: 2013-05-23
18
19 parameters:
20   public_network:
21     type: string
22     constraints:
23         - custom_constraint: neutron.network
24   agent_flavor:
25     type: string
26   agent_image:
27     type: string
28   volume_size:
29     type: number
30     description: Size of the volume to be created.
31     default: 1
32     constraints:
33       - range: { min: 1, max: 1024 }
34         description: must be between 1 and 1024 Gb.
35   agent_count:
36     type: number
37     default: 1
38     constraints:
39       - range: { min: 1, max: 512 }
40         description: must be between 1 and 512 agents.
41   availability_zone:
42     type: string
43     default: nova
44   network_name:
45     type: string
46   key_name:
47     type: string
48
49 resources:
50   slaves:
51     type: OS::Heat::ResourceGroup
52     depends_on: [subnet, network_router_interface,
53       open_security_group, key_pair]
54     properties:
55       count: {get_param: agent_count}
56       resource_def: {
57         type: "agent.yaml",
58         properties: {
59           public_network: {get_param: public_network},
60           agent_network: {get_resource: network},
61           flavor: {get_param: agent_flavor},
62           image: {get_param: agent_image},
63           availability_zone: {get_param: availability_zone},
64           open_security_group: {get_resource: open_security_group},
65           key_name: {get_resource: key_pair},
66           volume_size: {get_param: volume_size}
67         }
68       }
69
70   network:
71         type: OS::Neutron::Net
72         properties:
73           name: { get_param: agent_count }
74
75   subnet:
76         type: OS::Neutron::Subnet
77         properties:
78           network_id: { get_resource: network }
79           cidr: 172.16.0.0/16
80           gateway_ip: 172.16.0.1
81
82   network_router:
83         type: OS::Neutron::Router
84         properties:
85           external_gateway_info:
86                 network: { get_param: public_network }
87
88   network_router_interface:
89         type: OS::Neutron::RouterInterface
90         properties:
91           router_id: { get_resource: network_router }
92           subnet_id: { get_resource: subnet }
93
94   key_pair:
95     type: OS::Nova::KeyPair
96     properties:
97       save_private_key: true
98       name: { get_param: key_name }
99
100   open_security_group:
101     type: OS::Neutron::SecurityGroup
102     properties:
103       description: An open security group to allow all access to the slaves
104       rules:
105         - remote_ip_prefix: 0.0.0.0/0
106           protocol: tcp
107           port_range_min: 22
108           port_range_max: 22
109         - remote_ip_prefix: 0.0.0.0/0
110           protocol: icmp
111
112 outputs:
113   slave_ips: {
114       description: "Slave addresses",
115       value: { get_attr: [ slaves, agent_ip] }
116   }
117   private_key:
118     description: "SSH Private Key"
119     value: { get_attr: [ key_pair, private_key ]}