Skip to content
Open
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
- name: Unseal secret store on the ci-runners
any_errors_fatal: true
gather_facts: true
hosts: github-runners:gitlab-runners
vars:
vault_api_addr: http://127.0.0.1:8200
tasks:
- name: Set a fact about the virtualenv on the remote system
ansible.builtin.set_fact:
virtualenv: "{{ ansible_python_interpreter | dirname | dirname }}"
when:
- ansible_python_interpreter is defined
- not ansible_python_interpreter.startswith('/bin/')
- not ansible_python_interpreter.startswith('/usr/bin/')

- name: Ensure Python hvac module is installed
ansible.builtin.pip:
name: hvac
state: latest

Choose a reason for hiding this comment

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

medium

For better idempotency and predictability, it's recommended to use state: present instead of state: latest. Using latest can cause the hvac package to be reinstalled on every playbook run if a newer version is available, which might not be the desired behavior and can lead to unexpected changes. present will ensure the package is installed and will not attempt to upgrade it if it's already present, while still respecting the version specified in pip_upper_constraints_file if provided.

        state: present

extra_args: "{% if pip_upper_constraints_file %}-c {{ pip_upper_constraints_file }}{% endif %}"
virtualenv: "{{ virtualenv is defined | ternary(virtualenv, omit) }}"
become: "{{ virtualenv is not defined }}"
Comment on lines +9 to +23

Choose a reason for hiding this comment

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

medium

These first two tasks, for setting up the virtualenv fact and installing the hvac package, are also present in secret-store-unseal-seed.yml and secret-store-unseal-overcloud.yml. To improve maintainability and reduce code duplication, consider extracting these common tasks into a new Ansible role (e.g., vault-client-prereqs). This new role could then be included in all three playbooks, making the codebase easier to manage in the long run.


- name: Include secret store keys
ansible.builtin.include_vars:
file: "{{ kayobe_env_config_path }}/{{ stackhpc_ca_secret_store }}/kayobe-automation-keys.json"
name: secret_store_keys

- name: Apply unseal role
ansible.builtin.import_role:
name: stackhpc.hashicorp.vault_unseal
vars:
vault_unseal_keys: "{{ secret_store_keys.keys_base64 }}"
Loading