|
| 1 | +OpenStack Networks |
| 2 | +================== |
| 3 | + |
| 4 | +This role can be used to register networks, subnets and routers in neutron |
| 5 | +using the `openstack.cloud.network`, `openstack.cloud.subnet` and |
| 6 | +`openstack.cloud.router` modules. |
| 7 | + |
| 8 | +Requirements |
| 9 | +------------ |
| 10 | + |
| 11 | +The OpenStack neutron API should be accessible from the target host. |
| 12 | + |
| 13 | +Role Variables |
| 14 | +-------------- |
| 15 | + |
| 16 | +`os_networks_venv` is a path to a directory in which to create a virtualenv. |
| 17 | + |
| 18 | +`os_networks_auth_type` is an authentication type compatible with the |
| 19 | +`auth_type` argument of `openstack.cloud` Ansible modules. |
| 20 | + |
| 21 | +`os_networks_auth` is a dict containing authentication information |
| 22 | +compatible with the `auth` argument of `openstack.cloud` Ansible modules. |
| 23 | + |
| 24 | +`os_networks_cacert` is an optional path to a CA certificate bundle. |
| 25 | + |
| 26 | +`os_networks_cloud` is an optional name of a cloud in `clouds.yaml`. |
| 27 | + |
| 28 | +`os_networks_interface` is the endpoint URL type to fetch from the service |
| 29 | +catalog. Maybe be one of `public`, `admin`, or `internal`. |
| 30 | + |
| 31 | +`os_networks` is a list of networks to register. Each item should be a |
| 32 | +dict containing the following items: |
| 33 | + |
| 34 | +- `name`: Name of the neutron network. |
| 35 | +- `provider_network_type`: Provider type of the neutron network. |
| 36 | +- `provider_physical_network`: Provider physical network of the neutron |
| 37 | + network. |
| 38 | +- `provider_segmentation_id`: Provider segmentation ID of the neutron network. |
| 39 | +- `shared`: Whether the neutron network is shared. |
| 40 | +- `external`: Whether the neutron network is external. |
| 41 | +- `project`: Optionally create this network for a project other than the |
| 42 | + authenticating project. |
| 43 | +- `state`: Optional state of the network, default is `present`. |
| 44 | +- `mtu`: The maximum transmission unit (MTU) value to address fragmentation. |
| 45 | + Network will use OpenStack defaults if this option is not provided. |
| 46 | + Requires ansible >= 2.9. |
| 47 | +- `port_security_enabled`: Whether port security is enabled on the network |
| 48 | + or not. Network will use OpenStack defaults if this option is not utilised. |
| 49 | + Boolean, true to enable, false otherwise. Requires ansible >= 2.8. |
| 50 | +- `dns_domain`: The DNS domain value to set. Network will use Openstack |
| 51 | + defaults if this option is not provided. Requires ansible >= 2.9. |
| 52 | +- `subnets`: A list of subnets to create in this network. Each item should |
| 53 | + be a dict containing the following items: |
| 54 | + - `name`: Name of the neutron subnet. |
| 55 | + - `cidr`: CIDR representation of the neutron subnet's IP network. |
| 56 | + - `dns_nameservers`: A list of DNS nameservers for the subnet. |
| 57 | + - `extra_specs`: Optional Dictionary with extra key/value pairs |
| 58 | + passed to the API. Requires ansible >= 2.7. |
| 59 | + - `gateway_ip`: IP address of the neutron subnet's gateway. |
| 60 | + - `no_gateway_ip`: Optional boolean, whether to omit a gateway IP. If unset, |
| 61 | + this will be `true` if `gateway_ip` is specified, and `false` otherwise. |
| 62 | + - `enable_dhcp`: Whether to enable DHCP on the subnet. |
| 63 | + - `allocation_pool_start`: Start of the neutron subnet's IP allocation |
| 64 | + pool. |
| 65 | + - `allocation_pool_end`: End of the neutron subnet's IP allocation pool. |
| 66 | + - `host_routes`: A list of classless static routes to supply to hosts |
| 67 | + connected to this subnet. A list of dicts of `destination` |
| 68 | + (destination network in CIDR encoding) and `nexthop` |
| 69 | + (router IP on this subnet) must be supplied. |
| 70 | + - `ip_version`: Optional IP version for the subnet. |
| 71 | + - `ipv6_address_mode`: Optional IPv6 address mode for the subnet. |
| 72 | + - `ipv6_ra_mode`: Optional IPv6 router advertisement mode for the subnet. |
| 73 | + - `use_default_subnetpool`: Optional boolean, whether to use the default |
| 74 | + subnet pool for the IP version. |
| 75 | + - `project`: Optionally create this subnet for a project other than the |
| 76 | + authenticating project. |
| 77 | + - `state`: Optional state of the subnet, default is `present`. |
| 78 | + |
| 79 | +`os_networks_routers` is a list of routers to create. Each item should be a |
| 80 | +dict containing the following items: |
| 81 | + |
| 82 | +- `name`: Name of the neutron router. |
| 83 | +- `interfaces`: List of names of subnets to attach to the router |
| 84 | + internal interface. |
| 85 | +- `network`: Unique name or ID of the external gateway network. |
| 86 | +- `external_fixed_ips`: Optional list of IP address parameters for the |
| 87 | + external gateway network. Each is a dictionary with the subnet name or |
| 88 | + subnet ID and the IP address to assign on the subnet. |
| 89 | +- `project`: Optionally create this router for a project other than the |
| 90 | + authenticating project. |
| 91 | +- `state`: Optional state of the router, default is `present`. |
| 92 | + |
| 93 | + |
| 94 | +`os_networks_security_groups`: List of security groups to create. |
| 95 | +Each item should be a dict containing the following items: |
| 96 | +- `name`: Name of the security group. |
| 97 | +- `description`: Optional description of the security group. |
| 98 | +- `project`: Optional project in which to register the security group. |
| 99 | +- `state`: Optional state of the security group, default is `present`. |
| 100 | +- `rules`: Optional list of rules to add to the security group. Each item |
| 101 | + should be a dict containing the following items: |
| 102 | + - `direction`: Optional direction of the rule, default is `ingress`. |
| 103 | + - `ethertype`: Optional Ethertype of the rule, default is `IPv4` |
| 104 | + - `port_range_min`: Optional starting port. |
| 105 | + - `port_range_max`: Optional ending port. |
| 106 | + - `protocol`: Optional IP protocol of the rule. |
| 107 | + - `remote_group`: Optional name or ID of the security group to link. |
| 108 | + - `remote_ip_prefix`: Optional source IP address prefix in CIDR notation. |
| 109 | + - `state`: Optional state of the rule, default is `present`. |
| 110 | + |
| 111 | +`os_networks_rbac` is a list of role-based access control |
| 112 | +shares for named networks and projects. See the [Neutron RBAC admin |
| 113 | +guide](https://docs.openstack.org/neutron/latest/admin/config-rbac.html#sharing-a-network-with-specific-projects) |
| 114 | +for details. Each entry in the list is a dictionary containing the |
| 115 | +following items: |
| 116 | + |
| 117 | +- `network`: The name of the network to share. This network is normally |
| 118 | + owned by the `admin` project and not `shared` or `external`. |
| 119 | +- `access`: The mode of sharing with the target project(s). Valid options |
| 120 | + are `access_as_external` and `access_as_shared` |
| 121 | +- `projects`: A list of project names for sharing the named network |
| 122 | + in the designated way. |
| 123 | + |
| 124 | +*NOTE*: RBAC assignments cannot be modified after they are created. |
| 125 | + |
| 126 | +Dependencies |
| 127 | +------------ |
| 128 | + |
| 129 | +This role depends on the `stackhpc.openstack.os_openstacksdk` role. |
| 130 | + |
| 131 | +Example Playbook |
| 132 | +---------------- |
| 133 | + |
| 134 | +The following playbook registers a neutron network, subnet and router. |
| 135 | +A classless static route is defined to access another subnet through a |
| 136 | +different gateway. |
| 137 | + |
| 138 | + --- |
| 139 | + - name: Ensure networks, subnets and routers are registered |
| 140 | + hosts: localhost |
| 141 | + roles: |
| 142 | + - role: stackhpc.openstack.os_networks |
| 143 | + os_networks_venv: "~/os-networks-venv" |
| 144 | + os_networks_auth_type: "password" |
| 145 | + os_networks_auth: |
| 146 | + project_name: <keystone project> |
| 147 | + username: <keystone user> |
| 148 | + password: <keystone password> |
| 149 | + auth_url: <keystone auth URL> |
| 150 | + os_networks: |
| 151 | + - name: net1 |
| 152 | + provider_network_type: vlan |
| 153 | + provider_physical_network: physnet1 |
| 154 | + provider_segmentation_id: 1234 |
| 155 | + shared: true |
| 156 | + external: false |
| 157 | + subnets: |
| 158 | + - name: subnet1 |
| 159 | + cidr: 10.0.0.0/24 |
| 160 | + gateway_ip: 10.0.0.1 |
| 161 | + allocation_pool_start: 10.0.0.2 |
| 162 | + allocation_pool_end: 10.0.0.254 |
| 163 | + host_routes: |
| 164 | + - destination: 10.0.1.0/24 |
| 165 | + nexthop: 10.0.0.254 |
| 166 | + os_networks_routers: |
| 167 | + - name: router1 |
| 168 | + interfaces: |
| 169 | + - subnet1 |
| 170 | + network: net1 |
| 171 | + os_networks_security_groups: |
| 172 | + - name: secgroup1 |
| 173 | + rules: |
| 174 | + - protocol: icmp |
| 175 | + |
| 176 | +Author Information |
| 177 | +------------------ |
| 178 | + |
| 179 | +- Mark Goddard ( <[email protected]>) |
0 commit comments