fix
This commit is contained in:
parent
bebe621f3e
commit
a812baa242
1 changed files with 13 additions and 1 deletions
|
@ -45,9 +45,14 @@ def main():
|
|||
'api_url': { 'type': 'str', 'default': 'http://127.0.0.1:9200' },
|
||||
'api_user': { 'type': 'str', 'default': None },
|
||||
'api_password': { 'type': 'str', 'default': None },
|
||||
'state': { 'type': 'str', 'default': 'present', 'required': True, 'choice': ['absent', 'present'] },
|
||||
}
|
||||
module = AnsibleModule(argument_spec=fields)
|
||||
changed = False
|
||||
special_users = [
|
||||
'elastic', 'kibana', 'logstash_system',
|
||||
'beats_system', 'apm_system', 'remote_monitoring_user'
|
||||
]
|
||||
|
||||
options = {
|
||||
'roles': module.params['roles'],
|
||||
|
@ -66,7 +71,14 @@ def main():
|
|||
)
|
||||
user.get_data()
|
||||
|
||||
if module.params['name'] != 'elastic':
|
||||
if not module.params['name'] in special_users:
|
||||
if module.params['state'] == 'absent':
|
||||
if user.exist:
|
||||
user.delete()
|
||||
changed = True
|
||||
|
||||
module.exit_json(changed=changed)
|
||||
|
||||
if not user.exist or user.has_changed(module.params['roles']):
|
||||
user.create(options)
|
||||
changed = True
|
||||
|
|
Loading…
Reference in a new issue