salt/scripts/salt-extend
2016-07-27 09:39:54 +10:00

61 lines
2.2 KiB
Python
Executable File

#!/usr/bin/env python
'''
Quickstart for creating an/or extending the functionality of your SaltStack installation
usage: salt-extend [-h] [--extension EXTENSION]
[--salt-directory SALT_DIRECTORY] [--name NAME]
[--description DESCRIPTION] [--no-merge]
optional arguments:
-h, --help show this help message and exit
--extension EXTENSION, -e EXTENSION
Extension type, e.g. 'module', 'state'.
--salt-directory SALT_DIRECTORY, -o SALT_DIRECTORY
Directory where your salt installation is kept
(defaults to .).
--name NAME, -n NAME Module name.
--description DESCRIPTION, -d DESCRIPTION
Short description of what the module does.
--no-merge Don't merge the module into the salt directory, keep
in a temp location
'''
import logging
from salt.scripts import salt_extend
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(description="Quickly boilerplate an extension to SaltStack")
parser.add_argument(
"--extension",
"-e",
help="Extension type, e.g. 'module', 'state'.")
parser.add_argument(
"--salt-directory",
"-o",
help="Directory where your salt installation is kept (defaults to .).")
parser.add_argument(
"--name",
"-n",
help="Module name.")
parser.add_argument(
"--description",
"-d",
help="Short description of what the module does.")
parser.add_argument(
"--no-merge",
help="Don't merge the module into the salt directory, keep in a temp location",
action="store_true")
parser.add_argument(
"--debug",
help="Display detailed logs whilst applying templates",
action="store_true")
args = parser.parse_args()
if args.debug:
logging.basicConfig(level=logging.DEBUG)
salt_extend(extension=args.extension,
name=args.name,
description=args.description,
salt_dir=args.salt_directory,
merge=not args.no_merge)