From d30fc513bbda9fb2ab8421ed795b89c25bc08f7d Mon Sep 17 00:00:00 2001 From: Yifei Xue Date: Mon, 11 Dec 2017 16:08:16 +0800 Subject: 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 --- .../ansible/roles/pre-openstack/tasks/RedHat.yml | 38 ++++++++++++++++++++++ .../pre-openstack/templates/ifcfg-external.j2 | 8 +++++ .../ansible/roles/pre-openstack/vars/main.yml | 34 ++++++++++--------- 3 files changed, 64 insertions(+), 16 deletions(-) create mode 100644 deploy/adapters/ansible/roles/pre-openstack/templates/ifcfg-external.j2 (limited to 'deploy/adapters/ansible/roles/pre-openstack') 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 -- cgit 1.2.3-korg