summaryrefslogtreecommitdiffstats
path: root/xci/playbooks
diff options
context:
space:
mode:
Diffstat (limited to 'xci/playbooks')
-rw-r--r--xci/playbooks/configure-localhost.yml1
-rwxr-xr-xxci/playbooks/dynamic_inventory.py48
-rw-r--r--xci/playbooks/get-opnfv-scenario-requirements.yml6
-rw-r--r--xci/playbooks/roles/bootstrap-host/tasks/network_debian.yml8
-rw-r--r--xci/playbooks/roles/bootstrap-host/tasks/network_redhat.yml10
-rw-r--r--xci/playbooks/roles/bootstrap-host/tasks/network_suse.yml10
-rw-r--r--xci/playbooks/roles/bootstrap-host/templates/osa/debian.interface.j212
-rw-r--r--xci/playbooks/roles/bootstrap-host/templates/osa/redhat.interface.j27
-rw-r--r--xci/playbooks/roles/bootstrap-host/templates/osa/suse.interface.j24
-rw-r--r--xci/playbooks/roles/bootstrap-host/templates/osa/suse.routes.j22
10 files changed, 63 insertions, 45 deletions
diff --git a/xci/playbooks/configure-localhost.yml b/xci/playbooks/configure-localhost.yml
index 5f091c92..5b64c785 100644
--- a/xci/playbooks/configure-localhost.yml
+++ b/xci/playbooks/configure-localhost.yml
@@ -25,7 +25,6 @@
state: absent
recurse: no
with_items:
- - "{{ xci_cache }}/repos"
- "{{ log_path }} "
- "{{ opnfv_ssh_host_keys_path }}"
diff --git a/xci/playbooks/dynamic_inventory.py b/xci/playbooks/dynamic_inventory.py
index 8f498742..6d9d217f 100755
--- a/xci/playbooks/dynamic_inventory.py
+++ b/xci/playbooks/dynamic_inventory.py
@@ -13,6 +13,7 @@
# Based on https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/cobbler.py
import argparse
+import glob
import os
import sys
import yaml
@@ -30,19 +31,26 @@ class XCIInventory(object):
self.inventory['_meta']['hostvars'] = {}
self.installer = os.environ.get('INSTALLER_TYPE', 'osa')
self.flavor = os.environ.get('XCI_FLAVOR', 'mini')
+ self.flavor_files = os.path.dirname(os.path.realpath(__file__)) + "/../installer/" + self.installer + "/files/" + self.flavor
# Static information for opnfv host for now
self.add_host('opnfv')
- self.add_hostvar('opnfv', 'ansible_ssh_host', '192.168.122.2')
+ self.add_hostvar('opnfv', 'ansible_host', '192.168.122.2')
+ self.add_hostvar('opnfv', 'ip', '192.168.122.2')
self.add_to_group('deployment', 'opnfv')
self.add_to_group('opnfv', 'opnfv')
self.opnfv_networks = {}
self.opnfv_networks['opnfv'] = {}
- self.opnfv_networks['opnfv']['admin'] = '172.29.236.10'
- self.opnfv_networks['opnfv']['public'] = '192.168.122.2'
- self.opnfv_networks['opnfv']['private'] = '172.29.240.10'
- self.opnfv_networks['opnfv']['storage'] = '172.29.244.10'
+ self.opnfv_networks['opnfv']['admin'] = {}
+ self.opnfv_networks['opnfv']['admin']['address'] = '172.29.236.10/22'
+ self.opnfv_networks['opnfv']['public'] = {}
+ self.opnfv_networks['opnfv']['public']['address'] = '192.168.122.2/24'
+ self.opnfv_networks['opnfv']['public']['gateway'] = '192.168.122.1'
+ self.opnfv_networks['opnfv']['private'] = {}
+ self.opnfv_networks['opnfv']['private']['address'] = '172.29.240.10/22'
+ self.opnfv_networks['opnfv']['storage'] = {}
+ self.opnfv_networks['opnfv']['storage']['address'] = '172.29.244.10/24'
self.read_pdf_idf()
@@ -93,11 +101,15 @@ class XCIInventory(object):
pdf_host_info = filter(lambda x: x['name'] == host, pdf['nodes'])[0]
native_vlan_if = filter(lambda x: x['vlan'] == 'native', pdf_host_info['interfaces'])
self.add_hostvar(hostname, 'ansible_host', native_vlan_if[0]['address'])
+ self.add_hostvar(hostname, 'ip', native_vlan_if[0]['address'])
host_networks[hostname] = {}
# And now record the rest of the information
- for network in idf['idf']['net_config'].keys():
+ for network, ndata in idf['idf']['net_config'].items():
network_interface_num = idf['idf']['net_config'][network]['interface']
- host_networks[hostname][network] = pdf_host_info['interfaces'][int(network_interface_num)]['address']
+ host_networks[hostname][network] = {}
+ host_networks[hostname][network]['address'] = pdf_host_info['interfaces'][int(network_interface_num)]['address'] + "/" + str(ndata['mask'])
+ if 'gateway' in ndata.keys():
+ host_networks[hostname][network]['gateway'] = str(ndata['gateway']) + "/" + str(ndata['mask'])
host_networks.update(self.opnfv_networks)
@@ -107,6 +119,24 @@ class XCIInventory(object):
for parent in idf['xci'][self.installer]['groups'].keys():
map(lambda x: self.add_group(x, parent), idf['xci'][self.installer]['groups'][parent])
+ # Read additional group variables
+ self.read_additional_group_vars()
+
+ def read_additional_group_vars(self):
+ if not os.path.exists(self.flavor_files + "/inventory/group_vars"):
+ return
+ group_dir = self.flavor_files + "/inventory/group_vars/*.yml"
+ group_file = glob.glob(group_dir)
+ for g in group_file:
+ with open(g) as f:
+ try:
+ group_vars = yaml.safe_load(f)
+ except yaml.YAMLError as e:
+ print(e)
+ sys.exit(1)
+ for k,v in group_vars.items():
+ self.add_groupvar(os.path.basename(g.replace('.yml', '')), k, v)
+
def dump(self, data):
print (json.dumps(data, sort_keys=True, indent=2))
@@ -134,8 +164,8 @@ class XCIInventory(object):
self.inventory['_meta']['hostvars'][host].update({param: value})
def add_groupvar(self, group, param, value):
- if group not in self.groupvars(group):
- self.inventory[group]['vars'] = {}
+ if param not in self.groupvars(group):
+ self.inventory[group]['vars'][param] = {}
self.inventory[group]['vars'].update({param: value})
def hostvars(self):
diff --git a/xci/playbooks/get-opnfv-scenario-requirements.yml b/xci/playbooks/get-opnfv-scenario-requirements.yml
index 945a7802..a9165709 100644
--- a/xci/playbooks/get-opnfv-scenario-requirements.yml
+++ b/xci/playbooks/get-opnfv-scenario-requirements.yml
@@ -86,8 +86,6 @@
state: directory
become: true
- # NOTE(hwoarang) We have to check all levels of the local fact before we add it
- # otherwise Ansible will fail.
- name: Record scenario information
ini_file:
create: yes
@@ -97,10 +95,6 @@
value: "{{ xci_scenario.role | basename }}"
path: "/etc/ansible/facts.d/xci.fact"
become: true
- 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.scenarios is not defined)
- or (ansible_local is defined and ansible_local.xci is defined and ansible_local.xci.scenarios is defined and ansible_local.xci.scenarios.role is not defined)
- name: Fail if {{ deploy_scenario }} is not supported
fail:
diff --git a/xci/playbooks/roles/bootstrap-host/tasks/network_debian.yml b/xci/playbooks/roles/bootstrap-host/tasks/network_debian.yml
index 380e4c52..3cac1e22 100644
--- a/xci/playbooks/roles/bootstrap-host/tasks/network_debian.yml
+++ b/xci/playbooks/roles/bootstrap-host/tasks/network_debian.yml
@@ -45,10 +45,10 @@
- { 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].admin }}", prefix: "255.255.252.0" }
- - { name: "br-vxlan", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.30", ip: "{{ host_info[inventory_hostname].private }}", prefix: "255.255.252.0" }
- - { name: "br-vlan", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}", ip: "{{ host_info[inventory_hostname].public }}", prefix: "255.255.255.0", gateway: "192.168.122.1" }
- - { name: "br-storage", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.20", ip: "{{ host_info[inventory_hostname].storage }}", prefix: "255.255.252.0" }
+ - { name: "br-mgmt", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.10", network: "{{ host_info[inventory_hostname].admin }}" }
+ - { 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 }}"
diff --git a/xci/playbooks/roles/bootstrap-host/tasks/network_redhat.yml b/xci/playbooks/roles/bootstrap-host/tasks/network_redhat.yml
index 9dce50b6..b06a8695 100644
--- a/xci/playbooks/roles/bootstrap-host/tasks/network_redhat.yml
+++ b/xci/playbooks/roles/bootstrap-host/tasks/network_redhat.yml
@@ -17,17 +17,17 @@
- { 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: "br-vlan" , ip: "{{ host_info[inventory_hostname].public }}", prefix: 24 }
- - { name: "br-mgmt" , ip: "{{ host_info[inventory_hostname].admin }}", prefix: 22 }
- - { name: "br-storage", ip: "{{ host_info[inventory_hostname].storage }}", prefix: 22 }
- - { name: "br-vxlan" , ip: "{{ host_info[inventory_hostname].private}}", prefix: 22 }
+ - { name: "br-vlan" , network: "{{ host_info[inventory_hostname].public }}" }
+ - { name: "br-mgmt" , network: "{{ host_info[inventory_hostname].admin }}" }
+ - { name: "br-storage", network: "{{ host_info[inventory_hostname].storage }}" }
+ - { name: "br-vxlan" , network: "{{ host_info[inventory_hostname].private }}" }
loop_control:
label: "{{ item.name }}"
- name: Add default route through br-vlan
lineinfile:
path: "/etc/sysconfig/network-scripts/ifcfg-br-vlan"
- line: "GATEWAY=192.168.122.1"
+ line: "GATEWAY={{ host_info[inventory_hostname]['public']['gateway'] | ipaddr('address') }}"
- name: restart network service
service:
diff --git a/xci/playbooks/roles/bootstrap-host/tasks/network_suse.yml b/xci/playbooks/roles/bootstrap-host/tasks/network_suse.yml
index b1059c81..c9c9d83c 100644
--- a/xci/playbooks/roles/bootstrap-host/tasks/network_suse.yml
+++ b/xci/playbooks/roles/bootstrap-host/tasks/network_suse.yml
@@ -17,10 +17,10 @@
- { 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].admin }}/22" }
- - { name: "br-vxlan", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.30", ip: "{{ host_info[inventory_hostname].private }}/22" }
- - { name: "br-vlan", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}", ip: "{{ host_info[inventory_hostname].public }}/24" }
- - { name: "br-storage", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.20", ip: "{{ host_info[inventory_hostname].storage }}/22" }
+ - { name: "br-mgmt", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.10", network: "{{ host_info[inventory_hostname].admin }}" }
+ - { 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 }}"
@@ -35,7 +35,7 @@
src: "{{ installer_type }}/{{ ansible_os_family | lower }}.routes.j2"
dest: "/etc/sysconfig/network/ifroute-{{ item.name }}"
with_items:
- - { name: "br-vlan", gateway: "192.168.122.1", route: "default" }
+ - { name: "br-vlan", gateway: "{{ host_info[inventory_hostname]['public']['gateway'] }}", route: "default" }
- name: restart network service
service:
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 56db509b..3eddce45 100644
--- a/xci/playbooks/roles/bootstrap-host/templates/osa/debian.interface.j2
+++ b/xci/playbooks/roles/bootstrap-host/templates/osa/debian.interface.j2
@@ -25,14 +25,12 @@ iface {{ item.name }} inet static
post-down ip link del br-vlan-veth || true
bridge_ports br-vlan-veth
{% endif %}
-{% if item.ip is defined %}
- address {{ item.ip }}
+{% if item.network is defined %}
+ address {{ item.network.address | ipaddr('address') }}
+ netmask {{ item.network.address | ipaddr('netmask') }}
{% endif %}
-{% if item.prefix is defined %}
- netmask {{ item.prefix }}
-{% endif %}
-{% if item.gateway is defined %}
- gateway {{ item.gateway }}
+{% if item.network is defined and item.network.gateway is defined %}
+ gateway {{ item.network.gateway | ipaddr('address') }}
{% 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 d3364385..fa957764 100644
--- a/xci/playbooks/roles/bootstrap-host/templates/osa/redhat.interface.j2
+++ b/xci/playbooks/roles/bootstrap-host/templates/osa/redhat.interface.j2
@@ -14,9 +14,6 @@ TYPE=Bridge
DELAY=0
STP=off
{% endif %}
-{% if item.ip is defined %}
-IPADDR={{ item.ip }}
-{% endif %}
-{% if item.prefix is defined %}
-PREFIX={{ item.prefix }}
+{% if item.network is defined %}
+IPADDR={{ item.network.address }}
{% 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 27b01eb4..70811a09 100644
--- a/xci/playbooks/roles/bootstrap-host/templates/osa/suse.interface.j2
+++ b/xci/playbooks/roles/bootstrap-host/templates/osa/suse.interface.j2
@@ -10,8 +10,8 @@ BRIDGE_FORWARDDELAY='0'
BRIDGE_STP=off
BRIDGE_PORTS={{ item.bridge_ports }}
{% endif %}
-{% if item.ip is defined %}
-IPADDR={{ item.ip }}
+{% if item.network is defined %}
+IPADDR={{ item.network.address }}
{% endif %}
PRE_UP_SCRIPT="compat:suse:network-config-suse"
POST_DOWN_SCRIPT="compat:suse:network-config-suse"
diff --git a/xci/playbooks/roles/bootstrap-host/templates/osa/suse.routes.j2 b/xci/playbooks/roles/bootstrap-host/templates/osa/suse.routes.j2
index 7c868447..93941fad 100644
--- a/xci/playbooks/roles/bootstrap-host/templates/osa/suse.routes.j2
+++ b/xci/playbooks/roles/bootstrap-host/templates/osa/suse.routes.j2
@@ -1 +1 @@
-{{ item.route }} {{ item.gateway }}
+{{ item.route }} {{ item.gateway | ipaddr('address') }}