- name: Configure /etc/hosts
  template:
    dest: /etc/hosts
    src: hosts.j2

- name: Configure nftables
  template:
    dest: /etc/nftables.d/ceph.nft
    src: ceph.nft.j2
    mode: 0644
  notify: reload nftables

- name: Set up NTP servers
  lineinfile:
    path: /etc/systemd/timesyncd.conf
    regexp: '^#?NTP='
    line: 'NTP={{ ntp | join(" ") }}'
  notify: restart systemd-timesyncd

- name: Generate my SSH key
  openssh_keypair:
    path: /root/.ssh/id_ed25519
    type: ed25519
    comment: "root@{{ inventory_hostname }}"
  register: my_key

- name: Deploy my key on other nodes
  authorized_key:
    user: root
    key: "{{ my_key.public_key }}"
    comment: "{{ my_key.comment }}"
  delegate_to: "{{ item }}"
  loop: "{{ nodes | map(attribute='inventory_hostname') }}"

- name: Install required packages
  package:
    name:
      - lvm2
      - podman

- name: Install cephadm script
  get_url:
    url: https://download.ceph.com/rpm-{{ ceph_version }}/el9/noarch/cephadm
    checksum: '{{ cephadm_checksum }}'
    dest: /usr/local/bin/cephadm
    mode: 0755

- include_tasks: cert.yml