Giter VIP home page Giter VIP logo

ansible-role-os-networks's Introduction

NOTE:

This repository is no longer maintained - role has been moved to Ansible collection now ➡️ https://github.com/stackhpc/ansible-collection-openstack

OpenStack Networks

This role can be used to register networks, subnets and routers in neutron using the os_network, os_subnet and os_router modules.

Requirements

The OpenStack neutron API should be accessible from the target host.

Role Variables

os_networks_venv is a path to a directory in which to create a virtualenv.

os_networks_auth_type is an authentication type compatible with the auth_type argument of os_* Ansible modules.

os_networks_auth is a dict containing authentication information compatible with the auth argument of os_* Ansible modules.

os_networks_cacert is an optional path to a CA certificate bundle.

os_networks_cloud is an optional name of a cloud in clouds.yaml.

os_networks_interface is the endpoint URL type to fetch from the service catalog. Maybe be one of public, admin, or internal.

os_networks is a list of networks to register. Each item should be a dict containing the following items:

  • name: Name of the neutron network.
  • provider_network_type: Provider type of the neutron network.
  • provider_physical_network: Provider physical network of the neutron network.
  • provider_segmentation_id: Provider segmentation ID of the neutron network.
  • shared: Whether the neutron network is shared.
  • external: Whether the neutron network is external.
  • project: Optionally create this network for a project other than the authenticating project.
  • state: Optional state of the network, default is present.
  • mtu: The maximum transmission unit (MTU) value to address fragmentation. Network will use OpenStack defaults if this option is not provided. Requires ansible >= 2.9.
  • port_security_enabled: Whether port security is enabled on the network or not. Network will use OpenStack defaults if this option is not utilised. Boolean, true to enable, false otherwise. Requires ansible >= 2.8.
  • dns_domain: The DNS domain value to set. Network will use Openstack defaults if this option is not provided. Requires ansible >= 2.9.
  • subnets: A list of subnets to create in this network. Each item should be a dict containing the following items:
    • name: Name of the neutron subnet.
    • cidr: CIDR representation of the neutron subnet's IP network.
    • dns_nameservers: A list of DNS nameservers for the subnet.
    • extra_specs: Optional Dictionary with extra key/value pairs passed to the API. Requires ansible >= 2.7.
    • gateway_ip: IP address of the neutron subnet's gateway.
    • no_gateway_ip: Optional boolean, whether to omit a gateway IP. If unset, this will be true if gateway_ip is specified, and false otherwise.
    • enable_dhcp: Whether to enable DHCP on the subnet.
    • allocation_pool_start: Start of the neutron subnet's IP allocation pool.
    • allocation_pool_end: End of the neutron subnet's IP allocation pool.
    • host_routes: A list of classless static routes to supply to hosts connected to this subnet. A list of dicts of destination (destination network in CIDR encoding) and nexthop (router IP on this subnet) must be supplied.
    • ip_version: Optional IP version for the subnet.
    • ipv6_address_mode: Optional IPv6 address mode for the subnet.
    • ipv6_ra_mode: Optional IPv6 router advertisement mode for the subnet.
    • use_default_subnetpool: Optional boolean, whether to use the default subnet pool for the IP version.
    • project: Optionally create this subnet for a project other than the authenticating project.
    • state: Optional state of the subnet, default is present.

os_networks_routers is a list of routers to create. Each item should be a dict containing the following items:

  • name: Name of the neutron router.
  • interfaces: List of names of subnets to attach to the router internal interface.
  • network: Unique name or ID of the external gateway network.
  • external_fixed_ips: Optional list of IP address parameters for the external gateway network. Each is a dictionary with the subnet name or subnet ID and the IP address to assign on the subnet.
  • project: Optionally create this router for a project other than the authenticating project.
  • state: Optional state of the router, default is present.

os_networks_security_groups: List of security groups to create. Each item should be a dict containing the following items:

  • name: Name of the security group.
  • description: Optional description of the security group.
  • project: Optional project in which to register the security group.
  • state: Optional state of the security group, default is present.
  • rules: Optional list of rules to add to the security group. Each item should be a dict containing the following items:
    • direction: Optional direction of the rule, default is ingress.
    • ethertype: Optional Ethertype of the rule, default is IPv4
    • port_range_min: Optional starting port.
    • port_range_max: Optional ending port.
    • protocol: Optional IP protocol of the rule.
    • remote_group: Optional name or ID of the security group to link.
    • remote_ip_prefix: Optional source IP address prefix in CIDR notation.
    • state: Optional state of the rule, default is present.

os_networks_rbac is a list of role-based access control shares for named networks and projects. See the Neutron RBAC admin guide for details. Each entry in the list is a dictionary containing the following items:

  • network: The name of the network to share. This network is normally owned by the admin project and not shared or external.
  • access: The mode of sharing with the target project(s). Valid options are access_as_external and access_as_shared
  • projects: A list of project names for sharing the named network in the designated way.

