Skip to content
Snippets Groups Projects
sharednetwork.pp 2.27 KiB
Newer Older
  • Learn to ignore specific revisions
  • # A static class to set up a shared network. Should appear on the
    # controller node. It sets up the public network, a private network,
    # two subnets (one for admin, one for test), and the routers that
    # connect the subnets to the public network.
    #
    # After this class has run, you should have a functional network
    # avaiable for your test user to launch and connect machines to.
    class iaas::setup::sharednetwork (
    
    #New variable definition
    # tenant where configure network defined as yaml variable
     $tenant = hiera('iaas::profile::network::tenant', undef),
     $external_network = hiera('iaas::profile::neutron::external_network', undef),
     $gateway  = hiera('iaas::profile::neutron::external_gateway', undef),
    # $dns      = hiera('iaas::profile::base::dns_servers', undef),
     $start_ip = hiera('iaas::profile::neutron::network_external_ippool_start', undef),
     $end_ip   = hiera('iaas::profile::neutron::network_external_ippool_end', undef),
     $private_network =  hiera('iaas::profile::neutron::network_neutron_private', undef),
    ) {
    
    $ip_range = "start=${start_ip},end=${end_ip}"
    
    notify {"debug message: ${start_ip}; ${end_ip}; ${ip_range}":
    loglevel => alert
    }
    
      neutron_network { 'public':
        tenant_name              => 'services',
        provider_network_type    => 'gre',
        router_external          => true,
        provider_segmentation_id => 3604,
        shared                   => true,
      } ->
    
      neutron_subnet { $external_network:
        cidr             => $external_network,
        ip_version       => '4',
        gateway_ip       => $gateway,
        enable_dhcp      => false,
        network_name     => 'public',
        tenant_name      => 'services',
        allocation_pools => [$ip_range],
    #DNS commented
    #    dns_nameservers  => [$dns],
      }
    
      neutron_network { 'private':
        tenant_name              => 'services',
        provider_network_type    => 'gre',
        router_external          => false,
        provider_segmentation_id => 4063,
        shared                   => true,
      } ->
    
      neutron_subnet { $private_network:
        cidr            => $private_network,
        ip_version      => '4',
        enable_dhcp     => true,
        network_name    => 'private',
        tenant_name     => 'services',
    #DNS commented
    #    dns_nameservers => [$dns],
      }
    
    # router setup for the selected tenant 
      iaas::setup::router { "${tenant}:${private_network}": }
    }