Reorganize some bootstrap tasks

This commit is contained in:
Joshua Boniface 2023-09-01 15:42:19 -04:00
parent 0bf86fc5e8
commit 5cbce17bd1
5 changed files with 50 additions and 16 deletions

View File

@ -0,0 +1,16 @@
---
- name: add IP addresses to cluster interfaces
command: ip address add {{ item.cluster_ip }}/{{ item.cluster_cidr }} dev {{ pvc_cluster_device }}
delegate_to: "{{ item.hostname }}"
run_once: yes
ignore_errors: yes
with_items:
- "{{ pvc_nodes }}"
- name: add IP addresses to storage interfaces
command: ip address add {{ item.storage_ip }}/{{ item.storage_cidr }} dev {{ pvc_storage_device }}
delegate_to: "{{ item.hostname }}"
run_once: yes
ignore_errors: yes
with_items:
- "{{ pvc_nodes }}"

View File

@ -1,19 +1,12 @@
--- ---
- name: add IP addresses to cluster interfaces - name: stop the monitor daemon
command: ip address add {{ item.cluster_ip }}/{{ item.cluster_cidr }} dev {{ pvc_cluster_device }} service:
delegate_to: "{{ item.hostname }}" name: ceph-mon@{{ ansible_hostname }}
run_once: yes state: stopped
ignore_errors: yes ignore_errors: yes
with_items:
- "{{ pvc_nodes }}"
- name: add IP addresses to storage interfaces - name: reset any systemd failures
command: ip address add {{ item.storage_ip }}/{{ item.storage_cidr }} dev {{ pvc_storage_device }} command: systemctl reset-failed
delegate_to: "{{ item.hostname }}"
run_once: yes
ignore_errors: yes
with_items:
- "{{ pvc_nodes }}"
- block: - block:
- name: generate cluster FSID - name: generate cluster FSID
@ -102,7 +95,7 @@
- name: collect bootstrapped Ceph files into the role - name: collect bootstrapped Ceph files into the role
fetch: fetch:
src: /tmp/ceph-bootstrap/{{ item }} src: /tmp/ceph-bootstrap/{{ item }}
dest: roles/pvc/files/ceph/ dest: roles/pvc/files/ceph/{{ hostvars[inventory_hostname].group_names[0] }}/ceph/
flat: yes flat: yes
with_items: with_items:
- ceph.conf - ceph.conf
@ -120,7 +113,7 @@
- name: deploy out configurations to all nodes - name: deploy out configurations to all nodes
copy: copy:
src: ceph/{{ item }} src: ceph/{{ hostvars[inventory_hostname].group_names[0] }}/ceph/{{ item }}
dest: /etc/ceph/{{ item }} dest: /etc/ceph/{{ item }}
owner: ceph owner: ceph
group: ceph group: ceph

View File

@ -39,5 +39,8 @@
dest: /etc/ceph dest: /etc/ceph
state: directory state: directory
- include: add_cluster_ips.yml
when: newhost.changed
- include: bootstrap_ceph.yml - include: bootstrap_ceph.yml
when: newhost.changed when: newhost.changed

View File

@ -19,10 +19,12 @@
shell: "/usr/share/zookeeper/bin/zkCli.sh stat /nodes 2>&1 | grep -q 'Node does not exist'" shell: "/usr/share/zookeeper/bin/zkCli.sh stat /nodes 2>&1 | grep -q 'Node does not exist'"
register: cluster_init register: cluster_init
failed_when: no failed_when: no
run_once: yes
- name: bootstrap a fresh cluster - name: bootstrap a fresh cluster
shell: /usr/bin/pvc init shell: /usr/bin/pvc init
when: cluster_init.rc == 0 and ansible_local.host_id == 1 when: cluster_init.rc == 0
run_once: yes
- name: stop and disable unneccessary services - name: stop and disable unneccessary services
service: service:
@ -32,6 +34,9 @@
with_items: with_items:
- pdns.service - pdns.service
- include: remove_cluster_ips.yml
when: newhost.changed
- name: start and enable services - name: start and enable services
service: service:
name: "{{ item }}" name: "{{ item }}"

View File

@ -0,0 +1,17 @@
---
- name: remove IP addresses from cluster interfaces before starting PVC
command: ip address delete {{ item.cluster_ip }}/{{ item.cluster_cidr }} dev {{ pvc_cluster_device }}
delegate_to: "{{ item.hostname }}"
run_once: yes
ignore_errors: yes
with_items:
- "{{ pvc_nodes }}"
- name: remove IP addresses from storage interfaces before starting PVC
command: ip address delete {{ item.storage_ip }}/{{ item.storage_cidr }} dev {{ pvc_storage_device }}
delegate_to: "{{ item.hostname }}"
run_once: yes
ignore_errors: yes
with_items:
- "{{ pvc_nodes }}"