diff --git a/bifrost/cli.py b/bifrost/cli.py index 7816888cf..e204a5ccb 100644 --- a/bifrost/cli.py +++ b/bifrost/cli.py @@ -51,10 +51,15 @@ def log(*message, only_if=True): print(*message, file=sys.stderr) -def ansible(playbook, inventory, verbose=False, env=None, **params): - extra = COMMON_PARAMS + list(itertools.chain.from_iterable( +def ansible(playbook, inventory, verbose=False, env=None, extra_vars=None, + **params): + extra = COMMON_PARAMS[:] + extra.extend(itertools.chain.from_iterable( ('-e', '%s=%s' % pair) for pair in params.items() if pair[1] is not None)) + if extra_vars: + extra.extend(itertools.chain.from_iterable( + ('-e', item) for item in extra_vars)) if verbose: extra.append('-vvvv') args = [ANSIBLE, playbook, '-i', inventory] + extra @@ -119,6 +124,7 @@ def cmd_testenv(args): test_vm_domain_type=args.domain_type, baremetal_json_file=os.path.abspath(args.inventory), baremetal_nodes_json=os.path.abspath(args.output), + extra_vars=args.extra_vars, **kwargs) log('Inventory generated in', args.output) @@ -157,6 +163,7 @@ def cmd_install(args): testing=args.testenv, use_cirros=args.testenv, use_tinyipa=args.testenv, + extra_vars=args.extra_vars, **kwargs) log("Ironic is installed and running, try it yourself:\n", " $ source %s/bin/activate\n" % VENV, @@ -190,6 +197,8 @@ def parse_args(): testenv.add_argument('--inventory', default='baremetal-inventory.json', help='output file with the inventory for using ' 'with dynamic playbooks') + testenv.add_argument('-e', '--extra-vars', action='append', + help='additional vars to pass to ansible') testenv.add_argument('-o', '--output', default='baremetal-nodes.json', help='output file with the nodes information for ' 'importing into ironic') @@ -217,6 +226,8 @@ def parse_args(): action='store_true', default=False, help='enable full disk cleaning between ' 'deployments (can take a lot of time)') + install.add_argument('-e', '--extra-vars', action='append', + help='additional vars to pass to ansible') args = parser.parse_args() if getattr(args, 'func', None) is None: diff --git a/releasenotes/notes/bifrost-cli-extra-19fd989a05b2e4b4.yaml b/releasenotes/notes/bifrost-cli-extra-19fd989a05b2e4b4.yaml new file mode 100644 index 000000000..0b10f4906 --- /dev/null +++ b/releasenotes/notes/bifrost-cli-extra-19fd989a05b2e4b4.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Extra parameters for ansible can now be passed to ``bifrost-cli`` via + the ``-e``/``--extra-vars`` flag. The format is the same as for + ansible-playbook. diff --git a/scripts/test-bifrost.sh b/scripts/test-bifrost.sh index 83d51ae96..3621b1eae 100755 --- a/scripts/test-bifrost.sh +++ b/scripts/test-bifrost.sh @@ -54,6 +54,10 @@ if [ "$ZUUL_BRANCH" != "" ]; then VM_SETUP_EXTRA="--storage-pool-path /opt/libvirt/images" fi +if [ -d "${WORKSPACE:-}" ]; then + BIFROST_CLI_EXTRA="${BIFROST_CLI_EXTRA:-} --extra-vars copy_from_local_path=true" +fi + source $SCRIPT_HOME/env-setup.sh # Note(cinerama): activate is not compatible with "set -u"; @@ -123,7 +127,9 @@ done --memory ${VM_MEMORY_SIZE:-512} \ --disk ${VM_DISK:-5} \ --inventory "${BAREMETAL_DATA_FILE}" \ - ${VM_SETUP_EXTRA:-} + --extra-vars git_url_root="${WORKSPACE:-https://opendev.org}" \ + ${VM_SETUP_EXTRA:-} \ + ${BIFROST_CLI_EXTRA:-} if [ ${USE_DHCP} = "true" ]; then # reduce the number of nodes in JSON file @@ -136,8 +142,9 @@ if [ ${USE_DHCP} = "true" ]; then fi if [ ${CLI_TEST} = "true" ]; then - # FIXME(dtantsur): bifrost-cli does not use opendev-provided repos. - ../bifrost-cli --debug install --testenv + ../bifrost-cli --debug install --testenv \ + --extra-vars git_url_root="${WORKSPACE:-https://opendev.org}" \ + ${BIFROST_CLI_EXTRA:-} fi set +e