summaryrefslogtreecommitdiffstats
path: root/roles/glusterfs/tasks/migrate_volume.yml
blob: f9edeac5cc84883fc90c349c30046a00bbef1595 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- name: "Analyze bricks of {{ volume.key }}"
  shell: |
    gluster volume info '{{ volume.key }}' | grep -P 'Brick\d+:' | awk '{ print $2 }'
  register: gvires

- name: "Execute configured {{ migrate_action }} on volume {{ volume.key }} with bricks {{ src }} and {{ dst }}"
  include_tasks: "{{ migrate_action }}.yml"
  vars:
    bricks: "{{ gvires.stdout_lines | list }}"
    servers: "{{ bricks | map('regex_replace', ':.*$', '') | list }}"
    brick: "{{ servers.index(migrate_from) }}"
    src: "{{ bricks[brick | int] | default('') }}"
    dst: "{{ bricks[brick | int] | default('') | regex_replace('^' ~ migrate_from, migrate_to) }}"
    vol: "{{ volume.key }}"
  when:
    - migrate_from in servers
    - brick is defined