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

Omnia Credential utility #2531

Open
wants to merge 49 commits into
base: pub/new_architecture
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
33cafb7
Omnia credentials utility: initial draft
Aditya-DP Mar 3, 2025
2cfad9d
Omnia credetials utility: code changes
Aditya-DP Mar 3, 2025
ab50cce
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
75ba787
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
6d0d3e3
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
d5adb23
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
82ca84f
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
511e90a
Merge branch 'pub/new_architecture' into credential_utility
Aditya-DP Mar 3, 2025
dcaa072
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
1d65eaa
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
1a18911
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
9f9e588
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
bd5369d
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
e0a6b7c
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
66dca4d
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
811de14
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
eda51ad
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
edf311e
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
22de04c
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
7bdc8dc
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
f21dec5
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
2aa9e5d
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
a93b57f
Omnia credetials utility: code changes
Aditya-DP Mar 3, 2025
77d27ae
Omnia credetials utility: code changes
Aditya-DP Mar 3, 2025
e08be97
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
4260ed6
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
1db9fa3
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
19c40ed
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
5e3890e
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
bc65d01
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
c4d1357
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
8f94f0a
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
dd596f0
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
da55b18
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
e7a6860
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
c9b7286
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
deb9e19
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
53e83af
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
d3f0c2e
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
54189a9
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
4427daf
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
7550827
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
a98a5a6
Omnia credentials utility: code changes
Aditya-DP Mar 3, 2025
7bc19a1
Omnia credentials utility: code changes
Aditya-DP Mar 4, 2025
2dd1945
Omnia credentials utility: code changes
Aditya-DP Mar 4, 2025
06a3783
Omnia credentials utility: code changes
Aditya-DP Mar 4, 2025
67eef7d
Omnia credentials utility: code changes
Aditya-DP Mar 4, 2025
c7c09fd
Omnia credentials utility: code changes
Aditya-DP Mar 4, 2025
4705924
Omnia credentials utility: code changes
Aditya-DP Mar 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions utils/credential_utility/get_config_credentials.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---


- name: Include input project directory
when: not project_dir_status | default(false) | bool
ansible.builtin.import_playbook: ../include_input_dir.yml
tags: always

- name: Include validation include_tasks
hosts: localhost
connection: local
roles:
- validation
tags: always

- name: Create omnia_credential_config
hosts: localhost
connection: local
roles:
- role: create_config
when: not cred_file_status
tags: always


- name: Fetch and update credentials in config file
hosts: localhost
connection: local
roles:
- update_config
tags: always
25 changes: 25 additions & 0 deletions utils/credential_utility/roles/create_config/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---

- name: Create Omnia Credentials file
ansible.builtin.template:
src: "{{ omnia_credential_template }}"
dest: "{{ omnia_credential_file }}"
mode: "{{ omnia_credential_file_mode }}"

- name: Include omnia_credentials.yml
ansible.builtin.include_vars: "{{ omnia_credential_file }}"
register: include_omnia_credentials
no_log: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---

# Provision credentials
provision_password: ""
bmc_username: ""
bmc_password: ""
switch_snmp3_username: ""
switch_snmp3_password: ""

# Prepare_oim credentials
postgresdb_password: ""
pulp_password: ""
docker_username: ""
docker_password: ""

#Omnia credentials
mariadb_password: "password"

# Security credentials
openldap_db_username: "admin"
openldap_db_password: ""
openldap_config_username: "admin"
openldap_config_password: ""
openldap_monitor_password: ""
kerberos_admin_password: ""
directory_manager_password: ""
17 changes: 17 additions & 0 deletions utils/credential_utility/roles/create_config/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
omnia_credential_template: "{{ role_path }}/templates/omnia_credential.j2"
omnia_credential_file: "{{ input_project_dir }}/omnia_credentials.yml"
omnia_credential_file_mode: 600
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---

- name: Encrypt credentials file
block:
- name: Encrypt provision_config_credentials.yml
ansible.builtin.command: >-
ansible-vault encrypt {{ omnia_credential_file }}
--vault-password-file {{ omnia_credential_vault_path }}
changed_when: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---

- name: Initialize mandatory credentials status
ansible.builtin.set_fact:
mandatory_credentials_status: false

- name: Prompt to fetch Omnia credentials
ansible.builtin.include_tasks: "fetch_{{ type.key }}_credentials.yml"
loop: "{{ service.value | dict2items }}"
loop_control:
loop_var: type
when:
- service.key in software_names or service.key in ["provision", "prepare_oim","local_repo"]
- (omnia_run_tags | default([]) | difference(['all']) | length == 0)
or service.key in (omnia_run_tags | default([]))
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---

