Fixed vm instance instantiation from Heat when using nested resources
[snaps.git] / snaps / openstack / tests / heat / agent.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   flavor:
21     type: string
22     default: test
23   image:
24     type: string
25     default: 'Ubuntu 16.04'
26   key_name:
27     type: string
28     default: test_key
29   username:
30     type: string
31     default: test_user
32   open_security_group:
33     type: string
34   volume_size:
35     type: number
36     description: Size of the volume to be created.
37     default: 1
38     constraints:
39       - range: { min: 1, max: 1024 }
40         description: must be between 1 and 1024 Gb.
41   agent_network:
42     type: string
43     constraints:
44         - custom_constraint: neutron.network
45   public_network:
46     type: string
47     constraints:
48         - custom_constraint: neutron.network
49   availability_zone:
50     type: string
51     default: nova
52
53 resources:
54   agent:
55     type: "OS::Nova::Server"
56     properties:
57       name: agent
58       image: { get_param: image }
59       flavor: { get_param: flavor }
60       key_name: { get_param: key_name }
61       networks:
62         - port: { get_resource: agent_port }
63       user_data: { get_resource: agent_config }
64       user_data_format: RAW
65       availability_zone: { get_param: availability_zone}
66
67   agent_config:
68     type: "OS::Heat::CloudConfig"
69     properties:
70       cloud_config:
71         users:
72         - name: { get_param: username }
73           groups: users
74           shell: /bin/bash
75           sudo: "ALL=(ALL) NOPASSWD:ALL"
76           ssh_authorized_keys:
77           - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDEbnDiqZ8RjQJJzJPf074J41XlYED+zYBzaUZ5UkkUquXzymyUmoWaFBXJP+XPu4Ns44U/S8614+JxGk96tjUdJlIjL0Ag8HP6KLtTNCabucKcEASpgJIVWqJvE3E9upZLIEiTGsF8I8S67T2qq1J1uvtxyeZmyjm7NMamjyFXE53dhR2EHqSutyKK1CK74NkRY9wr3qWUIt35kLdKSVSfrr4gOOicDALbIRu77skHIvrjt+wK1VWphBdMg6ytuq5mIE6pjWAU3Gwl4aTxOU0z43ARzCLq8HVf8s/dKjYMj8plNqaIfceMbaEUqpNHv/xbvtGNG7N0aB/a4pkUQL07
78         - default
79         package_update: false
80         package_upgrade: false
81         manage_etc_hosts: localhost
82
83   agent_port:
84     type: "OS::Neutron::Port"
85     properties:
86       network_id: { get_param: agent_network }
87       security_groups:
88         - { get_param: open_security_group }
89
90   floating_ip:
91     type: OS::Neutron::FloatingIP
92     properties:
93       floating_network_id: { get_param: public_network }
94       port_id: { get_resource: agent_port }
95
96   agent_volume:
97     type: OS::Cinder::Volume
98     properties:
99       size: { get_param: volume_size }
100
101   agent_volume_att:
102     type: OS::Cinder::VolumeAttachment
103     properties:
104       instance_uuid: { get_resource: agent }
105       volume_id: { get_resource: agent_volume}
106
107 outputs:
108   agent_ip:
109     description: The floating IP address of the agent on the public network
110     value: { get_attr: [ floating_ip, floating_ip_address ] }