diff options
Diffstat (limited to 'xci/playbooks/roles/bootstrap-host')
8 files changed, 159 insertions, 9 deletions
diff --git a/xci/playbooks/roles/bootstrap-host/tasks/network_debian.yml b/xci/playbooks/roles/bootstrap-host/tasks/network_debian.yml index 3cac1e22..176c7eb1 100644 --- a/xci/playbooks/roles/bootstrap-host/tasks/network_debian.yml +++ b/xci/playbooks/roles/bootstrap-host/tasks/network_debian.yml @@ -45,14 +45,54 @@ - { name: "{{ ansible_local.xci.network.xci_interface }}.10", vlan_id: 10 } - { name: "{{ ansible_local.xci.network.xci_interface }}.30", vlan_id: 30 } - { name: "{{ ansible_local.xci.network.xci_interface }}.20", vlan_id: 20 } - - { name: "br-mgmt", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.10", network: "{{ host_info[inventory_hostname].admin }}" } + - { name: "br-mgmt", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.10", network: "{{ host_info[inventory_hostname].mgmt }}" } - { name: "br-vxlan", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.30", network: "{{ host_info[inventory_hostname].private }}" } - { name: "br-vlan", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}", network: "{{ host_info[inventory_hostname].public }}" } - { name: "br-storage", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.20", network: "{{ host_info[inventory_hostname].storage }}" } loop_control: label: "{{ item.name }}" + when: baremetal | bool != true + + +- name: "Configure baremetal networking for blade: {{ inventory_hostname }}" + template: + src: "{{ installer_type }}/debian.interface.j2" + dest: "/etc/network/interfaces.d/{{ item.name }}.cfg" + with_items: + - { name: "{{ admin_interface }}", network: "{{ host_info[inventory_hostname].admin }}" } + - { name: "{{ mgmt_interface }}", vlan_id: "{{ (mgmt_vlan == 'native') | ternary(omit, mgmt_vlan) }}" } + - { name: "{{ storage_interface }}", vlan_id: "{{ (storage_vlan == 'native') | ternary(omit, storage_vlan) }}" } + - { name: "{{ public_interface }}", vlan_id: "{{ (public_vlan == 'native') | ternary(omit, public_vlan) }}" } + - { name: "{{ private_interface }}", vlan_id: "{{ (private_vlan == 'native') | ternary(omit, private_vlan) }}" } + - { name: "br-mgmt", bridge_ports: "{{ mgmt_interface }}", network: "{{ host_info[inventory_hostname].mgmt }}" } + - { name: "br-vxlan", bridge_ports: "{{ private_interface }}", network: "{{ host_info[inventory_hostname].private }}" } + - { name: "br-vlan", bridge_ports: "{{ public_interface }}", network: "{{ host_info[inventory_hostname].public }}" } + - { name: "br-storage", bridge_ports: "{{ storage_interface }}", network: "{{ host_info[inventory_hostname].storage }}" } + loop_control: + label: "{{ item.name }}" + when: + - baremetal | bool == true + - "'opnfv' not in inventory_hostname" + +- name: "Configure baremetal networking for VM: {{ inventory_hostname }}" + template: + src: "{{ installer_type }}/debian.interface.j2" + dest: "/etc/network/interfaces.d/{{ item.name }}.cfg" + with_items: + - { name: "{{ mgmt_interface }}", vlan_id: "{{ (mgmt_vlan == 'native') | ternary(omit, mgmt_vlan) }}" } + - { name: "{{ public_interface }}", vlan_id: "{{ (public_vlan == 'native') | ternary(omit, public_vlan) }}" } + - { name: "br-mgmt", bridge_ports: "{{ mgmt_interface }}", network: "{{ host_info[inventory_hostname].mgmt }}" } + - { name: "br-vlan", bridge_ports: "{{ public_interface }}", network: "{{ host_info[inventory_hostname].public }}" } + loop_control: + label: "{{ item.name }}" + when: + - baremetal | bool == true + - "'opnfv' in inventory_hostname" - name: restart network service - shell: "/sbin/ifconfig {{ ansible_local.xci.network.xci_interface }} 0 && /sbin/ifdown -a && /sbin/ifup -a" + shell: "/sbin/ip addr flush dev {{ item }}; /sbin/ifdown -a; /sbin/ifup -a" async: 15 poll: 0 + with_items: + - "{{ public_interface }}" + - "{{ mgmt_interface }}" diff --git a/xci/playbooks/roles/bootstrap-host/tasks/network_redhat.yml b/xci/playbooks/roles/bootstrap-host/tasks/network_redhat.yml index c360f15d..288fdf65 100644 --- a/xci/playbooks/roles/bootstrap-host/tasks/network_redhat.yml +++ b/xci/playbooks/roles/bootstrap-host/tasks/network_redhat.yml @@ -18,7 +18,7 @@ - { name: "{{ ansible_local.xci.network.xci_interface }}.20", bridge: "br-storage", vlan_id: 20 } - { name: "{{ ansible_local.xci.network.xci_interface }}.30", bridge: "br-vxlan" , vlan_id: 30 } - { name: "br-vlan" , network: "{{ host_info[inventory_hostname].public }}" } - - { name: "br-mgmt" , network: "{{ host_info[inventory_hostname].admin }}" } + - { name: "br-mgmt" , network: "{{ host_info[inventory_hostname].mgmt }}" } - { name: "br-storage", network: "{{ host_info[inventory_hostname].storage }}" } - { name: "br-vxlan" , network: "{{ host_info[inventory_hostname].private }}" } loop_control: diff --git a/xci/playbooks/roles/bootstrap-host/tasks/network_suse.yml b/xci/playbooks/roles/bootstrap-host/tasks/network_suse.yml index e2b5aa4a..a8f1bf59 100644 --- a/xci/playbooks/roles/bootstrap-host/tasks/network_suse.yml +++ b/xci/playbooks/roles/bootstrap-host/tasks/network_suse.yml @@ -17,12 +17,52 @@ - { name: "{{ ansible_local.xci.network.xci_interface }}.10", vlan_id: 10 } - { name: "{{ ansible_local.xci.network.xci_interface }}.30", vlan_id: 30 } - { name: "{{ ansible_local.xci.network.xci_interface }}.20", vlan_id: 20 } - - { name: "br-mgmt", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.10", network: "{{ host_info[inventory_hostname].admin }}" } + - { name: "br-mgmt", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.10", network: "{{ host_info[inventory_hostname].mgmt }}" } - { name: "br-vxlan", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.30", network: "{{ host_info[inventory_hostname].private }}" } - { name: "br-vlan", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}", network: "{{ host_info[inventory_hostname].public }}" } - { name: "br-storage", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.20", network: "{{ host_info[inventory_hostname].storage }}" } loop_control: label: "{{ item.name }}" + when: baremetal | bool != true + +- name: "Configure baremetal networking for blade: {{ inventory_hostname }}" + template: + src: "{{ installer_type }}/{{ ansible_os_family | lower }}.interface.j2" + dest: "/etc/sysconfig/network/ifcfg-{{ item.name }}" + with_items: + - { name: "{{ admin_interface }}", network: "{{ host_info[inventory_hostname].admin }}" } + - { name: "{{ mgmt_interface }}", vlan_id: "{{ (mgmt_vlan == 'native') | ternary(omit, mgmt_vlan) }}" } + - { name: "{{ storage_interface }}", vlan_id: "{{ (storage_vlan == 'native') | ternary(omit, storage_vlan) }}" } + - { name: "{{ public_interface }}", vlan_id: "{{ (public_vlan == 'native') | ternary(omit, public_vlan) }}" } + - { name: "{{ private_interface }}", vlan_id: "{{ (private_vlan == 'native') | ternary(omit, private_vlan) }}" } + - { name: "br-mgmt", bridge_ports: "{{ mgmt_interface }}", network: "{{ host_info[inventory_hostname].mgmt }}" } + - { name: "br-vxlan", bridge_ports: "{{ private_interface }}", network: "{{ host_info[inventory_hostname].private }}" } + - { name: "br-vlan", bridge_ports: "{{ public_interface }}", network: "{{ host_info[inventory_hostname].public }}" } + - { name: "br-storage", bridge_ports: "{{ storage_interface }}", network: "{{ host_info[inventory_hostname].storage }}" } + loop_control: + label: "{{ item.name }}" + when: + - baremetal | bool == true + - "'opnfv' not in inventory_hostname" + +- name: "Configure baremetal networking for VM: {{ inventory_hostname }}" + template: + src: "{{ installer_type }}/{{ ansible_os_family | lower }}.interface.j2" + dest: "/etc/sysconfig/network/ifcfg-{{ item.name }}" + with_items: + - { name: "{{ mgmt_interface }}", vlan_id: "{{ (mgmt_vlan == 'native') | ternary(omit, mgmt_vlan) }}" } + - { name: "{{ mgmt_interface }}.30", vlan_id: 30 } + - { name: "{{ mgmt_interface }}.20", vlan_id: 20 } + - { name: "{{ public_interface }}", vlan_id: "{{ (public_vlan == 'native') | ternary(omit, public_vlan) }}" } + - { name: "br-mgmt", bridge_ports: "{{ mgmt_interface }}", network: "{{ host_info[inventory_hostname].mgmt }}" } + - { name: "br-vlan", bridge_ports: "{{ public_interface }}", network: "{{ host_info[inventory_hostname].public }}" } + - { name: "br-vxlan", bridge_ports: "{{ mgmt_interface }}.30", network: "{{ host_info[inventory_hostname].private }}" } + - { name: "br-storage", bridge_ports: "{{ mgmt_interface }}.20", network: "{{ host_info[inventory_hostname].storage }}" } + loop_control: + label: "{{ item.name }}" + when: + - baremetal | bool == true + - "'opnfv' in inventory_hostname" - name: Add postup/postdown scripts on SUSE copy: @@ -33,7 +73,7 @@ - name: Configure static DNS on SUSE lineinfile: regexp: '^NETCONFIG_DNS_STATIC_SERVERS=.*' - line: "NETCONFIG_DNS_STATIC_SERVERS={{ host_info[inventory_hostname]['public']['dns'] }}" + line: "NETCONFIG_DNS_STATIC_SERVERS=\"{{ host_info[inventory_hostname]['public']['dns'] | join(' ') }}\"" path: "/etc/sysconfig/network/config" state: present when: host_info[inventory_hostname]['public']['dns'] is defined diff --git a/xci/playbooks/roles/bootstrap-host/templates/osa/debian.interface.j2 b/xci/playbooks/roles/bootstrap-host/templates/osa/debian.interface.j2 index f9e4d8df..2f976002 100644 --- a/xci/playbooks/roles/bootstrap-host/templates/osa/debian.interface.j2 +++ b/xci/playbooks/roles/bootstrap-host/templates/osa/debian.interface.j2 @@ -33,7 +33,7 @@ iface {{ item.name }} inet static gateway {{ item.network.gateway | ipaddr('address') }} {% endif %} {% if item.network is defined and item.network.dns is defined %} - dns-nameservers {{ item.network.dns }} + dns-nameservers {{ item.network.dns | join(' ') }} {% endif %} {% endif %} diff --git a/xci/playbooks/roles/bootstrap-host/templates/osa/redhat.interface.j2 b/xci/playbooks/roles/bootstrap-host/templates/osa/redhat.interface.j2 index 3a51eb86..525686d9 100644 --- a/xci/playbooks/roles/bootstrap-host/templates/osa/redhat.interface.j2 +++ b/xci/playbooks/roles/bootstrap-host/templates/osa/redhat.interface.j2 @@ -21,6 +21,6 @@ IPADDR={{ item.network.address }} GATEWAY="{{ host_info[inventory_hostname]['public']['gateway'] | ipaddr('address') }}" {% endif %} {% if item.network is defined and item.network.dns is defined %} -DNS="{{ host_info[inventory_hostname]['public']['dns'] }}" +DNS="{{ host_info[inventory_hostname]['public']['dns'] | join(' ') }}" {% endif %} {% endif %} diff --git a/xci/playbooks/roles/bootstrap-host/templates/osa/suse.interface.j2 b/xci/playbooks/roles/bootstrap-host/templates/osa/suse.interface.j2 index 70811a09..7c2929d6 100644 --- a/xci/playbooks/roles/bootstrap-host/templates/osa/suse.interface.j2 +++ b/xci/playbooks/roles/bootstrap-host/templates/osa/suse.interface.j2 @@ -1,8 +1,7 @@ STARTMODE='auto' BOOTPROTO='static' {% if item.vlan_id is defined %} -ETHERDEVICE={{ ansible_default_ipv4.interface }} -VLAN_ID={{ item.vlan_id }} +ETHERDEVICE={{ item.name.split('.')[0] }} {% endif %} {% if item.bridge_ports is defined %} BRIDGE='yes' diff --git a/xci/playbooks/roles/bootstrap-host/templates/osh b/xci/playbooks/roles/bootstrap-host/templates/osh new file mode 120000 index 00000000..f820fd11 --- /dev/null +++ b/xci/playbooks/roles/bootstrap-host/templates/osh @@ -0,0 +1 @@ +osa
\ No newline at end of file diff --git a/xci/playbooks/roles/bootstrap-host/vars/main.yml b/xci/playbooks/roles/bootstrap-host/vars/main.yml new file mode 100644 index 00000000..1730ad57 --- /dev/null +++ b/xci/playbooks/roles/bootstrap-host/vars/main.yml @@ -0,0 +1,70 @@ +--- +# admin network information +admin_mac: "{{ host_info[inventory_hostname].admin.mac_address }}" +admin_interface: >- + {% for x in (ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) | selectattr('macaddress','defined')) -%} + {%- if x.macaddress == admin_mac -%} + {%- if admin_vlan == 'native' -%} + {{ x.device }} + {%- else -%} + {{ x.device }}.{{ admin_vlan }} + {%- endif -%} + {%- endif -%} + {%- endfor -%} +admin_vlan: "{{ host_info[inventory_hostname].admin.vlan }}" + +# mgmt network information +mgmt_mac: "{{ host_info[inventory_hostname].mgmt.mac_address }}" +mgmt_interface: >- + {% for x in (ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) | selectattr('macaddress','defined')) -%} + {%- if x.macaddress == mgmt_mac -%} + {%- if mgmt_vlan == 'native' -%} + {{ x.device }} + {%- else -%} + {{ x.device }}.{{ mgmt_vlan }} + {%- endif -%} + {%- endif -%} + {%- endfor -%} +mgmt_vlan: "{{ host_info[inventory_hostname].mgmt.vlan }}" + +# storage network information +storage_mac: "{{ host_info[inventory_hostname].storage.mac_address }}" +storage_interface: >- + {%- for x in (ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) | selectattr('macaddress','defined')) -%} + {%- if x.macaddress == storage_mac -%} + {%- if storage_vlan == 'native' -%} + {{ x.device }} + {%- else -%} + {{ x.device }}.{{ storage_vlan }} + {%- endif -%} + {%- endif -%} + {%- endfor -%} +storage_vlan: "{{ host_info[inventory_hostname].storage.vlan }}" + +# public vlan netwrk information +public_mac: "{{ host_info[inventory_hostname].public.mac_address }}" +public_interface: >- + {%- for x in (ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) | selectattr('macaddress','defined')) -%} + {%- if x.macaddress == public_mac -%} + {%- if public_vlan == 'native' -%} + {{ x.device }} + {%- else -%} + {{ x.device }}.{{ public_vlan }} + {%- endif -%} + {%- endif -%} + {%- endfor -%} +public_vlan: "{{ host_info[inventory_hostname].public.vlan }}" + +# private vxlan network information +private_mac: "{{ host_info[inventory_hostname].private.mac_address }}" +private_interface: >- + {%- for x in (ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) | selectattr('macaddress','defined')) -%} + {%- if x.macaddress == private_mac -%} + {%- if private_vlan == 'native' -%} + {{ x.device }} + {%- else -%} + {{x.device}}.{{ private_vlan }} + {%- endif -%} + {%- endif -%} + {%- endfor -%} +private_vlan: "{{ host_info[inventory_hostname].private.vlan }}" |