summaryrefslogtreecommitdiffstats
path: root/xci/playbooks/roles/bootstrap-host
diff options
context:
space:
mode:
authorMarkos Chandras <mchandras@suse.de>2018-04-03 09:33:17 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-04-03 09:33:17 +0000
commite2b961ec221a68437fae2a062d3492b6e77d27ad (patch)
tree19ac6db7720ae38914f65b14920b831bee2e0678 /xci/playbooks/roles/bootstrap-host
parent56ab31c8ae5fe9e4f151fc1de5881c7bb2a09a2f (diff)
parent396ea65c98f71580a2e789c7d93c8d8611878b64 (diff)
Merge changes from topic 'misc-simplifications-osa'
* changes: xci: bootstrap-host: Make active network interface consistent xci: osa: Simplify tasks for copying OSA configuration files xci: Use proper Ansible modules to manage SSH keys
Diffstat (limited to 'xci/playbooks/roles/bootstrap-host')
-rw-r--r--xci/playbooks/roles/bootstrap-host/handlers/main.yml12
-rw-r--r--xci/playbooks/roles/bootstrap-host/tasks/network.yml59
2 files changed, 50 insertions, 21 deletions
diff --git a/xci/playbooks/roles/bootstrap-host/handlers/main.yml b/xci/playbooks/roles/bootstrap-host/handlers/main.yml
new file mode 100644
index 00000000..b9103233
--- /dev/null
+++ b/xci/playbooks/roles/bootstrap-host/handlers/main.yml
@@ -0,0 +1,12 @@
+---
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2018 SUSE Linux GmbH and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+- name: Reload facts
+ setup:
+ filter: ansible_local
diff --git a/xci/playbooks/roles/bootstrap-host/tasks/network.yml b/xci/playbooks/roles/bootstrap-host/tasks/network.yml
index ea9060e6..92e9195e 100644
--- a/xci/playbooks/roles/bootstrap-host/tasks/network.yml
+++ b/xci/playbooks/roles/bootstrap-host/tasks/network.yml
@@ -25,6 +25,31 @@
name: "{{ network_packages }}"
state: present
+- name: Ensure local facts directory exists
+ file:
+ path: "/etc/ansible/facts.d"
+ state: directory
+
+# NOTE(hwoarang) We have to check all levels of the local fact before we add it
+# otherwise Ansible will fail.
+- name: Record initial active interface
+ ini_file:
+ create: yes
+ section: network
+ state: present
+ option: xci_interface
+ value: "{{ ansible_default_ipv4.interface }}"
+ path: "/etc/ansible/facts.d/xci.fact"
+ when: ansible_local is not defined
+ or (ansible_local is defined and ansible_local.xci is not defined)
+ or (ansible_local is defined and ansible_local.xci is defined and ansible_local.xci.network is not defined)
+ or (ansible_local is defined and ansible_local.xci is defined and ansible_local.xci.network is defined and ansible_local.xci.network.xci_interface is not defined)
+ notify:
+ - Reload facts
+
+- name: Run handlers
+ meta: flush_handlers
+
- block:
- name: configure modules
lineinfile:
@@ -48,33 +73,25 @@
src: "{{ ansible_os_family | lower }}/{{ ansible_hostname }}.interface.j2"
dest: "/etc/network/interfaces"
- name: restart network service
- shell: "/sbin/ifconfig {{ ansible_default_ipv4.interface }} 0 && /sbin/ifdown -a && /sbin/ifup -a"
+ shell: "/sbin/ifconfig {{ ansible_local.xci.network.xci_interface }} 0 && /sbin/ifdown -a && /sbin/ifup -a"
async: 15
poll: 0
when: ansible_os_family | lower == "debian"
- block:
- - name: Remove existing network configuration
- file:
- path: "/etc/sysconfig/network/{{ item }}"
- state: absent
- with_items:
- - "ifcfg-eth0"
- - "ifroute-eth0"
-
- name: Configure networking on SUSE
template:
src: "{{ ansible_os_family | lower }}/suse.interface.j2"
dest: "/etc/sysconfig/network/ifcfg-{{ item.name }}"
with_items:
- - { name: "{{ ansible_default_ipv4.interface }}" }
- - { name: "{{ ansible_default_ipv4.interface }}.10", vlan_id: 10 }
- - { name: "{{ ansible_default_ipv4.interface }}.30", vlan_id: 30 }
- - { name: "{{ ansible_default_ipv4.interface }}.20", vlan_id: 20 }
- - { name: "br-mgmt", bridge_ports: "{{ ansible_default_ipv4.interface }}.10", ip: "{{ host_info[inventory_hostname].MGMT_IP }}/22" }
- - { name: "br-vxlan", bridge_ports: "{{ ansible_default_ipv4.interface }}.30", ip: "{{ host_info[inventory_hostname].VXLAN_IP }}/22" }
- - { name: "br-vlan", bridge_ports: "{{ ansible_default_ipv4.interface }}", ip: "{{ host_info[inventory_hostname].VLAN_IP }}/24" }
- - { name: "br-storage", bridge_ports: "{{ ansible_default_ipv4.interface }}.20", ip: "{{ host_info[inventory_hostname].STORAGE_IP }}/22" }
+ - { name: "{{ ansible_local.xci.network.xci_interface }}" }
+ - { 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", ip: "{{ host_info[inventory_hostname].MGMT_IP }}/22" }
+ - { name: "br-vxlan", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.30", ip: "{{ host_info[inventory_hostname].VXLAN_IP }}/22" }
+ - { name: "br-vlan", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}", ip: "{{ host_info[inventory_hostname].VLAN_IP }}/24" }
+ - { name: "br-storage", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.20", ip: "{{ host_info[inventory_hostname].STORAGE_IP }}/22" }
- name: Add postup/postdown scripts on SUSE
copy:
@@ -102,10 +119,10 @@
src: "{{ ansible_os_family | lower }}/interface.ifcfg.j2"
dest: "/etc/sysconfig/network-scripts/ifcfg-{{ item.name }}"
with_items:
- - { name: "{{ ansible_default_ipv4.interface }}" , bridge: "br-vlan" }
- - { name: "{{ ansible_default_ipv4.interface }}.10", bridge: "br-mgmt" , vlan_id: 10 }
- - { name: "{{ ansible_default_ipv4.interface }}.20", bridge: "br-storage", vlan_id: 20 }
- - { name: "{{ ansible_default_ipv4.interface }}.30", bridge: "br-vxlan" , vlan_id: 30 }
+ - { name: "{{ ansible_local.xci.network.xci_interface }}" , bridge: "br-vlan" }
+ - { name: "{{ ansible_local.xci.network.xci_interface }}.10", bridge: "br-mgmt" , vlan_id: 10 }
+ - { 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: Configure networking on CentOS for bridges
template:
src: "{{ ansible_os_family | lower }}/bridge.ifcfg.j2"