Skip to content

Commit

Permalink
Fix needed to fetch vault secrets to remote hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
RanabirChakraborty committed Dec 3, 2024
1 parent 0315509 commit eee7394
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
19 changes: 17 additions & 2 deletions cci_vm_automate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,23 @@
path: inventory
block: "{{ instance.servers[0].access_ipv4 }}"

- name: Run cci_worker.yml playbook
ansible.builtin.command: ansible-playbook -i inventory -u cloud-user cci_worker.yml
- name: Fetch IP of vault.corp.redhat.com

Check failure on line 154 in cci_vm_automate.yml

View workflow job for this annotation

GitHub Actions / molecule (3.11)

risky-shell-pipe

Shells that use pipes should set the pipefail option.
ansible.builtin.shell: "ping -c 1 vault.corp.redhat.com | head -n 1 | awk -F'[()]' '{print $2}'"
register: vault_ip
changed_when: false

- name: Store vault IP in a variable
ansible.builtin.set_fact:
vault_ip_address: "{{ vault_ip.stdout }}"

- name: Pause for a minute to start the instance
ansible.builtin.pause:
minutes: 1

- name: Run cci_worker.yml playbook with vault IP as an extra variable
ansible.builtin.command: >
ansible-playbook -i inventory -u cloud-user cci_worker.yml
--extra-vars "vault_ip_address={{ vault_ip_address }}"
- name: Remove the inventory file
ansible.builtin.file:
Expand Down
7 changes: 7 additions & 0 deletions cci_worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
- vars/java.yml

pre_tasks:
- name: Add vault.corp.redhat.com entry to /etc/hosts
ansible.builtin.lineinfile:
path: /etc/hosts
line: "{{ vault_ip_address }} vault.corp.redhat.com"
create: yes
state: present

- name: "Load Secrets from Vault"
ansible.builtin.include_role:
name: "vault"
Expand Down

0 comments on commit eee7394

Please sign in to comment.