Initial commit
This commit is contained in:
61
ansible/roles/linstor_cluster/tasks/main.yml
Normal file
61
ansible/roles/linstor_cluster/tasks/main.yml
Normal file
@@ -0,0 +1,61 @@
|
||||
---
|
||||
# tasks file for linstor_cluster
|
||||
|
||||
- name: Safely manage LINSTOR cluster nodes in /etc/hosts
|
||||
ansible.builtin.blockinfile:
|
||||
path: /etc/hosts
|
||||
marker: "# {mark} ANSIBLE MANAGED BLOCK - LINSTOR CLUSTER"
|
||||
block: |
|
||||
# Linstor Cluster Nodes (Primary: Private Network)
|
||||
{% for host in groups['proxmox'] %}
|
||||
{{ hostvars[host].priv_ip }} {{ host }}
|
||||
{% endfor %}
|
||||
|
||||
# Linstor Cluster Nodes (Fallback: Public Network)
|
||||
{% for host in groups['proxmox'] %}
|
||||
{{ hostvars[host].ansible_host }} {{ host }}-public
|
||||
{% endfor %}
|
||||
|
||||
- name: Ensure /etc/linstor directory exists
|
||||
ansible.builtin.file:
|
||||
path: /etc/linstor
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Deploy linstor-client.conf
|
||||
ansible.builtin.template:
|
||||
src: linstor-client.conf.j2
|
||||
dest: /etc/linstor/linstor-client.conf
|
||||
mode: '0644'
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# LINSTOR NODE REGISTRATION (Executed ONLY on Node 1)
|
||||
# ---------------------------------------------------------
|
||||
|
||||
- name: Register nodes in LINSTOR
|
||||
ansible.builtin.shell: |
|
||||
set -o pipefail
|
||||
if ! linstor node list | grep -q " {{ item }} "; then
|
||||
linstor node create "{{ item }}" "{{ hostvars[item].priv_ip }}" --node-type Combined > /dev/null
|
||||
echo "changed"
|
||||
fi
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: linstor_cluster_node_create
|
||||
changed_when: "'changed' in linstor_cluster_node_create.stdout"
|
||||
loop: "{{ groups['proxmox'] }}"
|
||||
when: inventory_hostname == groups['proxmox'][0]
|
||||
|
||||
- name: Configure Multipath Fallback Interfaces
|
||||
ansible.builtin.shell: |
|
||||
set -o pipefail
|
||||
if ! linstor node interface list "{{ item }}" | grep -q " fallback "; then
|
||||
linstor node interface create "{{ item }}" fallback "{{ hostvars[item].ansible_host }}" > /dev/null
|
||||
echo "changed"
|
||||
fi
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: linstor_cluster_int_create
|
||||
changed_when: "'changed' in linstor_cluster_int_create.stdout"
|
||||
loop: "{{ groups['proxmox'] }}"
|
||||
when: inventory_hostname == groups['proxmox'][0]
|
||||
Reference in New Issue
Block a user