- name: Notify user about default inputs
ansible.builtin.debug:
msg: "{{ default_warning_msg }}"

- name: Fetch default credentials
ansible.builtin.include_tasks: prompt_credentials.yml
loop: "{{ type.value | dict2items }}"
loop_control:
loop_var: field
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---

- name: Set mandatory credentials status
ansible.builtin.set_fact:
mandatory_credentials_status: true

- name: Notify user about mandatory inputs
ansible.builtin.debug:
msg: "{{ mandatory_warning_msg }}"

- name: Fetch mandatory credentials
ansible.builtin.include_tasks: prompt_credentials.yml
loop: "{{ type.value | dict2items }}"
loop_control:
loop_var: field

- name: Reset mandatory credentials status
ansible.builtin.set_fact:
mandatory_credentials_status: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---

- name: Notify user about optional inputs
ansible.builtin.debug:
msg: "{{ optional_warning_msg }}"

- name: Fetch optional credentials
ansible.builtin.include_tasks: prompt_credentials.yml
loop: "{{ type.value | dict2items }}"
loop_control:
loop_var: field
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---

- name: Fetch "{{ password }}" if empty # noqa name[template]
when:
- vars[password] is defined
- (vars[password] | length == 0) or (type.key == "default")
block:
- name: Prompt user for Password
ansible.builtin.pause:
prompt: "Enter [{{ type.key }}] - {{ password }}"
echo: false
register: password_input

- name: Validate mandatory password not empty
ansible.builtin.fail:
msg: "{{ mandatory_password_fail_msg }}"
when:
- mandatory_credentials_status
- password_input.user_input | length == 0

- name: Prompt user to confirm password
ansible.builtin.pause:
prompt: "Confirm [{{ type.key }}] - {{ password }}"
echo: false
register: confirm_password
when: password_input.user_input | length != 0

- name: Ensure passwords match
ansible.builtin.fail:
msg: "{{ password_match_fail_msg }}"
when:
- password_input.user_input | length != 0
- password_input.user_input != confirm_password.user_input

- name: Update vars file with entered password
ansible.builtin.lineinfile:
path: "{{ omnia_credential_file }}"
regexp: '^{{ password }}:'
line: "{{ password }}: \"{{ password_input.user_input }}\""
no_log: true
when: password_input.user_input | length != 0
rescue:
- name: Invalid Password provided
ansible.builtin.include_tasks: encrypt_credentials_file.yml

- name: Failed to credentials with entered password
ansible.builtin.fail:
msg: "{{ password_fail_msg }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---

- name: Fetch "{{ username }}" if empty # noqa name[template]
when:
- vars[username] is defined
- (vars[username] | length == 0) or (type.key == "default")
block:
- name: Prompt user for Username
ansible.builtin.pause:
prompt: "Enter the [{{ type.key }}] - {{ username }}:"
register: username_input

- name: Validate mandatory username not empty
ansible.builtin.fail:
msg: "{{ mandatory_credentials_msg }}"
when:
- mandatory_credentials_status
- password_input.user_input | length == 0

- name: Update vars file with entered username
ansible.builtin.lineinfile:
path: "{{ omnia_credential_file }}"
regexp: '^{{ username }}:'
line: "{{ username }}: \"{{ username_input.user_input }}\""
no_log: true
when: username_input.user_input | length != 0

rescue:
- name: Invalid Username provided
ansible.builtin.include_tasks: encrypt_credentials_file.yml

- name: Failed to credentials with entered username
ansible.builtin.fail:
msg: "{{ username_fail_msg }}"
32 changes: 32 additions & 0 deletions utils/credential_utility/roles/update_config/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---

- name: Initialize list of tags
ansible.builtin.set_fact:
omnia_run_tags: "{{ ansible_run_tags | default([]) }}"
when: omnia_run_tags is not defined

- name: Fetch omnia credentials
ansible.builtin.include_tasks: fetch_credentials.yml
loop: "{{ omnia_credentials | dict2items }}"
loop_control:
loop_var: service

- name: Include updated credentials
ansible.builtin.include_vars: "{{ omnia_credential_file }}"
no_log: true

- name: Encrypt omnia credentials config
ansible.builtin.include_tasks: encrypt_credentials_file.yml
Loading