Repository URL to install this package:
|
Version:
4.1.94.1.dev5 ▾
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
import traceback
from ansible.module_utils.basic import AnsibleModule
from datetime import datetime
from cork import Cork
DOCUMENTATION = '''
---
module: configurator_password
short_description: Updates the configurator password.
options:
new_password:
description:
- service account new password
required: yes
author: Murali Balcha
'''
EXAMPLES = '''
examples:
- name: Update configurator password
configurator_password:
new_password: "newpassword"
'''
def populate_conf_directory(new_password):
cork = Cork('/opt/stack/workloadmgr/workloadmgr/tvault-config/conf',
initialize=True)
cork._store.roles['admin'] = 100
cork._store.roles['editor'] = 60
cork._store.roles['user'] = 50
cork._store.save_roles()
tstamp = str(datetime.utcnow())
username = 'admin'
password = new_password
cork._store.users[username] = {
'role': 'admin',
'hash': cork._hash(username, password),
'email_addr': username + '@localhost.local',
'desc': username + ' administrator',
'creation_date': tstamp
}
cork._store.save_users()
def main():
module = AnsibleModule(
argument_spec=dict(
new_password=dict(required=True, no_log=True),
),
)
new_password = module.params['new_password']
try:
populate_conf_directory(new_password)
d = dict(changed=True)
except Exception:
module.fail_json(msg=traceback.format_exc())
else:
module.exit_json(**d)
# this is magic, see lib/ansible/module_common.py
# <<INCLUDE_ANSIBLE_MODULE_COMMON>>
if __name__ == '__main__':
main()