NOTE: RBAC assignments cannot be modified after they are created.

Dependencies

This role depends on the stackhpc.os_openstacksdk role.

Example Playbook

The following playbook registers a neutron network, subnet and router. A classless static route is defined to access another subnet through a different gateway.

---
- name: Ensure networks, subnets and routers are registered
  hosts: neutron-api
  roles:
    - role: os-networks
      os_networks_venv: "~/os-networks-venv"
      os_networks_auth_type: "password"
      os_networks_auth:
        project_name: <keystone project>
        username: <keystone user>
        password: <keystone password>
        auth_url: <keystone auth URL>
      os_networks:
        - name: net1
          provider_network_type: vlan
          provider_physical_network: physnet1
          provider_segmentation_id: 1234
          shared: true
          external: false
          subnets:
            - name: subnet1
              cidr: 10.0.0.0/24
              gateway_ip: 10.0.0.1
              allocation_pool_start: 10.0.0.2
              allocation_pool_end: 10.0.0.254
              host_routes:
                - destination: 10.0.1.0/24
                  nexthop: 10.0.0.254
      os_networks_routers:
        - name: router1
          interfaces:
            - subnet1
          network: net1
      os_networks_security_groups:
        - name: secgroup1
          rules:
            - protocol: icmp

Author Information

ansible-role-os-networks's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-role-os-networks's Issues

Issues creating a new network for a non-admin project

To create an overlay network for the use of a project, the project parameter must be passed to os_network.

However, when this is done, shade claims the project cannot be found.

When invoking the shade function get_project from the python interpreter, using the same parameters as the ansible invocation, get_project returns nothing unless environment variable OS_IDENTITY_API_VERSION=3 is set.

Enable support for IPv6 Subnets

Currently there is no support for IPv6 subnets.
Specifically we need to be able to set parameters:
ip_version (default is 4)
ipv6_address_mode
ipv6_ra_mode

Security groups created with default rules incorporated

A security group is created with two default rules in place:

+--------------------------------------+-------------+-----------+-----------+------------+-----------------------+
| ID                                   | IP Protocol | Ethertype | IP Range  | Port Range | Remote Security Group |
+--------------------------------------+-------------+-----------+-----------+------------+-----------------------+
| 32a56a43-798a-44c8-bb3e-ed424405941a | None        | IPv6      | ::/0      |            | None                  |
| 989d72fb-c146-4657-a6cc-08cbf9a0b770 | None        | IPv4      | 0.0.0.0/0 |            | None                  |
+--------------------------------------+-------------+-----------+-----------+------------+-----------------------+

We don't necessarily want these rules to be there. When a security group is created, should it be stripped of default entries if we are defining our own?

Broken with openstacksdk 0.53: Unrecognized attribute(s) 'remote_address_group_id'

Latest openstacksdk (version 0.53) passes remote_address_group_id to security group creation requests, which breaks on any current OpenStack release. Only master code (soon to be Wallaby) doesn't break.

failed: [localhost] (item=[{'name': 'octavia-sg', 'project': 'service'}, {'protocol': 'tcp', 'port_range_min': 22, 'port_range_max': 22, 'remote_ip_prefix': '0.0.0.0/0'}]) => {"ansible_loop_var": "item", "changed": false, "item": [{"name": "octavia-sg", "project": "service"}, {"port_range_max": 22, "port_range_min": 22, "protocol": "tcp", "remote_ip_prefix": "0.0.0.0/0"}], "msg": "BadRequestException: 400: Client Error for url: https://example.com:9696/v2.0/security-group-rules, Unrecognized attribute(s) 'remote_address_group_id'"}

Issue with enable_dhcp:false not being honoured in created openstack network

When using hpcDIRECT-config to create networks, which uses this role, the networks created do not disable DHCP when requested in the config.

e.g.:
customer_subnet_infiniband:
name: "{{ customer_network_infiniband_name }}"
project: "{{ customer_project_name }}"
cidr: "192.168.94.0/24"
allocation_pool_start: "192.168.94.1"
allocation_pool_end: "192.168.94.254"
enable_dhcp: no

Also tried:
enable_dhcp: false

Idempotency of this role?

I've been using this role embedded within bmrc-config and one issue I have found is that it appears not to be idempotent with regard to handling networks it has already created.

For example, for the task Ensure subnet is registered with neutron I see this sort of error:

Current gateway ip 10.1.0.1 already in use by <port UUID>. Unable to update.

This may be strictly a bmrc-config problem, but thought I would report it here in case it applied more generally.

Broken CI/CD

Since June 15th, 2021, the building on travis-ci.org is ceased. Please use travis-ci.com from now on.

Automatic tests and Galaxy imports no longer happen.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.