Paste #792445

Welcome To LodgeIt

Welcome to the LodgeIt pastebin. In order to use the notification feature a 31 day cookie with an unique ID was created for you. The lodgeit database does not store any information about you, it's just used for an advanced pastebin experience :-). Read more on the about lodgeit page. Have fun :-)

hide this notification

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
heat_template_version: 2015-10-15

description: A Group of Load Balanced Servers

parameters:

  app_port:
    type: number
    default: 8080
    description: Port used by the servers
  flavor:
    type: string
    default: cirros_flavor
    description: Flavor used for servers
    constraints:
    - custom_constraint: nova.flavor
  image:
    type: string
    default: cirros35
    description: Image used for servers
    constraints:
    - custom_constraint: glance.image
  private_network:
    type: string
    default: int_net_1
    description: Network used by the servers
    constraints:
    - custom_constraint: neutron.network

resources:

  sec_group:
    type: OS::Neutron::SecurityGroup
    properties:
      rules:
      - remote_ip_prefix: 0.0.0.0/0
        protocol: tcp
        port_range_min: { get_param: app_port }
        port_range_max: { get_param: app_port }
      - direction: ingress
        ethertype: IPv4
      - direction: ingress
        ethertype: IPv6

  server1:
    type: OS::Nova::Server
    properties:
      image: { get_param: image }
      flavor: { get_param: flavor }
      networks: [{ network: { get_param: private_network }}]
      security_groups: [{ get_resource: sec_group }]
      user_data_format: RAW
      user_data:
        str_replace:
          template: |
            #! /bin/sh -v
            Body=$(hostname)
            Response="HTTP/1.1 200 OK\r\nContent-Length: ${#Body}\r\n\r\n$Body"
            while true ; do echo -e $Response | nc -llp PORT; done
          params:
            PORT: { get_param: app_port }

  server2:
    type: OS::Nova::Server
    properties:
      image: { get_param: image }
      flavor: { get_param: flavor }
      networks: [{ network: { get_param: private_network }}]
      security_groups: [{ get_resource: sec_group }]
      user_data_format: RAW
      user_data:
        str_replace:
          template: |
            #! /bin/sh -v
            Body=$(hostname)
            Response="HTTP/1.1 200 OK\r\nContent-Length: ${#Body}\r\n\r\n$Body"
            while true ; do echo -e $Response | nc -llp PORT; done
          params:
            PORT: { get_param: app_port }