Skip to content

Commit

Permalink
Stop using deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
TerryHowe committed Nov 12, 2018
1 parent 17a8966 commit 11d416f
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 27 deletions.
4 changes: 2 additions & 2 deletions ansible/module_utils/hashivault.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ def hashivault_auth(client, params):
role_id = params.get('role_id')

if authtype == 'github':
client.auth_github(token)
client.auth_methods.Github.login(token)
elif authtype == 'userpass':
client.auth_userpass(username, password)
elif authtype == 'ldap':
client.auth_ldap(username, password)
client.auth_methods.Ldap.login(username, password)
elif authtype == 'approle':
client = AppRoleClient(client,role_id,secret_id)
elif authtype == 'tls':
Expand Down
4 changes: 2 additions & 2 deletions ansible/modules/hashivault/hashivault_audit_enable.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ def hashivault_audit_enable(params):
name = params.get('name')
description = params.get('description')
options = params.get('options')
backends = client.list_audit_backends()
backends = client.sys.list_enabled_audit_devices()
backends = backends.get('data', backends)
path = name + "/"
if path in backends and backends[path]["options"] == options:
return {'changed': False}
client.enable_audit_backend(name, description=description, options=options)
client.sys.enable_audit_device(name, description=description, options=options)
return {'changed': True }


Expand Down
2 changes: 1 addition & 1 deletion ansible/modules/hashivault/hashivault_audit_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def main():
@hashiwrapper
def hashivault_audit_list(params):
client = hashivault_auth_client(params)
backends = client.list_audit_backends()
backends = client.sys.list_enabled_audit_devices()
backends = backends.get('data', backends)
return {'changed': True, 'backends': backends}

Expand Down
4 changes: 2 additions & 2 deletions ansible/modules/hashivault/hashivault_auth_enable.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ def hashivault_auth_enable(params):
name = params.get('name')
description = params.get('description')
mount_point = params.get('mount_point')
backends = client.list_auth_backends()
backends = client.sys.list_auth_methods()
path = (mount_point or name) + u"/"
if path in backends:
return {'changed': False}
client.enable_auth_backend(name, description=description, mount_point=mount_point)
client.sys.enable_auth_method(name, description=description, path=mount_point)
return {'changed': True}


Expand Down
2 changes: 1 addition & 1 deletion ansible/modules/hashivault/hashivault_auth_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def main():
@hashiwrapper
def hashivault_auth_list(params):
client = hashivault_auth_client(params)
result = client.list_auth_backends()
result = client.sys.list_auth_methods()
if isinstance(result, dict):
result = result.get('data', result)
return {'changed': True, 'backends': result}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def hashivault_aws_ec2_role_create(params):
if value is not None:
kwargs[arg] = value

if not 'aws/' in client.list_auth_backends().keys():
if not 'aws/' in client.sys.list_auth_methods().keys():
return { 'failed' : True , 'msg' : 'aws auth backend is not enabled', 'rc' : 1}

