diff options
author | Yifei Xue <xueyifei@huawei.com> | 2017-12-11 16:08:16 +0800 |
---|---|---|
committer | Yifei Xue <xueyifei@huawei.com> | 2017-12-12 17:49:13 +0800 |
commit | d30fc513bbda9fb2ab8421ed795b89c25bc08f7d (patch) | |
tree | d756617467b00fc7bdfedd954022b8b28c3d2cfa /deploy/adapters/ansible | |
parent | 5fbadc0b9b5d8726050906d0923abfe7ea5ce1c0 (diff) |
Bug fix for CentOS BM deployment
JIRA: -
In order to configure network for OSA deployment,
it's needed to install some packages, such as
bridge-utils, iputils, etc. So we configure
external network before using yum to install
packages.
Change-Id: I87864d6bdae79184aa82223f77b6ced1d0e9cf26
Signed-off-by: Yifei Xue <xueyifei@huawei.com>
Diffstat (limited to 'deploy/adapters/ansible')
17 files changed, 185 insertions, 46 deletions
diff --git a/deploy/adapters/ansible/roles/config-compute/tasks/RedHat.yml b/deploy/adapters/ansible/roles/config-compute/tasks/RedHat.yml index 3ec1659f..ff91393d 100644 --- a/deploy/adapters/ansible/roles/config-compute/tasks/RedHat.yml +++ b/deploy/adapters/ansible/roles/config-compute/tasks/RedHat.yml @@ -14,20 +14,19 @@ shell: "echo 'nfs 2049/tcp' >> /etc/services; \ echo 'nfs 2049/udp' >> /etc/services" -# yamllint disable rule:line-length - name: generate ifcfg-if.tenant template: src: ifcfg-if.tenant - dest: /etc/sysconfig/network-scripts/ifcfg-{{compu_sys_mappings["tenant"]["interface"]}}.{{compu_sys_mappings["tenant"]["vlan_tag"]}} + dest: /etc/sysconfig/network-scripts/ifcfg-{{ intf_tenant }} - name: generate ifcfg-if.storage template: src: ifcfg-if.storage - dest: /etc/sysconfig/network-scripts/ifcfg-{{compu_sys_mappings["storage"]["interface"]}}.{{compu_sys_mappings["storage"]["vlan_tag"]}} + dest: /etc/sysconfig/network-scripts/ifcfg-{{ intf_storage }} - name: add br-external to interface script lineinfile: - dest: /etc/sysconfig/network-scripts/ifcfg-{{compu_sys_mappings["external"]["interface"]}} + dest: /etc/sysconfig/network-scripts/ifcfg-{{ intf_external }} line: "BRIDGE=br-external" - name: remove eth0 ip addresss @@ -49,14 +48,13 @@ - name: add br-vlan to interface script lineinfile: - dest: /etc/sysconfig/network-scripts/ifcfg-{{compu_sys_mappings["storage"]["interface"]}}.{{compu_sys_mappings["storage"]["vlan_tag"]}} + dest: /etc/sysconfig/network-scripts/ifcfg-{{ intf_storage }} line: "BRIDGE=br-storage" - name: add br-tenant to interface script lineinfile: - dest: /etc/sysconfig/network-scripts/ifcfg-{{compu_sys_mappings["tenant"]["interface"]}}.{{compu_sys_mappings["tenant"]["vlan_tag"]}} + dest: /etc/sysconfig/network-scripts/ifcfg-{{ intf_tenant }} line: "BRIDGE=br-tenant" -# yamllint enable rule:line-length - name: generate ifcfg-br-mgmt script template: diff --git a/deploy/adapters/ansible/roles/config-compute/templates/ifcfg-br-mgmt b/deploy/adapters/ansible/roles/config-compute/templates/ifcfg-br-mgmt index 2e958cc7..184f752b 100644 --- a/deploy/adapters/ansible/roles/config-compute/templates/ifcfg-br-mgmt +++ b/deploy/adapters/ansible/roles/config-compute/templates/ifcfg-br-mgmt @@ -5,3 +5,4 @@ PREFIX=24 BOOTPROTO=none ONBOOT=yes DELAY=0 +DEFROUTE="no" diff --git a/deploy/adapters/ansible/roles/config-compute/templates/ifcfg-if.storage b/deploy/adapters/ansible/roles/config-compute/templates/ifcfg-if.storage index 2e409205..eecc7a42 100644 --- a/deploy/adapters/ansible/roles/config-compute/templates/ifcfg-if.storage +++ b/deploy/adapters/ansible/roles/config-compute/templates/ifcfg-if.storage @@ -1,4 +1,9 @@ -DEVICE={{compu_sys_mappings["storage"]["interface"]}}.{{compu_sys_mappings["storage"]["vlan_tag"]}} +DEVICE={{ intf_storage }} BOOTPROTO=none ONBOOT=yes -VLAN=yes +{% if compu_sys_mappings["storage"]["vlan_tag"] | int %} +{% set intf_vlan = "yes" %} +{% else %} +{% set intf_vlan = "no" %} +{% endif %} +VLAN={{ intf_vlan }} diff --git a/deploy/adapters/ansible/roles/config-compute/templates/ifcfg-if.tenant b/deploy/adapters/ansible/roles/config-compute/templates/ifcfg-if.tenant index 2a114f7c..b36fa105 100644 --- a/deploy/adapters/ansible/roles/config-compute/templates/ifcfg-if.tenant +++ b/deploy/adapters/ansible/roles/config-compute/templates/ifcfg-if.tenant @@ -1,4 +1,9 @@ -DEVICE={{compu_sys_mappings["tenant"]["interface"]}}.{{compu_sys_mappings["tenant"]["vlan_tag"]}} +DEVICE={{ intf_tenant }} BOOTPROTO=none ONBOOT=yes -VLAN=yes +{% if compu_sys_mappings["tenant"]["vlan_tag"] | int %} +{% set intf_vlan = "yes" %} +{% else %} +{% set intf_vlan = "no" %} +{% endif %} +VLAN={{ intf_vlan }} diff --git a/deploy/adapters/ansible/roles/config-compute/vars/main.yml b/deploy/adapters/ansible/roles/config-compute/vars/main.yml index 783ea0d0..b157f910 100644 --- a/deploy/adapters/ansible/roles/config-compute/vars/main.yml +++ b/deploy/adapters/ansible/roles/config-compute/vars/main.yml @@ -8,3 +8,24 @@ # ############################################################################# --- LOCAL_REPOSITORY_IP: "192.168.137.222" + +intf_external: |- + {%- set intf_external = compu_sys_mappings["external"]["interface"] %} + {%- if compu_sys_mappings["external"]["vlan_tag"] | int %} + {%- set intf_external = intf_external + '.' + compu_sys_mappings["external"]["vlan_tag"]|string %} + {%- endif %} + {{- intf_external }} + +intf_tenant: |- + {%- set intf_tenant = compu_sys_mappings["tenant"]["interface"] %} + {%- if compu_sys_mappings["tenant"]["vlan_tag"] | int %} + {%- set intf_tenant = intf_tenant + '.' + compu_sys_mappings["tenant"]["vlan_tag"]|string %} + {%- endif %} + {{- intf_tenant }} + +intf_storage: |- + {%- set intf_storage = compu_sys_mappings["storage"]["interface"] %} + {%- if compu_sys_mappings["storage"]["vlan_tag"] | int %} + {%- set intf_storage = intf_storage + '.' + compu_sys_mappings["storage"]["vlan_tag"]|string %} + {%- endif %} + {{- intf_storage }} diff --git a/deploy/adapters/ansible/roles/config-controller/tasks/RedHat.yml b/deploy/adapters/ansible/roles/config-controller/tasks/RedHat.yml index cc14347a..58bc2bf7 100644 --- a/deploy/adapters/ansible/roles/config-controller/tasks/RedHat.yml +++ b/deploy/adapters/ansible/roles/config-controller/tasks/RedHat.yml @@ -7,32 +7,30 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## --- -# yamllint disable rule:line-length - name: generate tenant vlan ifcfg-if script template: src: ifcfg-if.tenant - dest: /etc/sysconfig/network-scripts/ifcfg-{{contr_sys_mappings["tenant"]["interface"]}}.{{contr_sys_mappings["tenant"]["vlan_tag"]}} + dest: /etc/sysconfig/network-scripts/ifcfg-{{ intf_tenant }} - name: generate storage vlan ifcfg-if script template: src: ifcfg-if.storage - dest: /etc/sysconfig/network-scripts/ifcfg-{{contr_sys_mappings["storage"]["interface"]}}.{{contr_sys_mappings["storage"]["vlan_tag"]}} + dest: /etc/sysconfig/network-scripts/ifcfg-{{ intf_storage }} - name: add br-external to interface script lineinfile: - dest: /etc/sysconfig/network-scripts/ifcfg-{{contr_sys_mappings["external"]["interface"]}} + dest: /etc/sysconfig/network-scripts/ifcfg-{{ intf_external }} line: "BRIDGE=br-external" - name: add br-storage to interface script lineinfile: - dest: /etc/sysconfig/network-scripts/ifcfg-{{contr_sys_mappings["storage"]["interface"]}}.{{contr_sys_mappings["storage"]["vlan_tag"]}} + dest: /etc/sysconfig/network-scripts/ifcfg-{{ intf_storage }} line: "BRIDGE=br-storage" - name: add br-tenant to interface script lineinfile: - dest: /etc/sysconfig/network-scripts/ifcfg-{{contr_sys_mappings["tenant"]["interface"]}}.{{contr_sys_mappings["tenant"]["vlan_tag"]}} + dest: /etc/sysconfig/network-scripts/ifcfg-{{ intf_tenant }} line: "BRIDGE=br-tenant" -# yamllint enable rule:line-length - name: remove eth0 ip addresss lineinfile: diff --git a/deploy/adapters/ansible/roles/config-controller/templates/ifcfg-br-mgmt b/deploy/adapters/ansible/roles/config-controller/templates/ifcfg-br-mgmt index 2e958cc7..184f752b 100644 --- a/deploy/adapters/ansible/roles/config-controller/templates/ifcfg-br-mgmt +++ b/deploy/adapters/ansible/roles/config-controller/templates/ifcfg-br-mgmt @@ -5,3 +5,4 @@ PREFIX=24 BOOTPROTO=none ONBOOT=yes DELAY=0 +DEFROUTE="no" diff --git a/deploy/adapters/ansible/roles/config-controller/templates/ifcfg-if.storage b/deploy/adapters/ansible/roles/config-controller/templates/ifcfg-if.storage index b71a80cf..c0a14049 100644 --- a/deploy/adapters/ansible/roles/config-controller/templates/ifcfg-if.storage +++ b/deploy/adapters/ansible/roles/config-controller/templates/ifcfg-if.storage @@ -1,4 +1,9 @@ -DEVICE={{contr_sys_mappings["storage"]["interface"]}}.{{contr_sys_mappings["storage"]["vlan_tag"]}} -BOOTPROTO=none +DEVICE={{ intf_storage }} ONBOOT=yes -VLAN=yes +{% if contr_sys_mappings["storage"]["vlan_tag"] | int %} +{% set intf_vlan = "yes" %} +{% else %} +{% set intf_vlan = "no" %} +{% endif %} +VLAN={{ intf_vlan }} +BOOTPROTO=none diff --git a/deploy/adapters/ansible/roles/config-controller/templates/ifcfg-if.tenant b/deploy/adapters/ansible/roles/config-controller/templates/ifcfg-if.tenant index bc9f2a57..b45c001f 100644 --- a/deploy/adapters/ansible/roles/config-controller/templates/ifcfg-if.tenant +++ b/deploy/adapters/ansible/roles/config-controller/templates/ifcfg-if.tenant @@ -1,4 +1,9 @@ -DEVICE={{contr_sys_mappings["tenant"]["interface"]}}.{{contr_sys_mappings["tenant"]["vlan_tag"]}} +DEVICE={{ intf_tenant }} BOOTPROTO=none ONBOOT=yes -VLAN=yes +{% if contr_sys_mappings["tenant"]["vlan_tag"] | int %} +{% set intf_vlan = "yes" %} +{% else %} +{% set intf_vlan = "no" %} +{% endif %} +VLAN={{ intf_vlan }} diff --git a/deploy/adapters/ansible/roles/config-controller/vars/main.yml b/deploy/adapters/ansible/roles/config-controller/vars/main.yml index 783ea0d0..701ec52b 100644 --- a/deploy/adapters/ansible/roles/config-controller/vars/main.yml +++ b/deploy/adapters/ansible/roles/config-controller/vars/main.yml @@ -8,3 +8,24 @@ # ############################################################################# --- LOCAL_REPOSITORY_IP: "192.168.137.222" + +intf_external: |- + {%- set intf_external = contr_sys_mappings["external"]["interface"] %} + {%- if contr_sys_mappings["external"]["vlan_tag"] | int %} + {%- set intf_external = intf_external + '.' + contr_sys_mappings["external"]["vlan_tag"]|string %} + {%- endif %} + {{- intf_external }} + +intf_tenant: |- + {%- set intf_tenant = contr_sys_mappings["tenant"]["interface"] %} + {%- if contr_sys_mappings["tenant"]["vlan_tag"] | int %} + {%- set intf_tenant = intf_tenant + '.' + contr_sys_mappings["tenant"]["vlan_tag"]|string %} + {%- endif %} + {{- intf_tenant }} + +intf_storage: |- + {%- set intf_storage = contr_sys_mappings["storage"]["interface"] %} + {%- if contr_sys_mappings["storage"]["vlan_tag"] | int %} + {%- set intf_storage = intf_storage + '.' + contr_sys_mappings["storage"]["vlan_tag"]|string %} + {%- endif %} + {{- intf_storage }} diff --git a/deploy/adapters/ansible/roles/post-osa/tasks/RedHat.yml b/deploy/adapters/ansible/roles/post-osa/tasks/RedHat.yml index 287fd515..dce89ef8 100644 --- a/deploy/adapters/ansible/roles/post-osa/tasks/RedHat.yml +++ b/deploy/adapters/ansible/roles/post-osa/tasks/RedHat.yml @@ -33,17 +33,17 @@ - name: generate ifcfg-external template: src: ifcfg-external.j2 - dest: /etc/sysconfig/network-scripts/ifcfg-{{compu_sys_mappings["external"]["interface"]}} + dest: /etc/sysconfig/network-scripts/ifcfg-{{ intf_external }} - name: generate ifcfg-storage template: src: ifcfg-storage.j2 - dest: /etc/sysconfig/network-scripts/ifcfg-{{compu_sys_mappings["storage"]["interface"]}}.{{compu_sys_mappings["storage"]["vlan_tag"]}} + dest: /etc/sysconfig/network-scripts/ifcfg-{{ intf_storage }} - name: generate ifcfg-tenant template: src: ifcfg-tenant.j2 - dest: /etc/sysconfig/network-scripts/ifcfg-{{compu_sys_mappings["tenant"]["interface"]}}.{{compu_sys_mappings["tenant"]["vlan_tag"]}} + dest: /etc/sysconfig/network-scripts/ifcfg-{{ intf_tenant }} # yamllint enable rule:line-length diff --git a/deploy/adapters/ansible/roles/post-osa/templates/ifcfg-storage.j2 b/deploy/adapters/ansible/roles/post-osa/templates/ifcfg-storage.j2 index 338da8c4..98cce6cb 100644 --- a/deploy/adapters/ansible/roles/post-osa/templates/ifcfg-storage.j2 +++ b/deploy/adapters/ansible/roles/post-osa/templates/ifcfg-storage.j2 @@ -1,7 +1,12 @@ -DEVICE={{compu_sys_mappings["storage"]["interface"]}}.{{compu_sys_mappings["storage"]["vlan_tag"]}} +DEVICE={{ intf_storage }} BOOTPROTO=none ONBOOT=yes -VLAN=yes IPADDR={{ ip_settings[inventory_hostname]["storage"]["ip"] }} NETMASK=255.255.255.0 DEFROUTE="no" +{% if contr_sys_mappings["storage"]["vlan_tag"] | int %} +{% set intf_vlan = "yes" %} +{% else %} +{% set intf_vlan = "no" %} +{% endif %} +VLAN={{ intf_vlan }} diff --git a/deploy/adapters/ansible/roles/post-osa/templates/ifcfg-tenant.j2 b/deploy/adapters/ansible/roles/post-osa/templates/ifcfg-tenant.j2 index 15230c96..fce9b572 100644 --- a/deploy/adapters/ansible/roles/post-osa/templates/ifcfg-tenant.j2 +++ b/deploy/adapters/ansible/roles/post-osa/templates/ifcfg-tenant.j2 @@ -1,7 +1,12 @@ -DEVICE={{compu_sys_mappings["tenant"]["interface"]}}.{{compu_sys_mappings["tenant"]["vlan_tag"]}} +DEVICE={{ intf_tenant }} BOOTPROTO=none ONBOOT=yes -VLAN=yes IPADDR={{ ip_settings[inventory_hostname]["tenant"]["ip"] }} NETMASK=255.255.255.0 DEFROUTE="no" +{% if contr_sys_mappings["tenant"]["vlan_tag"] | int %} +{% set intf_vlan = "yes" %} +{% else %} +{% set intf_vlan = "no" %} +{% endif %} +VLAN={{ intf_vlan }} diff --git a/deploy/adapters/ansible/roles/post-osa/vars/main.yml b/deploy/adapters/ansible/roles/post-osa/vars/main.yml index 4feb9756..da886028 100644 --- a/deploy/adapters/ansible/roles/post-osa/vars/main.yml +++ b/deploy/adapters/ansible/roles/post-osa/vars/main.yml @@ -3,3 +3,24 @@ sfc_plugins: src: sfc.conf dst: /opt/sfc.conf + +intf_external: |- + {%- set intf_external = compu_sys_mappings["external"]["interface"] %} + {%- if compu_sys_mappings["external"]["vlan_tag"] | int %} + {%- set intf_external = intf_external + '.' + compu_sys_mappings["external"]["vlan_tag"]|string %} + {%- endif %} + {{- intf_external }} + +intf_tenant: |- + {%- set intf_tenant = compu_sys_mappings["tenant"]["interface"] %} + {%- if compu_sys_mappings["tenant"]["vlan_tag"] | int %} + {%- set intf_tenant = intf_tenant + '.' + compu_sys_mappings["tenant"]["vlan_tag"]|string %} + {%- endif %} + {{- intf_tenant }} + +intf_storage: |- + {%- set intf_storage = compu_sys_mappings["storage"]["interface"] %} + {%- if compu_sys_mappings["storage"]["vlan_tag"] | int %} + {%- set intf_storage = intf_storage + '.' + compu_sys_mappings["storage"]["vlan_tag"]|string %} + {%- endif %} + {{- intf_storage }} diff --git a/deploy/adapters/ansible/roles/pre-openstack/tasks/RedHat.yml b/deploy/adapters/ansible/roles/pre-openstack/tasks/RedHat.yml index 5456c9fc..6ac191a3 100644 --- a/deploy/adapters/ansible/roles/pre-openstack/tasks/RedHat.yml +++ b/deploy/adapters/ansible/roles/pre-openstack/tasks/RedHat.yml @@ -49,6 +49,30 @@ - /tmp/ssh-keys-* - /root/.ssh/id_rsa.pub +- name: configure BOOTPROTO to static + replace: + dest: /etc/sysconfig/network-scripts/ifcfg-{{ compu_sys_mappings["external"]["interface"] }} + regexp: 'BOOTPROTO=.*' + replace: 'BOOTPROTO=static' + +- name: remove default route for mgmt + lineinfile: + dest: /etc/sysconfig/network-scripts/ifcfg-eth0 + line: "DEFROUTE=\"no\"" + +- name: backup external configure + shell: | + mv /etc/sysconfig/network-scripts/ifcfg-{{ compu_sys_mappings["external"]["interface"] }} \ + /home/ifcfg-{{ compu_sys_mappings["external"]["interface"] }} + +- name: configure external network + template: + src: ifcfg-external.j2 + dest: /etc/sysconfig/network-scripts/ifcfg-{{compu_sys_mappings["external"]["interface"]}} + +- name: restart network + shell: systemctl restart network + - name: change sources(yum) list copy: src: centos_base.repo @@ -75,3 +99,17 @@ - name: restart ssh service shell: service sshd restart + +- name: recovery external configure + shell: | + mv /home/ifcfg-{{ compu_sys_mappings["external"]["interface"] }} \ + /etc/sysconfig/network-scripts/ifcfg-{{ compu_sys_mappings["external"]["interface"] }} + +- name: add default route for mgmt + lineinfile: + dest: /etc/sysconfig/network-scripts/ifcfg-eth0 + regexp: "^DEFROUTE=\"no\"" + state: absent + +- name: restart network + shell: systemctl restart network diff --git a/deploy/adapters/ansible/roles/pre-openstack/templates/ifcfg-external.j2 b/deploy/adapters/ansible/roles/pre-openstack/templates/ifcfg-external.j2 new file mode 100644 index 00000000..05ad69f7 --- /dev/null +++ b/deploy/adapters/ansible/roles/pre-openstack/templates/ifcfg-external.j2 @@ -0,0 +1,8 @@ +DEVICE={{compu_sys_mappings["external"]["interface"]}} +ONBOOT=yes +BOOTPROTO=static +TYPE=Ethernet +IPADDR={{ ip_settings[inventory_hostname]["external"]["ip"] }} +GATEWAY={{ ip_settings[inventory_hostname]["external"]["gw"] }} +NETMASK=255.255.255.0 +DEFROUTE=yes diff --git a/deploy/adapters/ansible/roles/pre-openstack/vars/main.yml b/deploy/adapters/ansible/roles/pre-openstack/vars/main.yml index f44a9f9f..1b8c238b 100644 --- a/deploy/adapters/ansible/roles/pre-openstack/vars/main.yml +++ b/deploy/adapters/ansible/roles/pre-openstack/vars/main.yml @@ -1,20 +1,22 @@ --- aptpackages: -- bridge-utils -- debootstrap -- ifenslave -- ifenslave-2.6 -- lsof -- lvm2 -- ntp -- ntpdate -- sudo -- vlan -- tcpdump + - bridge-utils + - debootstrap + - ifenslave + - ifenslave-2.6 + - lsof + - lvm2 + - ntp + - ntpdate + - sudo + - vlan + - tcpdump yumpackages: -- bridge-utils -- iputils -- lvm2 -- ntp -- tcpdump + - bridge-utils + - iputils + - lvm2 + - ntp + - tcpdump + - net-tools + - vim |