b910d6c149cd7bb1cfb261d9ef64696ac6080419
[apex-tripleo-heat-templates.git] / ci / pingtests / tenantvm_floatingip.yaml
1 heat_template_version: ocata
2
3 description: >
4   This template resides in tripleo-ci for Mitaka CI jobs only.
5   For Newton and beyond, please look in THT.
6   HOT template to create a new neutron network plus a router to the public
7   network, and for deploying a server into the new network. The template also
8   assigns a floating IP address and sets security group rules. ADAPTED FROM
9   https://raw.githubusercontent.com/openstack/heat-templates/master/hot/servers_in_new_neutron_net.yaml
10 parameters:
11   key_name:
12     type: string
13     description: Name of keypair to assign to servers
14     default: 'pingtest_key'
15   image:
16     type: string
17     description: Name of image to use for servers
18     default: 'pingtest_image'
19   public_net_name:
20     type: string
21     default: 'nova'
22     description: >
23       ID or name of public network for which floating IP addresses will be allocated
24   private_net_name:
25     type: string
26     description: Name of private network to be created
27     default: 'default-net'
28   private_net_cidr:
29     type: string
30     description: Private network address (CIDR notation)
31     default: '192.168.2.0/24'
32   private_net_gateway:
33     type: string
34     description: Private network gateway address
35     default: '192.168.2.1'
36   private_net_pool_start:
37     type: string
38     description: Start of private network IP address allocation pool
39     default: '192.168.2.100'
40   private_net_pool_end:
41     type: string
42     default: '192.168.2.200'
43     description: End of private network IP address allocation pool
44
45 resources:
46
47   key_pair:
48     type: OS::Nova::KeyPair
49     properties:
50       save_private_key: true
51       name: {get_param: key_name }
52
53   private_net:
54     type: OS::Neutron::Net
55     properties:
56       name: { get_param: private_net_name }
57
58   private_subnet:
59     type: OS::Neutron::Subnet
60     properties:
61       network_id: { get_resource: private_net }
62       cidr: { get_param: private_net_cidr }
63       gateway_ip: { get_param: private_net_gateway }
64       allocation_pools:
65         - start: { get_param: private_net_pool_start }
66           end: { get_param: private_net_pool_end }
67
68   router:
69     type: OS::Neutron::Router
70     properties:
71       external_gateway_info:
72         network: { get_param: public_net_name }
73
74   router_interface:
75     type: OS::Neutron::RouterInterface
76     properties:
77       router_id: { get_resource: router }
78       subnet_id: { get_resource: private_subnet }
79
80   volume1:
81     type: OS::Cinder::Volume
82     properties:
83       name: Volume1
84       image: { get_param: image }
85       size: 1
86
87   server1:
88     type: OS::Nova::Server
89     depends_on: volume1
90     properties:
91       name: Server1
92       block_device_mapping:
93         - device_name: vda
94           volume_id: { get_resource: volume1 }
95       flavor: { get_resource: test_flavor }
96       key_name: { get_resource: key_pair }
97       networks:
98         - port: { get_resource: server1_port }
99
100   server1_port:
101     type: OS::Neutron::Port
102     properties:
103       network_id: { get_resource: private_net }
104       fixed_ips:
105         - subnet_id: { get_resource: private_subnet }
106       security_groups: [{ get_resource: server_security_group }]
107
108   server1_floating_ip:
109     type: OS::Neutron::FloatingIP
110     # TODO: investigate why we need this depends_on and if we could
111     # replace it by router_id with get_resource: router_interface
112     depends_on: router_interface
113     properties:
114       floating_network: { get_param: public_net_name }
115       port_id: { get_resource: server1_port }
116
117   server_security_group:
118     type: OS::Neutron::SecurityGroup
119     properties:
120       description: Add security group rules for server
121       name: pingtest-security-group
122       rules:
123         - remote_ip_prefix: 0.0.0.0/0
124           protocol: tcp
125           port_range_min: 22
126           port_range_max: 22
127         - remote_ip_prefix: 0.0.0.0/0
128           protocol: icmp
129
130   test_flavor:
131     type: OS::Nova::Flavor
132     properties:
133       ram: 512
134       vcpus: 1
135
136 outputs:
137   server1_private_ip:
138     description: IP address of server1 in private network
139     value: { get_attr: [ server1, first_address ] }
140   server1_public_ip:
141     description: Floating IP address of server1 in public network
142     value: { get_attr: [ server1_floating_ip, floating_ip_address ] }