Skip to content

Commit c5f4a4b

Browse files
authored
Merge pull request #248 from stackhpc/feature/debug-ci
Add script to retrieve CI inventory
2 parents bdeda03 + 645a09d commit c5f4a4b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

ansible/ci/retrieve_inventory.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Retrieve inventory from a deployed CI arcus environment by reversing arcus/inventory/hooks/pre.yml
2+
# Usage example:
3+
# ansible-playbook ansible/ci/retrieve_inventory.yml -e cluster_prefix=ci4005969475
4+
#
5+
- hosts: localhost
6+
become: no
7+
gather_facts: no
8+
vars:
9+
cluster_prefix: "{{ undef(hint='cluster_prefix must be defined') }}" # e.g. ci4005969475
10+
cluster_network: WCDC-iLab-60
11+
tasks:
12+
- name: Get control host IP
13+
set_fact:
14+
control_ip: "{{ (lookup('pipe', 'openstack server show -f json ' + cluster_prefix + '-control') | from_json)['addresses'][cluster_network][0] }}"
15+
- name: Add host into in-memory inventory
16+
add_host:
17+
name: cluster_control
18+
groups: control
19+
ansible_host: "{{ control_ip }}"
20+
21+
- hosts: control
22+
become: yes
23+
gather_facts: no
24+
tasks:
25+
- ansible.builtin.fetch:
26+
src: "/etc/ci-config/{{ item | basename }}"
27+
dest: "{{ item }}"
28+
flat: true
29+
loop:
30+
- "{{ lookup('env', 'APPLIANCES_ENVIRONMENT_ROOT') }}/inventory/hosts"
31+
- "{{ lookup('env', 'APPLIANCES_ENVIRONMENT_ROOT') }}/inventory/group_vars/all/secrets.yml"
32+
- "{{ lookup('env', 'APPLIANCES_ENVIRONMENT_ROOT') }}/inventory/group_vars/all/test_user.yml"

0 commit comments

Comments
 (0)