diff --git a/bifrost/cli.py b/bifrost/cli.py index 8b07e93e5..443933855 100644 --- a/bifrost/cli.py +++ b/bifrost/cli.py @@ -171,6 +171,21 @@ def cmd_install(args): "See documentation for next steps") +def cmd_enroll(args): + inventory = os.path.join(PLAYBOOKS, 'inventory', 'bifrost_inventory.py') + if os.path.exists(args.inventory): + nodes_inventory = os.path.abspath(args.inventory) + os.environ['BIFROST_INVENTORY_SOURCE'] = nodes_inventory + else: + sys.exit('Inventory file %s cannot be found' % args.inventory) + + ansible('enroll-dynamic.yaml', + inventory=inventory, + verbose=args.debug, + inspect_nodes=args.inspect, + extra_vars=args.extra_vars) + + def parse_args(): parser = argparse.ArgumentParser("Bifrost CLI") parser.add_argument('--debug', action='store_true', @@ -243,6 +258,16 @@ def parse_args(): install.add_argument('-e', '--extra-vars', action='append', help='additional vars to pass to ansible') + enroll = subparsers.add_parser( + 'enroll', help='Enroll bare metal nodes') + enroll.set_defaults(func=cmd_enroll) + enroll.add_argument('inventory', default='baremetal-inventory.json', + help='file with the inventory') + enroll.add_argument('--inspect', action='store_true', + help='inspect nodes while enrolling') + enroll.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: parser.print_usage(file=sys.stderr) diff --git a/doc/source/user/howto.rst b/doc/source/user/howto.rst index a6fd4e9f3..22f285d89 100644 --- a/doc/source/user/howto.rst +++ b/doc/source/user/howto.rst @@ -123,6 +123,10 @@ injection can be found in the ``playbooks/inventory/`` folder. How this works? --------------- +Starting with the Wallaby cycle, you can use ``bifrost-cli`` for enrolling:: + + ./bifrost-cli enroll /tmp/baremetal.json + Utilizing the dynamic inventory module, enrollment is as simple as setting the ``BIFROST_INVENTORY_SOURCE`` environment variable to your inventory data source, and then executing the enrollment playbook.:: diff --git a/releasenotes/notes/bifrost-cli-enroll-dd5a22f17c6666d5.yaml b/releasenotes/notes/bifrost-cli-enroll-dd5a22f17c6666d5.yaml new file mode 100644 index 000000000..5aeae5c2b --- /dev/null +++ b/releasenotes/notes/bifrost-cli-enroll-dd5a22f17c6666d5.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Adds a new command ``bifrost-cli enroll`` to simplify enrolling nodes.