XenAPI: centralize the facts files

When bootstrap compute hosts for XenAPI, it will generate a facts
file for each compute node. It contains some XenAPI specific variables
for both the compute host and the XenServer where the compute host
run on. This commit is to fetch the facts file into deployment host
and put it under a centralized directory - each compute host will
have a separate sub-dir which is named with its *inventory_hostname*.

In this way, the following tasks can use proper variable from the
proper facts file which exactly belongs to the host they running on.

Change-Id: I68d1a2d098d38c8e6bf4db76cdaf1f0465831822
blueprint: xenserver-support
This commit is contained in:
Jianghua Wang 2018-02-09 07:59:15 +00:00
parent e66cb5d46b
commit 65fa37fb84
3 changed files with 21 additions and 4 deletions

View File

@ -736,7 +736,8 @@ xenserver_himn_ip: "169.254.0.1"
xenserver_username: "root"
xenserver_connect_protocol: "https"
# File used to save XenAPI's facts variables formatted as json.
xenapi_facts_file: "/etc/kolla/xenapi.json"
xenapi_facts_root: "/etc/kolla/xenapi/"
xenapi_facts_file: "facts.json"
#############################################
# MariaDB component-specific database details

View File

@ -149,7 +149,7 @@
service_name: "{{ item.key }}"
services_need_ml2_conf_ini:
- "neutron-openvswitch-agent-xenapi"
os_xenapi_variables: "{{ lookup('file', xenapi_facts_file) | from_json }}"
os_xenapi_variables: "{{ lookup('file', xenapi_facts_root + '/' + inventory_hostname + '/' + xenapi_facts_file) | from_json }}"
merge_configs:
sources:
- "{{ role_path }}/templates/ml2_conf.ini.j2"

View File

@ -4,6 +4,22 @@
state: present
become: True
- name: Bootstrap XenAPI compute node
command: xenapi_bootstrap -i {{ xenserver_himn_ip }} -u {{ xenserver_username }} -p {{ xenserver_password }} -f {{ xenapi_facts_file }}
- name: Ensure XenAPI root path
file:
path: "{{ xenapi_facts_root }}"
state: directory
mode: "0770"
become: True
- name: Bootstrap XenAPI compute node
vars:
xenapi_facts_path: "{{ xenapi_facts_root + '/' + xenapi_facts_file }}"
command: xenapi_bootstrap -i {{ xenserver_himn_ip }} -u {{ xenserver_username }} -p {{ xenserver_password }} -f {{ xenapi_facts_path }}
become: True
- name: Fetching XenAPI facts file
fetch:
src: "{{ xenapi_facts_root + '/' + xenapi_facts_file }}"
dest: "{{ xenapi_facts_root + '/' + inventory_hostname + '/' }}"
flat: yes
become: True