Skip to content

Commit 33c03f3

Browse files
authored
Use json output of IP
1 parent 0a5d2b4 commit 33c03f3

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

ansible/roles/lustre/tasks/configure.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
- name: Gather Lustre interface info
22
shell:
33
cmd: |
4-
ip r get {{ _lustre_mgs_ip }}
4+
ip --json r get {{ _lustre_mgs_ip }}
55
changed_when: false
66
register: _lustre_ip_r_mgs
77
vars:
88
_lustre_mgs_ip: "{{ lustre_mgs_nid | split('@') | first }}"
99

1010
- name: Set facts for Lustre interface
1111
set_fact:
12-
_lustre_interface: "{{ _lustre_ip_r_mgs_info[interface_index | int] }}"
13-
_lustre_ip: "{{ _lustre_ip_r_mgs_info[ip_index | int] }}"
12+
_lustre_interface: "{{ _lustre_ip_r_mgs_info.dev }}"
13+
_lustre_ip: "{{ _lustre_ip_r_mgs_info.prefsrc }}"
1414
vars:
15-
interface_index: "{{ 4 if 'via' in _lustre_ip_r_mgs.stdout_lines.0 else 2 }}"
16-
ip_index: "{{ 6 if 'via' in _lustre_ip_r_mgs.stdout_lines.0 else 4 }}"
17-
_lustre_ip_r_mgs_info: "{{ _lustre_ip_r_mgs.stdout_lines.0 | split }}"
18-
# first line e.g. "10.167.128.1 via 10.179.0.2 dev eth0 src 10.179.3.149 uid 1000"
15+
_lustre_ip_r_mgs_info: "{{ _lustre_ip_r_mgs.stdout | from_json }}"
1916

2017
- name: Write LNet configuration file
2118
template:
@@ -46,4 +43,4 @@
4643
state: "{{ (item.mount_state | default(lustre_mount_state)) }}"
4744
opts: "{{ item.mount_options | default(lustre_mount_options) }}"
4845
loop: "{{ lustre_mounts }}"
49-
46+

0 commit comments

Comments
 (0)