Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create/update systems and license keys #16

Merged
merged 12 commits into from
Nov 28, 2023

Conversation

MatthiasWinzeler
Copy link
Contributor

This PR adds the functionality discussed in issue #15.

Scope

  • The PR adds two modules:
    • license_keys, which allows creating and updating systems and their license keys.
      It is closely modeled after the interactions in the portal https://me.sap.com/licensekey, meaning that systems and license keys are always updated together (i.e. you cannot just create new license keys, but you have to edit the system, add license keys, and submit everything together).
    • systems_info, which allows retrieving existing systems (i.e. its system number), so that the system update/license key creation can be done in an idempotent manner (see example below).
  • What is intentionally out of scope:
    • The entity 'Installation' - the parent entity of systems - has to be created manually beforehand (and its installation number passed on to the module). We think that it's not worth to offer automation for creating installations, as installations are usually created once per customer and only the systems and license keys change frequently.
    • The module doesn't allow deletion of systems or license keys. We found that decommissioning of SAP systems is usually a manual process anyway. But if desired, we can add deletion to this module/PR.

Example

An example usage of the module which allows to idempotently create or update a system and retrieve the license key file:

- name: test license key creation
  hosts: localhost
  tasks:

  - name: get existing system
    community.sap_launchpad.systems_info:
      suser_id: S1234
      suser_password: password
      filter: "Insnr eq '123456789' and sysid eq 'B01' and ProductDescr eq 'SAP S/4HANA'"
    register: result

  - name: create license keys
    community.sap_launchpad.license_keys:
      suser_id: S1234
      suser_password: password
      installation_nr: 123456789
      system:
        nr: "{{ result.systems[0].Sysnr | default(omit) }}"
        product: SAP S/4HANA
        version: SAP S/4HANA 2022
        data:
          sysid: B01
          sysname: Test-System
          systype: Development system
          sysdb: SAP HANA database
          sysos: Linux
          sys_depl: Public - Microsoft Azure
      licenses:
        - type: Standard - Web Application Server ABAP or ABAP+JAVA
          data:
            hwkey: H1234567890
            expdate: 99991231
        - type: Maintenance Entitlement
          data:
            hwkey: H1234567890
            expdate: 99991231
    register: result

  - name: Display the license file containing the licenses
    debug:
      msg:
        - "{{ result.license_file }}"

I tested the following use cases to ensure full idempotency.

  • If no system exists, a new system and its licenses are created
  • If a system exists and passed with system.nr, its data attributes are updated and any changed licenses applied. If the licenses had no changes, they are not updated.

Let me know if you need more examples (should we create a sample playbook in the repo?), more extensive documentation or other changes. Please also let me know if I have to sign any CLA. Eager to get your feedback!

@rainerleber
Copy link
Collaborator

Hi @MatthiasWinzeler thank you for contributing. I will review this PR soon.

Copy link
Collaborator

@rainerleber rainerleber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First Review is Done. @MatthiasWinzeler thank you for this PR we appreciate it.

plugins/modules/license_keys.py Show resolved Hide resolved
plugins/modules/license_keys.py Show resolved Hide resolved
plugins/modules/license_keys.py Show resolved Hide resolved
plugins/modules/license_keys.py Show resolved Hide resolved
galaxy.yml Outdated Show resolved Hide resolved
plugins/modules/license_keys.py Show resolved Hide resolved
plugins/modules/license_keys.py Show resolved Hide resolved
plugins/modules/license_keys.py Outdated Show resolved Hide resolved
plugins/modules/license_keys.py Show resolved Hide resolved
@MatthiasWinzeler
Copy link
Contributor Author

@rainerleber many thanks for your feedback! I took care of the obvious comments and added follow-up questions where it was unclear to me how we proceed.

@rainerleber
Copy link
Collaborator

@MatthiasWinzeler thanks for clarify the questions. Only a few things are left :-) after that we are ready to merge I think.

@MatthiasWinzeler
Copy link
Contributor Author

@rainerleber thanks - merged your suggestions and responded your other comments. Can you give it a final review?

@MatthiasWinzeler
Copy link
Contributor Author

@rainerleber FYI, cleanup PR is in #17

Copy link
Collaborator

@rainerleber rainerleber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @MatthiasWinzeler thank you for the great work

@rainerleber rainerleber merged commit 3dda10c into sap-linuxlab:main Nov 28, 2023
2 checks passed
@MatthiasWinzeler MatthiasWinzeler deleted the license-keys branch November 28, 2023 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants