|
| 1 | +--- |
| 2 | +- name: Deploy OpenBao on the runners |
| 3 | + any_errors_fatal: true |
| 4 | + gather_facts: true |
| 5 | + hosts: github-runners,gitlab-runners |
| 6 | + tasks: |
| 7 | + - name: Set a fact about the virtualenv on the remote system |
| 8 | + set_fact: |
| 9 | + virtualenv: "{{ ansible_python_interpreter | dirname | dirname }}" |
| 10 | + when: |
| 11 | + - ansible_python_interpreter is defined |
| 12 | + - not ansible_python_interpreter.startswith('/bin/') |
| 13 | + - not ansible_python_interpreter.startswith('/usr/bin/') |
| 14 | + |
| 15 | + - name: Ensure Python hvac module is installed |
| 16 | + pip: |
| 17 | + name: hvac |
| 18 | + state: latest |
| 19 | + extra_args: "{% if pip_upper_constraints_file %}-c {{ pip_upper_constraints_file }}{% endif %}" |
| 20 | + virtualenv: "{{ virtualenv is defined | ternary(virtualenv, omit) }}" |
| 21 | + become: "{{ virtualenv is not defined }}" |
| 22 | + |
| 23 | + - name: Ensure /opt/kayobe/vault exists |
| 24 | + file: |
| 25 | + path: /opt/kayobe/vault |
| 26 | + state: directory |
| 27 | + become: true |
| 28 | + |
| 29 | + - import_role: |
| 30 | + name: stackhpc.hashicorp.openbao |
| 31 | + vars: |
| 32 | + openbao_config_dir: "/opt/kayobe/vault" |
| 33 | + openbao_cluster_name: "kayobe-automation" |
| 34 | + copy_self_signed_ca: false |
| 35 | + openbao_write_keys_file: true |
| 36 | + openbao_write_keys_file_path: "{{ kayobe_env_config_path }}/vault/kayobe-automation-keys.json" |
| 37 | + |
| 38 | + - name: Include OpenBao keys |
| 39 | + include_vars: |
| 40 | + file: "{{ kayobe_env_config_path }}/vault/kayobe-automation-keys.json" |
| 41 | + name: openbao_keys |
| 42 | + tags: always |
| 43 | + |
| 44 | + - import_role: |
| 45 | + name: stackhpc.hashicorp.vault_unseal |
| 46 | + vars: |
| 47 | + vault_api_addr: "{{ openbao_api_addr }}" |
| 48 | + vault_unseal_token: "{{ openbao_keys.root_token }}" |
| 49 | + vault_unseal_keys: "{{ openbao_keys.keys_base64 }}" |
| 50 | + vault_unseal_verify: false |
| 51 | + environment: |
| 52 | + https_proxy: '' |
| 53 | + |
| 54 | + - name: Create secret store |
| 55 | + hashivault_secret_engine: |
| 56 | + name: kayobe-automation |
| 57 | + backend: kv |
| 58 | + url: "{{ openbao_api_addr }}" |
| 59 | + token: "{{ openbao_keys.root_token }}" |
| 60 | + |
| 61 | + - name: Ensure secret store is present |
| 62 | + community.hashi_vault.vault_write: |
| 63 | + url: "{{ openbao_api_addr }}" |
| 64 | + token: "{{ openbao_keys.root_token }}" |
| 65 | + path: kayobe-automation/{{ kayobe_environment }} |
| 66 | + data: |
| 67 | + kayobe_vault_password: "{{ kolla_ansible_vault_password }}" |
| 68 | + kayobe_automation_ssh_private_key: "{{ lookup('ansible.builtin.file', '{{ ssh_private_key_path }}') }}" |
| 69 | + kayobe_public_openrc: "{{ lookup('ansible.builtin.file', '{{ kolla_config_path }}/public-openrc.sh') }}" |
| 70 | + tags: add_secrets |
0 commit comments