try:
Expand Down
4 changes: 2 additions & 2 deletions ansible/modules/hashivault/hashivault_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ def main():
@hashiwrapper
def hashivault_initialize(params):
client = hashivault_client(params)
if client.is_initialized():
if client.sys.is_initialized():
return {'changed': False}
result = {'changed': True}
secret_shares = params.get('secret_shares')
secret_threshold = params.get('secret_threshold')
pgp_keys = params.get('pgp_keys')
result.update(
client.initialize(
client.sys.initialize(
secret_shares=secret_shares,
secret_threshold=secret_threshold,
pgp_keys=pgp_keys
Expand Down
4 changes: 2 additions & 2 deletions ansible/modules/hashivault/hashivault_mount_tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def hashivault_mount_tune(module):
max_lease_ttl = module.params.get('max_lease_ttl')

changed = False
current_tuning = client.get_secret_backend_tuning(None, mount_point=mount_point)
current_tuning = client.sys.read_mount_configuration(mount_point)
current_tuning = current_tuning.get('data', current_tuning)
current_default_lease_ttl = current_tuning.get('default_lease_ttl')
current_max_lease_ttl = current_tuning.get('max_lease_ttl')
Expand All @@ -100,7 +100,7 @@ def hashivault_mount_tune(module):
changed = True

if not module.check_mode:
client.tune_secret_backend(None, mount_point=mount_point, default_lease_ttl=default_lease_ttl, max_lease_ttl=max_lease_ttl)
client.sys.tune_mount_configuration(mount_point, default_lease_ttl=default_lease_ttl, max_lease_ttl=max_lease_ttl)

return {'changed': changed}

Expand Down
4 changes: 2 additions & 2 deletions ansible/modules/hashivault/hashivault_policy_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ def main():
def hashivault_policy_delete(params):
name = params.get('name')
client = hashivault_auth_client(params)
current_policies = client.list_policies()
current_policies = client.sys.list_policies()
if isinstance(current_policies, dict):
current_policies = current_policies.get('data', current_policies)
current_policies = current_policies.get('policies', current_policies)
if name not in current_policies:
return {'changed': False}
client.delete_policy(name)
client.sys.delete_policy(name)
return {'changed': True}


Expand Down
2 changes: 1 addition & 1 deletion ansible/modules/hashivault/hashivault_policy_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def main():
@hashiwrapper
def hashivault_policy_list(params):
client = hashivault_auth_client(params)
current_policies = client.list_policies()
current_policies = client.sys.list_policies()
if isinstance(current_policies, dict):
current_policies = current_policies.get('data', current_policies)
current_policies = current_policies.get('policies', current_policies)
Expand Down
2 changes: 1 addition & 1 deletion ansible/modules/hashivault/hashivault_policy_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def hashivault_policy_set(params):
current = client.get_policy(name)
if current == rules:
return {'changed': False}
client.set_policy(name, rules)
client.sys.create_or_update_policy(name, rules)
return {'changed': True}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def hashivault_policy_set_from_file(params):
current = client.get_policy(name)
if current == rules:
return {'changed': False}
client.set_policy(name, rules)
client.sys.create_or_update_policy(name, rules)
return {'changed': True}


Expand Down
2 changes: 1 addition & 1 deletion ansible/modules/hashivault/hashivault_rekey_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def hashivault_rekey_init(params):
secret_threshold = params.get('secret_threshold')
pgp_keys = params.get('pgp_keys')
backup = params.get('backup')
return {'status': client.start_rekey(secret_shares, secret_threshold, pgp_keys, backup), 'changed': True}
return {'status': client.sys.start_rekey(secret_shares, secret_threshold, pgp_keys, backup), 'changed': True}

if __name__ == '__main__':
main()
5 changes: 3 additions & 2 deletions ansible/modules/hashivault/hashivault_seal.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ def main():
def hashivault_seal(params):
key = params.get('key')
client = hashivault_auth_client(params)
if not client.is_sealed():
return {'status': client.seal(), 'changed': True}
if not client.sys.is_sealed():
status = client.sys.seal().ok
return {'status': status, 'changed': True}
else:
return {'changed': False}

Expand Down
2 changes: 1 addition & 1 deletion ansible/modules/hashivault/hashivault_secret_disable.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def main():
def hashivault_secret_disable(params):
client = hashivault_auth_client(params)
name = params.get('name')
client.disable_secret_backend(name)
client.sys.disable_secrets_engine(name)
return {'changed': True}


Expand Down
4 changes: 2 additions & 2 deletions ansible/modules/hashivault/hashivault_secret_enable.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ def hashivault_secret_enable(params):
description = params.get('description')
config = params.get('config')
options = params.get('options')
secrets = client.list_secret_backends()
secrets = client.sys.list_mounted_secrets_engines()
secrets = secrets.get('data', secrets)
path = name + "/"
if path in secrets:
return {'changed': False}
client.enable_secret_backend(backend, description=description, mount_point=name, config=config, options=options)
client.sys.enable_secrets_engine(backend, description=description, path=name, config=config, options=options)
return {'changed': True}


Expand Down
2 changes: 1 addition & 1 deletion ansible/modules/hashivault/hashivault_secret_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def main():
@hashiwrapper
def hashivault_secret_list(params):
client = hashivault_auth_client(params)
current_backends = client.list_secret_backends()
current_backends = client.sys.list_mounted_secrets_engines()
if isinstance(current_backends, dict):
current_backends = current_backends.get('data', current_backends)
return {'changed': False, 'backends': current_backends}
Expand Down
4 changes: 2 additions & 2 deletions ansible/modules/hashivault/hashivault_unseal.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def main():
def hashivault_unseal(params):
keys = params.get('keys')
client = hashivault_client(params)
if client.is_sealed():
return {'status': client.unseal_multi(keys.split()), 'changed': True}
if client.sys.is_sealed():
return {'status': client.sys.submit_unseal_keys(keys.split()), 'changed': True}
else:
return {'changed': False}

Expand Down

0 comments on commit 11d416f

Please sign in to comment.