Skip to content

Commit

Permalink
Merge pull request #30 from wttech/Support_management_of_certificates…
Browse files Browse the repository at this point in the history
…_in_aem_global_trust_store_

Support management of certificates in aem global trust store
  • Loading branch information
jan-kowalczyk-wttech authored Aug 22, 2023
2 parents f7a1d83 + d8dd3be commit e1e9031
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 0 deletions.
37 changes: 37 additions & 0 deletions examples/local/gts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
- name: Test instances
hosts: localhost
tasks:

# Gts tests

- name: Get status of GTS
wttech.aem.gts:
command: status
instance_id: local_author

- name: Create GTS
wttech.aem.gts:
command: create
instance_id: local_author
password: test

- name: Add Cert to GTS
wttech.aem.gts_certificate:
command: add
instance_id: local_author
path: ~/projects/data/cert.cer
register: cert_data

- name: Read Cert from GTS
wttech.aem.gts_certificate:
command: read
instance_id: local_author
alias: "{{ cert_data.data.added }}"

- name: Remove Cert from GTS
wttech.aem.gts_certificate:
command: remove
instance_id: local_author
alias: "{{ cert_data.data.added }}"

9 changes: 9 additions & 0 deletions plugins/action/gts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from __future__ import (absolute_import, division, print_function)

__metaclass__ = type

from ..module_utils.action import AemActionBase


class ActionModule(AemActionBase):
pass
9 changes: 9 additions & 0 deletions plugins/action/gts_certificate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from __future__ import (absolute_import, division, print_function)

__metaclass__ = type

from ..module_utils.action import AemActionBase


class ActionModule(AemActionBase):
pass
62 changes: 62 additions & 0 deletions plugins/modules/gts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/python

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type


from ansible.module_utils.basic import AnsibleModule
from ..module_utils.cli import AEMC, AEMC_arg_spec

DOCUMENTATION = r'''
---
module: gts_certificate
short_description: Communicate with Global Trust Store
version_added: "1.3.6"
author:
- Jan Kowalczyk ([email protected])
'''

EXAMPLES = r'''
'''

RETURN = r'''
'''


def run_module():
module = AnsibleModule(
argument_spec=AEMC_arg_spec(dict(
command=dict(type='str', required=True),
instance_id=dict(type='str'),
password=dict(type='str'),
)),
required_if=[
('command', 'create', ['instance_id','password']),
('command', 'status', ['instance_id']),
]
)
aemc = AEMC(module)
command = module.params['command']

args = ['gts', command]

instance_id = module.params['instance_id']
if instance_id:
args.extend(['--instance-id', instance_id])

password = module.params['password']
if password:
args.extend(['--password', password])

aemc.handle_json(args=args)


def main():
run_module()


if __name__ == '__main__':
main()
68 changes: 68 additions & 0 deletions plugins/modules/gts_certificate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/python

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

from ansible.module_utils.basic import AnsibleModule
from ..module_utils.cli import AEMC, AEMC_arg_spec

DOCUMENTATION = r'''
---
module: gts_certificate
short_description: Manage certificates in Global Trust Store
version_added: "1.3.6"
author:
- Jan Kowalczyk ([email protected])
'''

EXAMPLES = r'''
'''

RETURN = r'''
'''


def run_module():
module = AnsibleModule(
argument_spec=AEMC_arg_spec(dict(
command=dict(type='str', required=True),
instance_id=dict(type='str'),
alias=dict(type='str'),
path=dict(type='str'),
)),
required_if=[
('command', 'add', ['instance_id','path']),
('command', 'remove', ['instance_id','alias']),
('command', 'read', ['instance_id','alias']),
]
)

aemc = AEMC(module)
command = module.params['command']

args = ['gts', 'certificate', command]

instance_id = module.params['instance_id']
if instance_id:
args.extend(['--instance-id', instance_id])

alias = module.params['alias']
if alias:
args.extend(['--alias', alias])

path = module.params['path']
if path:
args.extend(['--path', path])

aemc.handle_json(args=args)


def main():
run_module()


if __name__ == '__main__':
main()

0 comments on commit e1e9031

Please sign in to comment.