|
5 | 5 | VAGRANTFILE_API_VERSION = '2' |
6 | 6 |
|
7 | 7 | Vagrant.require_version '>= 1.5.0' |
| 8 | +cloudstack_pf_ip_address = ENV['PUBLIC_SOURCE_NAT_IP'] |
| 9 | +machines = { |
| 10 | + box1: { |
| 11 | + # Test fixed public port |
| 12 | + pf_public_port: ENV['PUBLIC_SSH_PORT'], |
| 13 | + # Test fixed private port |
| 14 | + pf_private_port: ENV['PRIVATE_SSH_PORT'], |
| 15 | + firewall_rules: [ |
| 16 | + # Full Firewall rule |
| 17 | + {:ipaddress => cloudstack_pf_ip_address, :protocol => 'tcp', :startport => 1111, :endport => 1111}, |
| 18 | + # Firewall rule without ':ipaddress' which defaults to 'cloudstack_pf_ip_address' |
| 19 | + {:protocol => 'tcp', :startport => 1122, :endport => 1122}, |
| 20 | + # Firewall rule without ':protocol', which defaults to 'tcp' |
| 21 | + {:startport => 1133, :endport => 1133}, |
| 22 | + # Firewall rule without ':endport', which defaults to ':startport' if present |
| 23 | + {:startport => 1144}, |
| 24 | + # Firewall rule without ':start', which defaults to ':endport' if present |
| 25 | + {:endport => 22} |
| 26 | + ], |
| 27 | + port_forwarding_rules: [ |
| 28 | + # Full portforwarding rule |
| 29 | + {:ipaddress => cloudstack_pf_ip_address, :protocol => "tcp", :publicport => 1111, :privateport => 22, :openfirewall => false}, |
| 30 | + # Portforwarding rule without ':ipaddress' which defaults to 'cloudstack_pf_ip_address' |
| 31 | + {:protocol => "tcp", :publicport => 1122, :privateport => 22, :openfirewall => false}, |
| 32 | + # Portforwarding rule without ':protocol', which defaults to 'tcp' |
| 33 | + {:publicport => 1133, :privateport => 22, :openfirewall => false}, |
| 34 | + # Portforwarding rule without ':openfirewall', which defaults to 'cloudstack.pf_open_firewall' |
| 35 | + {:publicport => 1144, :privateport => 22}, |
| 36 | + # Portforwarding rule without ':publicport', which defaults to ':privateport' |
| 37 | + {:privateport => 22}, |
| 38 | + # Portforwarding rule with ':generate_firewall', which generates an apropriate |
| 39 | + # Firewall rule based ':publicport' => ':startport', and other defaults |
| 40 | + {:publicport => 1155, :privateport => 22, :generate_firewall => true}, |
| 41 | + # Portforwarding rule which instructs CloudStack to create a Firewall rule |
| 42 | + {:publicport => 1166, :privateport => 22, :openfirewall => true}, |
| 43 | + ], |
| 44 | + # Trusted network as array, instead of string. Add some networks to make sure it's an (multi element) Array |
| 45 | + pf_trusted_networks: [ENV['SOURCE_CIDR'], ',172.31.1.172/32', '172.31.1.173/32'], |
| 46 | + # Ignore security groups |
| 47 | + security_groups: [{ |
| 48 | + :name => "Awesome_security_group", |
| 49 | + :description => "Created from the Vagrantfile", |
| 50 | + :rules => [{:type => "ingress", :protocol => "TCP", :startport => 22, :endport => 22, :cidrlist => "0.0.0.0/0"}] |
| 51 | + }], |
| 52 | + # Ignore security groups |
| 53 | + security_group_names: ['default', 'Awesome_security_group'], |
| 54 | + }, |
| 55 | + box2: { |
| 56 | + # NO pf_public_port; test auto generated public port |
| 57 | + # NO pf_private_port; test detection of Communicator port (SSH/Winrm) |
| 58 | + # NO firewall rules for Communicator (SSH/WinRM), test auto generation |
| 59 | + # Trusted networks as string instead of array. Add some networks to make sure it supports multiple network-string |
| 60 | + pf_trusted_networks: ENV['SOURCE_CIDR'] + ',172.31.1.172/32,172.31.1.173/32' |
| 61 | + } |
| 62 | +} |
8 | 63 |
|
9 | | -Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
10 | | - config.vm.box = ENV['LINUX_TEMPLATE_NAME'] |
| 64 | +Vagrant.configure(VAGRANTFILE_API_VERSION) do |global_config| |
| 65 | + machines.each_pair do |name, options| |
| 66 | + global_config.vm.define name do |config| |
| 67 | + config.vm.box = ENV['LINUX_TEMPLATE_NAME'] |
11 | 68 |
|
12 | | - config.vm.synced_folder ".", "/vagrant", type: "rsync", |
13 | | - rsync__exclude: [".git/", "vendor"], disabled: true |
| 69 | + config.vm.synced_folder ".", "/vagrant", type: "rsync", |
| 70 | + rsync__exclude: [".git/", "vendor"], disabled: true |
14 | 71 |
|
15 | | - config.vm.provider :cloudstack do |cloudstack, override| |
16 | | - cloudstack.display_name = ENV['TEST_NAME'] |
| 72 | + config.vm.provider :cloudstack do |cloudstack, override| |
| 73 | + cloudstack.display_name = "#{name}-#{ENV['TEST_NAME']}" |
17 | 74 |
|
18 | | - cloudstack.host = ENV['CLOUDSTACK_HOST'] |
19 | | - # Use default path, port and scheme |
20 | | - cloudstack.api_key = ENV['CLOUDSTACK_API_KEY'] |
21 | | - cloudstack.secret_key = ENV['CLOUDSTACK_SECRET_KEY'] |
22 | | - cloudstack.zone_name = ENV['ZONE_NAME'] |
23 | | - cloudstack.network_name = ENV['NETWORK_NAME'] |
24 | | - cloudstack.service_offering_name = ENV['SERVICE_OFFERING_NAME'] |
25 | | - cloudstack.ssh_key = ENV['SSH_KEY'] unless ENV['SSH_KEY'].nil? |
26 | | - cloudstack.ssh_user = ENV['SSH_USER'] unless ENV['SSH_USER'].nil? |
| 75 | + cloudstack.host = ENV['CLOUDSTACK_HOST'] |
| 76 | + # Use default path, port and scheme |
| 77 | + cloudstack.api_key = ENV['CLOUDSTACK_API_KEY'] |
| 78 | + cloudstack.secret_key = ENV['CLOUDSTACK_SECRET_KEY'] |
| 79 | + cloudstack.zone_name = ENV['ZONE_NAME'] |
| 80 | + cloudstack.network_name = ENV['NETWORK_NAME'] |
| 81 | + cloudstack.service_offering_name = ENV['SERVICE_OFFERING_NAME'] |
| 82 | + cloudstack.ssh_key = ENV['SSH_KEY'] unless ENV['SSH_KEY'].nil? |
| 83 | + cloudstack.ssh_user = ENV['SSH_USER'] unless ENV['SSH_USER'].nil? |
| 84 | + cloudstack.expunge_on_destroy == true |
27 | 85 |
|
28 | | - cloudstack.pf_ip_address = ENV['PUBLIC_SOURCE_NAT_IP'] |
29 | | - cloudstack.pf_public_port = ENV['PUBLIC_SSH_PORT'] |
30 | | - cloudstack.pf_private_port = ENV['PRIVATE_SSH_PORT'] |
31 | | - cloudstack.pf_open_firewall = false |
| 86 | + cloudstack.pf_ip_address = cloudstack_pf_ip_address |
| 87 | + cloudstack.pf_public_port = options[:pf_public_port] unless options[:pf_public_port].nil? |
| 88 | + cloudstack.pf_private_port = options[:pf_private_port] unless options[:pf_private_port].nil? |
| 89 | + cloudstack.pf_open_firewall = false |
32 | 90 |
|
33 | | - # With Advanced networking, following Basic networking features should be ignored |
34 | | - cloudstack.security_groups = [{ |
35 | | - :name => "Awesome_security_group", |
36 | | - :description => "Created from the Vagrantfile", |
37 | | - :rules => [{:type => "ingress", :protocol => "TCP", :startport => 22, :endport => 22, :cidrlist => "0.0.0.0/0"}] |
38 | | - }] |
39 | | - cloudstack.security_group_names = ['default', 'Awesome_security_group'] |
40 | | - # With Advanced networking, following Basic networking features should be ignored |
| 91 | + # With Advanced networking, following Basic networking features should be ignored |
| 92 | + cloudstack.security_groups = options[:security_groups] unless options[:security_groups].nil? |
| 93 | + cloudstack.security_group_names = options[:security_group_names] unless options[:security_group_names].nil? |
| 94 | + # With Advanced networking, following Basic networking features should be ignored |
41 | 95 |
|
42 | | - cloudstack.pf_trusted_networks = [ ENV['SOURCE_CIDR'] ] |
43 | | - cloudstack.firewall_rules = [ |
44 | | - # Full Firewall rule |
45 | | - { :ipaddress => cloudstack.pf_ip_address, :protocol => 'tcp', :startport => 1111, :endport => 1111 }, |
46 | | - # Firewall rule without ':ipaddress' which defaults to 'cloudstack.pf_ip_address' |
47 | | - { :protocol => 'tcp', :startport => 1122, :endport => 1122 }, |
48 | | - # Firewall rule without ':protocol', which defaults to 'tcp' |
49 | | - { :startport => 1133, :endport => 1133 }, |
50 | | - # Firewall rule without ':endport', which defaults to ':startport' if present |
51 | | - { :startport => 1144 }, |
52 | | - # Firewall rule without ':start', which defaults to ':endport' if present |
53 | | - { :endport => 22 } |
54 | | - ] |
55 | | - cloudstack.port_forwarding_rules = [ |
56 | | - # Full portforwarding rule |
57 | | - { :ipaddress => cloudstack.pf_ip_address, :protocol => "tcp", :publicport => 1111, :privateport => 22, :openfirewall => false }, |
58 | | - # Portforwarding rule without ':ipaddress' which defaults to 'cloudstack.pf_ip_address' |
59 | | - { :protocol => "tcp", :publicport => 1122, :privateport => 22, :openfirewall => false }, |
60 | | - # Portforwarding rule without ':protocol', which defaults to 'tcp' |
61 | | - { :publicport => 1133, :privateport => 22, :openfirewall => false }, |
62 | | - # Portforwarding rule without ':openfirewall', which defaults to 'cloudstack.pf_open_firewall' |
63 | | - { :publicport => 1144, :privateport => 22 }, |
64 | | - # Portforwarding rule without ':publicport', which defaults to ':privateport' |
65 | | - { :privateport => 22 }, |
66 | | - # Portforwarding rule with ':generate_firewall', which generates an apropriate |
67 | | - # Firewall rule based ':publicport' => ':startport', and other defaults |
68 | | - { :publicport => 1155, :privateport => 22, :generate_firewall => true }, |
69 | | - # Portforwarding rule which instructs CloudStack to create a Firewall rule |
70 | | - { :publicport => 1166, :privateport => 22, :openfirewall => true }, |
71 | | - ] |
| 96 | + cloudstack.pf_trusted_networks = options[:pf_trusted_networks] unless options[:pf_trusted_networks].nil? |
| 97 | + cloudstack.firewall_rules = options[:firewall_rules] unless options[:firewall_rules].nil? |
| 98 | + cloudstack.port_forwarding_rules = options[:port_forwarding_rules] unless options[:port_forwarding_rules].nil? |
| 99 | + end |
| 100 | + end |
72 | 101 | end |
73 | 102 | end |
0 commit comments