Add initial implementation of scr_keys role for SSH credential retrie… - #1202
Open
dhruvmicrosoft wants to merge 1 commit into
Open
Add initial implementation of scr_keys role for SSH credential retrie…#1202dhruvmicrosoft wants to merge 1 commit into
dhruvmicrosoft wants to merge 1 commit into
Conversation
…val from Azure Key Vault
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces the initial SCR Ansible framework and an scr_keys role for retrieving SSH credentials from Azure Key Vault using managed identity.
Changes:
- Adds SCR framework and role documentation.
- Implements workload-, SID-, and host-level credential retrieval.
- Adds temporary key-file creation and cleanup behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
roles-scr/README.md |
Documents the SCR framework and roadmap. |
scr_keys/README.md |
Documents role usage, security, and operations. |
vars/main.yaml |
Defines secret names and cleanup defaults. |
tasks/main.yaml |
Dispatches retrieval or cleanup tasks. |
tasks/get_secrets.yaml |
Retrieves credentials and creates key files. |
tasks/cleanup.yaml |
Removes temporary key files. |
| --- | ||
| - name: "SCR Keys - Retrieve SSH credentials from Key Vault" | ||
| ansible.builtin.include_tasks: | ||
| file: roles-scr/scr_keys/tasks/get_secrets.yaml |
|
|
||
| - name: "SCR Keys - Remove temporary SSH key files" | ||
| ansible.builtin.include_tasks: | ||
| file: roles-scr/scr_keys/tasks/cleanup.yaml |
Comment on lines
+20
to
+21
| ansible.builtin.command: >- | ||
| az account show |
| ansible_ssh_common_args: {{ ansible_ssh_common_args | default('-') }} | ||
| _scr_username_{{ granularity }}: {{ lookup('vars', '_scr_username_' + granularity) }} | ||
| _scr_sshkey_{{ granularity }}: {{ lookup('vars', '_scr_sshkey_' + granularity) }} | ||
| verbosity: 1 |
| - name: "SCR Keys: ({{ function | upper }}) Put private key into a temp file on controller (0600) (controller only)" | ||
| ansible.builtin.copy: | ||
| content: "{{ _results.secrets[0].secret }}" | ||
| dest: "/tmp/ansible_kv_key_{{ inventory_hostname }}" |
| # SSH access to the source and destination SAP systems for key management operations. | ||
| # - By removing these files at the end of the playbook, we enhance the security posture of the deployment process. | ||
| # ---------------------------------------------------------------------------*/ | ||
| - name: "SCR Keys: ({{ function | upper }}) Cleanup the SSH credential files from the OS (controller only)" |
| - name: "SCR Keys: ({{ function | upper }}) Cleanup the SSH credential files from the OS (controller only)" | ||
| delegate_to: localhost | ||
| ansible.builtin.file: | ||
| path: "{{ ansible_ssh_private_key_file }}" |
Comment on lines
+196
to
+197
| Skip the identity chatter with `--skip-tags silent_v1`, or hide the | ||
| Key-Vault fetch traces with `--skip-tags silent_v2`. The recap `debug:` |
Comment on lines
+209
to
+210
| A calling playbook is expected to include the role three times — once | ||
| per side in `pre_tasks`, then once with `cleanup: true` in `post_tasks`: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces the initial SAP System Copy and Refresh (SCR) Ansible automation framework, focusing on secure SSH credential management using Azure Key Vault and Managed Identity (MSI). It adds comprehensive documentation and the first SCR role,
scr_keys, which retrieves and manages SSH credentials for SAP hosts, ensuring no static secrets are left on disk. The implementation emphasizes composability, security, and clear operational procedures.SCR Framework Introduction and Documentation:
roles-scr/README.mddescribing the SCR framework’s design, role responsibilities, and authentication model, including a roadmap for future roles.scr_keysrole in detail, covering inputs, outputs, Key Vault secret naming conventions, security notes, and integration patterns inscr_keys/README.md.New Role:
scr_keysImplementation:scr_keysto securely fetch SSH usernames and private keys from Azure Key Vault via MSI, expose them as per-host Ansible facts, and remove temporary key files after use. [1] [2]localhost) to ensure secrets never reside on remote hosts and are properly shredded post-playbook. [1] [2]Security and Operational Practices:
no_log: trueblocks, and key files are written with restrictive permissions (0600). The role does not set SSH options, leaving that to inventory or playbook configuration. [1] [2]silent_v1,silent_v2,secrets,cleanup) is used to control output verbosity and facilitate selective task execution. [1] [2]Known Limitations and Future Work:
This PR lays the foundation for secure, modular SAP system automation on Azure, with clear documentation and a robust credential management workflow.