Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

verify subcommand #59

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions ansible-dk-cli/ansible-dk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUBY_ABI = "2.1.0"
PYTHON_ABI = "2.7"
HOME = os.getenv("HOME")

# pull version from version-manifest file left by package install
def check_version():
file='/opt/ansible-dk/version-manifest.json'
try:
Expand All @@ -32,18 +33,14 @@ def check_version():
return version

###################################################
# Generic top-level group definitions
# Generic top-level group definition
@click.group()
@click.version_option(version=check_version())
def cli():
pass


@cli.group()
def generate():
pass


###################################################
# shell-init command
@cli.command(name='shell-init')
@click.option('--debug', is_flag=True, help="Enable debug mode")
@click.argument('shell', default='bash')
Expand All @@ -66,7 +63,7 @@ def shell_init(shell, debug=False):
except OSError as e:
if e.errno == 17: # if file exists
if debug:
print("[DEBUG] %s - skipping - %s" % (e.strerror, e.filename))
print("[DEBUG] %s - skipping - %s" % (e.strerror, e.filename))
pass
else:
print("Error creating %s - %s(%d)" % (e.filename, e.strerror, e.errno))
Expand All @@ -82,19 +79,41 @@ def shell_init(shell, debug=False):
print("export PYTHONUSERBASE=\""+HOME+"/.ansible-dk/python\"")
print("export PIP_INSTALL_OPTION=\"--user\"")

# -- generate command
###################################################
# verify command
@cli.command()
def verify():
commands = [
'ansible-dk --version',
'aws --version 2>&1 | tr " " "\n" | tr "/" " "',
'ansible --version',
'ansible-lint --version',
'ruby --version',
'kitchen --version',
'gem list ^kitchen-* | tail -n+0',
]
for command in commands:
if os.system(command) != 0:
print "Verification of %s failed." % command.split()[0]
sys.exit(-1)
print "Verification succeeded."

###################################################
# generate command
@cli.group()
def generate():
pass

@generate.command(name='playbook')
@click.option('--name', required=True, help='Name of playbook to generate')
def generate_playbook(name):
print("Generating playbook: ", name)


@generate.command(name='role')
@click.option('--name', required=True, help='Name of role to generate')
def generate_role(name):
print("Generating role: ", name)


###################################################
# Call main CLI
if __name__ == '__main__':
Expand Down