roles/ansible-gentoo_install/

This commit is contained in:
2023-12-31 03:19:26 +00:00
parent 94c76b2e4b
commit f2575772ec
11 changed files with 363 additions and 61 deletions

View File

@@ -11,6 +11,7 @@ import pathlib
import traceback
# in the library
mod_path = ''
if os.environ.get('PLAY_ANSIBLE_SRC',''):
# running from source
mod_path = os.environ.get('PLAY_ANSIBLE_SRC','')
@@ -152,11 +153,17 @@ from ansible.module_utils.basic import AnsibleModule
def run_module():
# define available arguments/parameters a user can pass to the module
#? default config from __file__ ?
if mod_path and os.path.isdir(mod_path):
def_config = os.path.join(mod_path, 'configs', 'base.json')
else:
# WARN:
def_config = 'base.json'
module_args = dict(
action=dict(type='str', required=True),
loglevel=dict(type='int', required=False, default=logging.INFO),
threads=dict(type='int', required=False, default=1),
config=dict(type='str', default='cloud.json', required=False),
config=dict(type='path', default=def_config, required=True),
profile=dict(type='str', required=False),
kernel_dir=dict(type='path', required=False),
portage=dict(type='path', required=False),
@@ -204,6 +211,8 @@ def run_module():
try:
from gentooimgr.__main__ import main
retval = main(oargs)
# should be 0
# is stdout already in result? how can it be?
except Exception as e:
result['message'] = str(e)
e = traceback.print_exc()
@@ -214,7 +223,7 @@ def run_module():
# use whatever logic you need to determine whether or not this module
# made any modifications to your target
if dArgs['action'] in ['status']:
if dArgs['action'] in ['status', '']:
result['changed'] = False
else:
result['changed'] = True
@@ -227,7 +236,6 @@ def run_module():
def main():
run_module()
if __name__ == '__main__':
main()