1
0
IaC/ansible/roles/k8s_storage_deploy/tasks/main.yaml

101 lines
3.3 KiB
YAML
Raw Normal View History

2022-11-02 05:18:55 -04:00
---
2022-11-02 10:59:42 -04:00
- name: create target directory for rook files
ansible.builtin.file:
path: "{{ ansible_search_path[0] }}/files/rook"
state: directory
mode: 0775
2022-11-02 05:18:55 -04:00
2022-11-02 10:59:42 -04:00
- name: load rbd kernel module
become: true
delegate_to: "{{ item }}"
with_items: "{{ groups['k8s_worker'] }}"
community.general.modprobe:
name: rbd
state: present
2022-11-02 05:18:55 -04:00
2022-11-02 10:59:42 -04:00
- name: set rbd kernel module to load at boot
become: true
delegate_to: "{{ item }}"
with_items: "{{ groups['k8s_worker'] }}"
ansible.builtin.copy:
dest: /etc/modules-load.d/rbd.conf
content: rbd
owner: root
group: root
mode: 0660
2022-11-02 05:18:55 -04:00
2022-11-02 10:59:42 -04:00
- name: install lvm2 package
become: true
delegate_to: "{{ item }}"
with_items: "{{ groups['k8s_worker'] }}"
community.general.pacman:
name: lvm2
state: latest
update_cache: true
2022-11-02 05:18:55 -04:00
2022-11-02 10:59:42 -04:00
- name: download the rook manifests
ansible.builtin.uri:
url: https://raw.githubusercontent.com/rook/rook/{{ rook_version }}/deploy/examples/{{ item }}.yaml
dest: "{{ ansible_search_path[0] }}/files/rook/rook_{{ item }}_{{ rook_version }}.yaml"
creates: "{{ ansible_search_path[0] }}/files/rook/rook_{{ item }}_{{ rook_version }}.yaml"
mode: 0664
with_items:
- crds
- common
- operator
- cluster
2022-11-02 05:18:55 -04:00
2022-11-02 10:59:42 -04:00
- name: deploy the rook manifest # The order of the items is important, crds > common > operator , see https://github.com/rook/rook/blob/v1.10.4/deploy/examples/common.yaml
kubernetes.core.k8s:
src: "{{ ansible_search_path[0] }}/files/rook/rook_{{ item }}_{{ rook_version }}.yaml"
state: present
with_items:
- crds
- common
# - operator
2022-11-02 05:18:55 -04:00
2022-11-02 08:34:34 -04:00
# # TODO somehow turn this command:
# # kubectl -n rook-ceph get pod -o json | jq '.items[].status.containerStatuses[].ready'
# # into a gate, not proceeding until it returns true, and timing out at some limit, ~2m
2022-11-02 05:18:55 -04:00
2022-11-02 08:34:34 -04:00
# - name: read the default rook cluster config into memory
# ansible.builtin.slurp:
# src: "{{ ansible_search_path[0] }}/files/rook/rook_cluster_{{ rook_version }}.yaml"
# register: rook_file_raw
2022-11-02 05:18:55 -04:00
2022-11-02 08:34:34 -04:00
# - name: parse rook cluster settings from the file data
# ansible.builtin.set_fact:
# rook_default_cluster: "{{ rook_file_raw['content'] | b64decode | from_yaml }}"
2022-11-02 05:18:55 -04:00
2022-11-02 08:34:34 -04:00
# - name: update the rook cluster settings with desired changes
# ansible.utils.update_fact:
# updates:
# - path: rook_default_cluster.spec.storage.useAllDevices
# value: "{{ k8s_storage_all_devices }}"
# - path: rook_default_cluster.spec.storage.deviceFilter
# value: "{{ k8s_storage_device_filter }}"
# register: rook_updated_cluster
2022-11-02 05:18:55 -04:00
2022-11-02 08:34:34 -04:00
# - name: debug the updated rook cluster settings
# ansible.builtin.debug:
# var: rook_updated_cluster.rook_default_cluster
2022-11-02 05:18:55 -04:00
2022-11-02 08:34:34 -04:00
# - name: write the updated rook cluster settings out to file
# ansible.builtin.copy:
# content: "{{ rook_updated_cluster.rook_default_cluster | to_nice_yaml }}"
# dest: "{{ ansible_search_path[0] }}/files/rook/rook_cluster_modified.yaml"
2022-11-02 05:18:55 -04:00
2022-11-02 08:34:34 -04:00
# - name: apply the rook cluster manifest
# kubernetes.core.k8s:
# src: "{{ ansible_search_path[0] }}/files/rook/rook_cluster_modified.yaml"
# state: present
# TODO create a check and wait until cluster is created and running
2022-11-02 10:59:42 -04:00
# - name: create the storage providers
# kubernetes.core.k8s:
# src: "{{ ansible_search_path[0] }}/files/config/{{ item }}"
# state: present
# with_items:
# - blockpool_ssd_replica.yaml
# - filesystem_multi.yaml