pvc-ansible/roles/pvc/tasks/main.yml

96 lines
2.1 KiB
YAML

---
# Set this_node fact
- set_fact:
this_node: "{{ inventory_hostname.split('.')[0] }}"
tags: always
# Set coordinator state fact
- set_fact:
is_coordinator: "{% for node in pvc_nodes if node.hostname == this_node %}{{ node.is_coordinator }}{% endfor %}"
tags: always
# First-run check
- name: check if this is a new instance
shell: "echo 'bootstrapped' > /etc/pvc-install.pvc"
args:
creates: /etc/pvc-install.pvc
register: newhost_check
tags: always
- name: set newhost fact
set_fact:
newhost: yes
when: newhost_check.changed
tags: always
- include: common/add_cluster_ips.yml
when: newhost is defined and newhost
tags: always
# Install system tweaks
- include: system/main.yml
tags: pvc-system
# Install base databases (coordinators only)
- include: ceph/main.yml
tags: pvc-ceph
when: is_coordinator
- include: zookeeper/main.yml
tags: pvc-zookeeper
when: is_coordinator
- include: patroni/main.yml
tags: pvc-patroni
when: is_coordinator
# Install core services
- include: libvirt/main.yml
tags: pvc-libvirt
- include: frr/main.yml
tags: pvc-frr
# Install PVC daemon
- include: pvc/main.yml
tags: pvc-daemon
# Install CPU tuning
- include: cputuning/main.yml
tags: pvc-cputuning
when: debian_version|int >= 11 and cpu_tuning is defined
- block:
- name: restart server on first install
reboot:
post_reboot_delay: 30
reboot_timeout: 1800
- name: wait 90 seconds for system to stabilize
pause:
seconds: 90
become: no
connection: local
- name: restart pvcnoded on first install
service:
name: pvcnoded
state: restarted
throttle: 1
ignore_errors: yes
- name: wait 30 seconds for system to stabilize
pause:
seconds: 30
become: no
connection: local
- name: set first node as primary coordinator on first install
command: "pvc node primary --wait {{ ansible_play_hosts[0].split('.')[0] }}"
run_once: yes
delegate_to: "{{ ansible_play_hosts[0] }}"
when: newhost is defined and newhost
tags: always