Merge "Support both inventory and metal file in ceph_spec_bootstrap"
This commit is contained in:
commit
66a8781d2c
@ -40,11 +40,11 @@ description:
|
||||
- "The ceph_spec_bootstrap module uses information from both the composed services in TripleO roles and the deployed hosts file ('openstack overcloud node provision' output), or just the inventory file (tripleo-ansible-inventory output) to determine what Ceph services should run on what hosts and generate a valid Ceph spec. This allows the desired end state defined in TripleO to be translated into an end state defined in Ceph orchestrator. The intention is to use this module when bootstraping a new Ceph cluster."
|
||||
options:
|
||||
deployed_metalsmith:
|
||||
description: The absolute path to a file like deployed_metal.yaml, as genereated by 'openstack overcloud node provision --output deployed_metal.yaml'. This file is used to map which ceph_service_types map to which deployed hosts. Use this option if you have deployed servers with metalsmith but do not yet have an inventory genereated from the overcloud in Heat. Either tripleo_ansible_inventory xor deployed_metalsmith must be used (not both).
|
||||
description: The absolute path to a file like deployed_metal.yaml, as genereated by 'openstack overcloud node provision --output deployed_metal.yaml'. This file is used to map which ceph_service_types map to which deployed hosts. Use this option if you have deployed servers with metalsmith but do not yet have an inventory genereated from the overcloud in Heat. Either tripleo_ansible_inventory xor deployed_metalsmith must be used (not both) unless the method option is used.
|
||||
required: False
|
||||
type: str
|
||||
tripleo_ansible_inventory:
|
||||
description: The absolute path to an Ansible inventory genereated by running the tripleo-ansible-inventory command. This file is used to map which ceph_service_types map to which deployed hosts. Use this option if you already have an inventory genereated from the overcloud in Heat. Either tripleo_ansible_inventory xor deployed_metalsmith must be used (not both).
|
||||
description: The absolute path to an Ansible inventory genereated by running the tripleo-ansible-inventory command. This file is used to map which ceph_service_types map to which deployed hosts. Use this option if you already have an inventory genereated from the overcloud in Heat. Either tripleo_ansible_inventory xor deployed_metalsmith must be used (not both) unless the method option is used.
|
||||
required: False
|
||||
type: str
|
||||
new_ceph_spec:
|
||||
@ -77,8 +77,11 @@ options:
|
||||
type: bool
|
||||
mon_ip:
|
||||
description: The desired IP address of the first Ceph monitor. Required when standalone is true, otherwise ignored.
|
||||
method:
|
||||
description: Whether the deployed_metalsmith file or tripleo_ansible_inventory file should be used to build the spec if both of these parameters are passed. When "both" is used the roles, services and hosts are determined from deployed_metalsmith and tripleo_roles parameters but the IPs come from the tripleo_ansible_inventory parameter.
|
||||
required: False
|
||||
type: str
|
||||
choices: ['deployed_metalsmith', 'tripleo_ansible_inventory', 'both']
|
||||
author:
|
||||
- John Fulton (fultonj)
|
||||
'''
|
||||
@ -94,6 +97,13 @@ EXAMPLES = '''
|
||||
new_ceph_spec: "{{ playbook_dir }}/ceph_spec.yaml"
|
||||
tripleo_ansible_inventory: ~/config-download/overcloud/tripleo-ansible-inventory.yaml
|
||||
|
||||
- name: make spec from deployed_metalsmith; use inventory not DeployedSeverPortMap for IPs
|
||||
ceph_spec_bootstrap:
|
||||
new_ceph_spec: "{{ playbook_dir }}/ceph_spec.yaml"
|
||||
tripleo_ansible_inventory: ~/config-download/overcloud/tripleo-ansible-inventory.yaml
|
||||
deployed_metalsmith: ~/overcloud-baremetal-deployed.yaml
|
||||
method: 'both'
|
||||
|
||||
- name: make spec from inventory with FQDNs and custom osd_spec
|
||||
ceph_spec_bootstrap:
|
||||
new_ceph_spec: "{{ playbook_dir }}/ceph_spec.yaml"
|
||||
@ -441,6 +451,7 @@ def main():
|
||||
crush = module.params.get('crush_hierarchy')
|
||||
standalone = module.params.get('standalone')
|
||||
mon_ip = module.params.get('mon_ip')
|
||||
method = module.params.get('method')
|
||||
|
||||
# Set defaults
|
||||
if ceph_service_types is None:
|
||||
@ -465,22 +476,33 @@ def main():
|
||||
result['specs'] = ceph_spec_standalone(new_ceph_spec, mon_ip, osd_spec)
|
||||
module.exit_json(**result)
|
||||
# ... otherwise validate the inputs to build a multinode spec
|
||||
# 0. Are they using metalsmith xor an inventory as their method?
|
||||
method = ""
|
||||
# 0. Are they using metalsmith or an inventory as their method?
|
||||
|
||||
if not method:
|
||||
if not (deployed_metalsmith and tripleo_ansible_inventory):
|
||||
error = ("The tripleo_ansible_inventory or "
|
||||
"deployed_metalsmith parameter is required.")
|
||||
errors.append(error)
|
||||
result['failed'] = True
|
||||
if not deployed_metalsmith and tripleo_ansible_inventory:
|
||||
method = 'tripleo_ansible_inventory'
|
||||
elif deployed_metalsmith and not tripleo_ansible_inventory:
|
||||
method = 'deployed_metalsmith'
|
||||
else:
|
||||
method = "both"
|
||||
|
||||
# determine required files based on method
|
||||
required_files = []
|
||||
if deployed_metalsmith is None and tripleo_ansible_inventory is not None:
|
||||
method = 'inventory'
|
||||
if method == 'tripleo_ansible_inventory':
|
||||
required_files.append(tripleo_ansible_inventory)
|
||||
elif deployed_metalsmith is not None and tripleo_ansible_inventory is None:
|
||||
method = 'metal'
|
||||
elif method == 'deployed_metalsmith':
|
||||
required_files.append(deployed_metalsmith)
|
||||
required_files.append(tripleo_roles)
|
||||
else:
|
||||
error = "You must provide either the "
|
||||
error += "tripleo_ansible_inventory or deployed_metalsmith "
|
||||
error += "parameter (but not both)."
|
||||
errors.append(error)
|
||||
result['failed'] = True
|
||||
elif method == 'both':
|
||||
required_files.append(tripleo_ansible_inventory)
|
||||
required_files.append(deployed_metalsmith)
|
||||
required_files.append(tripleo_roles)
|
||||
|
||||
# 1. The required files must all be an existing path to a file
|
||||
for fpath in required_files:
|
||||
if not os.path.isfile(fpath):
|
||||
@ -503,19 +525,19 @@ def main():
|
||||
errors.append(error)
|
||||
result['failed'] = True
|
||||
# 5. fqdn is only supported for the inventory method
|
||||
if method != 'inventory' and fqdn:
|
||||
if method != 'tripleo_ansible_inventory' and fqdn:
|
||||
error = "The fqdn option may only be true when using tripleo_ansible_inventory"
|
||||
errors.append(error)
|
||||
result['failed'] = True
|
||||
|
||||
if not result['failed']:
|
||||
# Build data structures to map roles/services/hosts/labels
|
||||
if method == 'metal':
|
||||
if method == 'deployed_metalsmith':
|
||||
roles_to_svcs = get_roles_to_svcs_from_roles(tripleo_roles)
|
||||
roles_to_hosts = get_deployed_roles_to_hosts(deployed_metalsmith,
|
||||
roles_to_svcs.keys())
|
||||
hosts_to_ips = get_deployed_hosts_to_ips(deployed_metalsmith)
|
||||
elif method == 'inventory':
|
||||
elif method == 'tripleo_ansible_inventory':
|
||||
with open(tripleo_ansible_inventory, 'r') as stream:
|
||||
inventory = yaml.safe_load(stream)
|
||||
roles_to_svcs = get_roles_to_svcs_from_inventory(inventory)
|
||||
@ -525,6 +547,15 @@ def main():
|
||||
hosts_to_ips = get_inventory_hosts_to_ips(inventory,
|
||||
roles_to_svcs.keys(),
|
||||
fqdn)
|
||||
elif method == 'both':
|
||||
roles_to_svcs = get_roles_to_svcs_from_roles(tripleo_roles)
|
||||
roles_to_hosts = get_deployed_roles_to_hosts(deployed_metalsmith,
|
||||
roles_to_svcs.keys())
|
||||
with open(tripleo_ansible_inventory, 'r') as stream:
|
||||
inventory = yaml.safe_load(stream)
|
||||
hosts_to_ips = get_inventory_hosts_to_ips(inventory,
|
||||
roles_to_svcs.keys(),
|
||||
fqdn)
|
||||
# regardless of how we built our maps, assign the correct labels
|
||||
label_map = get_label_map(hosts_to_ips, roles_to_svcs,
|
||||
roles_to_hosts, ceph_service_types)
|
||||
|
@ -59,6 +59,8 @@
|
||||
when:
|
||||
- osd_spec_path is defined
|
||||
- osd_spec_path | length > 0
|
||||
tags:
|
||||
- ceph_spec
|
||||
|
||||
- name: Override crush hierarchy if a custom crush path is provided
|
||||
set_fact:
|
||||
@ -68,16 +70,22 @@
|
||||
when:
|
||||
- crush_hierarchy_path is defined
|
||||
- crush_hierarchy_path | length > 0
|
||||
tags:
|
||||
- ceph_spec
|
||||
|
||||
- name: Create Ceph spec based on baremetal_deployed_path and tripleo_roles
|
||||
ceph_spec_bootstrap:
|
||||
new_ceph_spec: "{{ ceph_spec_path }}"
|
||||
deployed_metalsmith: "{{ baremetal_deployed_path }}"
|
||||
tripleo_roles: "{{ tripleo_roles_path }}"
|
||||
osd_spec: "{{ osd_spec }}"
|
||||
crush_hierarchy: "{{ crush_hierarchy | default({}) }}"
|
||||
deployed_metalsmith: "{{ baremetal_deployed_path }}"
|
||||
tripleo_ansible_inventory: "{{ inventory_file }}"
|
||||
method: 'both'
|
||||
when:
|
||||
- dynamic_ceph_spec | bool
|
||||
tags:
|
||||
- ceph_spec
|
||||
|
||||
- name: Get list of hosts which need ceph-admin user
|
||||
vars:
|
||||
|
Loading…
Reference in New Issue
Block a user