github.com/openshift/installer@v1.4.17/upi/openstack/network.yaml (about)

     1  # Required Python packages:
     2  #
     3  # ansible
     4  # openstackclient
     5  # openstacksdk
     6  # netaddr
     7  
     8  - ansible.builtin.import_playbook: common.yaml
     9  
    10  - hosts: all
    11    gather_facts: no
    12  
    13    tasks:
    14    - name: 'Create the cluster network'
    15      openstack.cloud.network:
    16        name: "{{ os_network }}"
    17  
    18    - name: 'Create the cluster IPv4 subnet'
    19      openstack.cloud.subnet:
    20        name: "{{ os_subnet }}"
    21        network_name: "{{ os_network }}"
    22        cidr: "{{ os_subnet_range }}"
    23        allocation_pool_start: "{{ os_subnet_range | ansible.utils.next_nth_usable(10) }}"
    24        allocation_pool_end: "{{ os_subnet_range | ansible.utils.ipaddr('last_usable') }}"
    25        dns_nameservers: "{{ os_external_dns }}"
    26  
    27    - name: 'Create the cluster IPv6 subnet'
    28      openstack.cloud.subnet:
    29        name: "{{ os_subnet6 }}"
    30        network_name: "{{ os_network }}"
    31        cidr: "{{ os_subnet6_range }}"
    32        ip_version: 6
    33        ipv6_address_mode: "{{ os_subnet6_address_mode }}"
    34        ipv6_ra_mode: "{{ os_subnet6_router_advertisements_mode }}"
    35      when: os_subnet6_range is defined
    36  
    37    - name: 'Create external router for IPv4'
    38      openstack.cloud.router:
    39        name: "{{ os_router }}"
    40        network: "{{ os_external_network }}"
    41        interfaces: "{{ os_subnet }}"
    42      when:
    43      - os_external_network is defined
    44      - os_external_network|length>0
    45      - os_subnet6_range is not defined
    46  
    47    - name: 'Create external router for dualstack'
    48      openstack.cloud.router:
    49        name: "{{ os_router }}"
    50        network: "{{ os_external_network }}"
    51        interfaces:
    52        - "{{ os_subnet }}"
    53        - "{{ os_subnet6 }}"
    54      when:
    55      - os_external_network is defined
    56      - os_external_network|length>0
    57      - os_subnet6_range is defined
    58  
    59    - name: 'Create the API port'
    60      openstack.cloud.port:
    61        name: "{{ os_port_api }}"
    62        network: "{{ os_network }}"
    63        fixed_ips:
    64        - subnet: "{{ os_subnet }}"
    65          ip_address: "{{ os_apiVIP }}"
    66      register: _api_ports
    67      when: os_subnet6_range is not defined
    68  
    69    - set_fact:
    70        api_ports: "{{ _api_ports }}"
    71      when: _api_ports.changed
    72  
    73    - name: 'Create the dualstack API port'
    74      openstack.cloud.port:
    75        name: "{{ os_port_api }}"
    76        network: "{{ os_network }}"
    77      register: _api_ports
    78      when: os_subnet6_range is defined
    79  
    80    - set_fact:
    81        api_ports: "{{ _api_ports }}"
    82      when: _api_ports.changed
    83  
    84    - name: 'Create the Ingress port'
    85      openstack.cloud.port:
    86        name: "{{ os_port_ingress }}"
    87        network: "{{ os_network }}"
    88        fixed_ips:
    89        - subnet: "{{ os_subnet }}"
    90          ip_address: "{{ os_ingressVIP }}"
    91      register: _ingress_ports
    92      when: os_subnet6_range is not defined
    93  
    94    - set_fact:
    95        ingress_ports: "{{ _ingress_ports }}"
    96      when: _ingress_ports.changed
    97  
    98    - name: 'Create the dualstack Ingress port'
    99      openstack.cloud.port:
   100        name: "{{ os_port_ingress }}"
   101        network: "{{ os_network }}"
   102      register: _ingress_ports
   103      when: os_subnet6_range is defined
   104  
   105    - set_fact:
   106        ingress_ports: "{{ _ingress_ports }}"
   107      when: _ingress_ports.changed
   108  
   109    - name: 'Populate inventory with API addresses'
   110      shell: |
   111        python -c 'import yaml
   112        path = "inventory.yaml"
   113        ipv4 = "{{ item.ip_address|ansible.utils.ipv4 }}"
   114        ipv6 = "{{ item.ip_address|ansible.utils.ipv6 }}"
   115        if ipv4 != "False":
   116          key = "os_apiVIP"
   117          ip = ipv4
   118        else:
   119          key = "os_apiVIP6"
   120          ip = ipv6
   121        data = yaml.safe_load(open(path))
   122        data["all"]["hosts"]["localhost"][key] = ip
   123        open(path, "w").write(yaml.dump(data, default_flow_style=False))'
   124      when:
   125      - api_ports.port is defined
   126      loop: "{{ api_ports.port.fixed_ips }}"
   127  
   128    - name: 'Populate inventory with Ingress addresses'
   129      shell: |
   130        python -c 'import yaml
   131        path = "inventory.yaml"
   132        ipv4 = "{{ item.ip_address|ansible.utils.ipv4 }}"
   133        ipv6 = "{{ item.ip_address|ansible.utils.ipv6 }}"
   134        if ipv4 != "False":
   135          key = "os_ingressVIP"
   136          ip = ipv4
   137        else:
   138          key = "os_ingressVIP6"
   139          ip = ipv6
   140        data = yaml.safe_load(open(path))
   141        data["all"]["hosts"]["localhost"][key] = ip
   142        open(path, "w").write(yaml.dump(data, default_flow_style=False))'
   143      when:
   144      - ingress_ports.port is defined
   145      loop: "{{ ingress_ports.port.fixed_ips }}"