Laur Ivan
8adf037392
- Update ansible lint version - Add default doc link - Support for 4.x molecule version
45 lines
1.4 KiB
Python
Executable File
45 lines
1.4 KiB
Python
Executable File
#!/usr/bin/python3
|
|
|
|
import sys
|
|
import os
|
|
import shutil
|
|
|
|
|
|
def checkInput():
|
|
appName = "{{ cookiecutter.app_name }}"
|
|
moleculeVersion = "{{ cookiecutter.molecule_version }}"
|
|
if appName.endswith("role"):
|
|
print("Error: app_name should not have _role or -role at the end, try again without it")
|
|
print(" The name of the role will the value you introduce in app_name plus _role appended")
|
|
sys.exit(1)
|
|
if not (moleculeVersion.startswith("3") or moleculeVersion.startswith("4")):
|
|
print("Error: Only supported molecule version 3.x.x or 4.x.x, please change it and try again")
|
|
sys.exit(1)
|
|
|
|
def configureRole():
|
|
# Remove or not the service
|
|
|
|
shutil.rmtree("molecule/default/group_vars")
|
|
# Remove or not the handlers folder
|
|
if not {{ cookiecutter.has_handlers }}:
|
|
shutil.rmtree("handlers")
|
|
# Remove or not the templates folder
|
|
if not {{ cookiecutter.has_templates }}:
|
|
shutil.rmtree("templates")
|
|
|
|
# Remove or not the files folder
|
|
if not {{ cookiecutter.has_files }}:
|
|
shutil.rmtree("files")
|
|
else:
|
|
os.remove("files/.empty")
|
|
|
|
def generatePipfile():
|
|
print("Now cd into the role directory and introduce the following command for it to be ready: \"pipenv install -r test-requirements.txt --three\"")
|
|
|
|
def main():
|
|
checkInput()
|
|
configureRole()
|
|
generatePipfile()
|
|
|
|
if __name__ == '__main__':
|
|
main() |