Merge "Generate an environment file during bifrost-cli install"
This commit is contained in:
commit
f3061e0a42
1
.gitignore
vendored
1
.gitignore
vendored
@ -76,3 +76,4 @@ playbooks/collections
|
|||||||
# Generated by bifrost-cli
|
# Generated by bifrost-cli
|
||||||
baremetal-inventory.json
|
baremetal-inventory.json
|
||||||
baremetal-nodes.json
|
baremetal-nodes.json
|
||||||
|
bifrost-install-env.json
|
||||||
|
@ -15,6 +15,7 @@ import argparse
|
|||||||
import configparser
|
import configparser
|
||||||
import ipaddress
|
import ipaddress
|
||||||
import itertools
|
import itertools
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
@ -56,11 +57,20 @@ def process_extra_vars(extra_vars):
|
|||||||
|
|
||||||
|
|
||||||
def ansible(playbook, inventory, verbose=False, env=None, extra_vars=None,
|
def ansible(playbook, inventory, verbose=False, env=None, extra_vars=None,
|
||||||
**params):
|
params_output_file=None, **params):
|
||||||
extra = COMMON_PARAMS[:]
|
extra = COMMON_PARAMS[:]
|
||||||
|
if params_output_file is None:
|
||||||
extra.extend(itertools.chain.from_iterable(
|
extra.extend(itertools.chain.from_iterable(
|
||||||
('-e', '%s=%s' % pair) for pair in params.items()
|
('-e', '%s=%s' % pair) for pair in params.items()
|
||||||
if pair[1] is not None))
|
if pair[1] is not None))
|
||||||
|
else:
|
||||||
|
params_output_file = os.path.abspath(params_output_file)
|
||||||
|
log('Writing environment file', params_output_file, only_if=verbose)
|
||||||
|
with open(params_output_file, 'wt') as output:
|
||||||
|
json.dump({k: v for k, v in params.items() if v is not None},
|
||||||
|
output)
|
||||||
|
extra.extend(['-e', '@%s' % params_output_file])
|
||||||
|
|
||||||
if extra_vars:
|
if extra_vars:
|
||||||
extra.extend(itertools.chain.from_iterable(
|
extra.extend(itertools.chain.from_iterable(
|
||||||
process_extra_vars(extra_vars)))
|
process_extra_vars(extra_vars)))
|
||||||
@ -154,14 +164,14 @@ def cmd_install(args):
|
|||||||
ansible('install.yaml',
|
ansible('install.yaml',
|
||||||
inventory='inventory/target',
|
inventory='inventory/target',
|
||||||
verbose=args.debug,
|
verbose=args.debug,
|
||||||
create_ipa_image='false',
|
create_ipa_image=False,
|
||||||
create_image_via_dib='false',
|
create_image_via_dib=False,
|
||||||
install_dib='true',
|
install_dib=True,
|
||||||
network_interface=args.network_interface,
|
network_interface=args.network_interface,
|
||||||
enable_keystone=args.enable_keystone,
|
enable_keystone=args.enable_keystone,
|
||||||
enable_tls=args.enable_tls,
|
enable_tls=args.enable_tls,
|
||||||
generate_tls=args.enable_tls,
|
generate_tls=args.enable_tls,
|
||||||
noauth_mode='false',
|
noauth_mode=False,
|
||||||
enabled_hardware_types=args.hardware_types,
|
enabled_hardware_types=args.hardware_types,
|
||||||
cleaning_disk_erase=args.cleaning_disk_erase,
|
cleaning_disk_erase=args.cleaning_disk_erase,
|
||||||
testing=args.testenv,
|
testing=args.testenv,
|
||||||
@ -172,6 +182,7 @@ def cmd_install(args):
|
|||||||
default_boot_mode=args.boot_mode or 'uefi',
|
default_boot_mode=args.boot_mode or 'uefi',
|
||||||
include_dhcp_server=not args.disable_dhcp,
|
include_dhcp_server=not args.disable_dhcp,
|
||||||
extra_vars=args.extra_vars,
|
extra_vars=args.extra_vars,
|
||||||
|
params_output_file=args.output,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
log("Ironic is installed and running, try it yourself:\n",
|
log("Ironic is installed and running, try it yourself:\n",
|
||||||
" $ source %s/bin/activate\n" % VENV,
|
" $ source %s/bin/activate\n" % VENV,
|
||||||
@ -277,6 +288,10 @@ def parse_args():
|
|||||||
help='Disable integrated dhcp server')
|
help='Disable integrated dhcp server')
|
||||||
install.add_argument('-e', '--extra-vars', action='append',
|
install.add_argument('-e', '--extra-vars', action='append',
|
||||||
help='additional vars to pass to ansible')
|
help='additional vars to pass to ansible')
|
||||||
|
install.add_argument('-o', '--output',
|
||||||
|
default='baremetal-install-env.json',
|
||||||
|
help='output file with the ansible environment used '
|
||||||
|
'to install Bifrost (excluding -e arguments)')
|
||||||
|
|
||||||
enroll = subparsers.add_parser(
|
enroll = subparsers.add_parser(
|
||||||
'enroll', help='Enroll bare metal nodes')
|
'enroll', help='Enroll bare metal nodes')
|
||||||
|
@ -299,6 +299,10 @@ See the built-in documentation for more details:
|
|||||||
|
|
||||||
./bifrost-cli install --help
|
./bifrost-cli install --help
|
||||||
|
|
||||||
|
The Ansible variables generated for installation are stored in a JSON file
|
||||||
|
(``bifrost-install-env.json`` by default) that should be passed via the ``-e``
|
||||||
|
flag to subsequent playbook or command invokations.
|
||||||
|
|
||||||
Using Bifrost
|
Using Bifrost
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
@ -239,6 +239,16 @@ To utilize the newer dynamic inventory based deployment:
|
|||||||
cd playbooks
|
cd playbooks
|
||||||
ansible-playbook -vvvv -i inventory/bifrost_inventory.py deploy-dynamic.yaml
|
ansible-playbook -vvvv -i inventory/bifrost_inventory.py deploy-dynamic.yaml
|
||||||
|
|
||||||
|
If you used ``bifrost-cli`` for installation, you should pass its environment
|
||||||
|
variables::
|
||||||
|
|
||||||
|
export BIFROST_INVENTORY_SOURCE=/tmp/baremetal.json
|
||||||
|
cd playbooks
|
||||||
|
ansible-playbook -vvvv \
|
||||||
|
-i inventory/bifrost_inventory.py \
|
||||||
|
-e @../bifrost-install-env.json \
|
||||||
|
deploy-dynamic.yaml
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
Before running the above command, ensure that the value for
|
Before running the above command, ensure that the value for
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
The ``bifrost-cli install`` command now generates an environment file
|
||||||
|
(``bifrost-install-env.json`` by default, can be changed with the
|
||||||
|
``--output`` argument) with the variables used during installation.
|
@ -86,6 +86,9 @@ sudo ls -lR /var/lib/ironic/httpboot > ${LOG_LOCATION}/pxe/listing.txt
|
|||||||
sudo bash -c "cp -aL /var/lib/ironic/httpboot/*.ipxe ${LOG_LOCATION}/pxe/"
|
sudo bash -c "cp -aL /var/lib/ironic/httpboot/*.ipxe ${LOG_LOCATION}/pxe/"
|
||||||
sudo cp -aL /var/lib/ironic/httpboot/pxelinux.cfg/ ${LOG_LOCATION}/pxe/
|
sudo cp -aL /var/lib/ironic/httpboot/pxelinux.cfg/ ${LOG_LOCATION}/pxe/
|
||||||
|
|
||||||
|
# Copy files generated by bifrost-cli
|
||||||
|
cp -a ${SCRIPT_HOME}/../playbooks/*.json ${LOG_LOCATION}
|
||||||
|
|
||||||
# Copy baremetal information
|
# Copy baremetal information
|
||||||
source $HOME/openrc bifrost
|
source $HOME/openrc bifrost
|
||||||
for vm in $(baremetal node list -c Name -f value); do
|
for vm in $(baremetal node list -c Name -f value); do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user