Add role cephfs-mount with prerequisites
This commit is contained in:
parent
1949a2e307
commit
d72582a1bc
6 changed files with 99 additions and 0 deletions
6
Vagrantfile
vendored
6
Vagrantfile
vendored
|
@ -48,4 +48,10 @@ Vagrant.configure("2") do |config|
|
|||
end
|
||||
end
|
||||
|
||||
config.vm.define "cephfs-client" do |guest|
|
||||
guest.vm.box = "generic/ubuntu2204"
|
||||
guest.vm.hostname = "cephfs-client"
|
||||
guest.vm.network "private_network", ip: "10.0.0.31"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -4,6 +4,7 @@ ceph-mon-03 remote_user=vagrant
|
|||
ceph-osd-01 remote_user=vagrant
|
||||
ceph-osd-02 remote_user=vagrant
|
||||
ceph-osd-03 remote_user=vagrant
|
||||
cephfs-client remote_user=vagrant
|
||||
|
||||
[mons]
|
||||
ceph-mon-01
|
||||
|
|
|
@ -51,3 +51,12 @@
|
|||
- role: cephfs
|
||||
vars:
|
||||
fs_name: cephfs
|
||||
|
||||
- name: Mount CephFS filesystem on a client
|
||||
tags: mount
|
||||
hosts: cephfs-client
|
||||
roles:
|
||||
- role: cephfs-mount
|
||||
vars:
|
||||
fs_name: cephfs
|
||||
fs_user: cephfs
|
||||
|
|
4
roles/cephfs-mount/defaults/main.yml
Normal file
4
roles/cephfs-mount/defaults/main.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
|
||||
fs_name: cephfs
|
||||
fs_user: cephfs
|
13
roles/cephfs-mount/handlers/main.yml
Normal file
13
roles/cephfs-mount/handlers/main.yml
Normal file
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
|
||||
- name: Add new line to ceph conf
|
||||
become: true
|
||||
ansible.builtin.shell:
|
||||
cmd: echo >> /etc/ceph/ceph.conf
|
||||
changed_when: true
|
||||
|
||||
- name: Add new line to cephfs client keyring
|
||||
become: true
|
||||
ansible.builtin.shell:
|
||||
cmd: "echo >> /etc/ceph/ceph.client.{{ fs_user }}.keyring"
|
||||
changed_when: true
|
66
roles/cephfs-mount/tasks/main.yml
Normal file
66
roles/cephfs-mount/tasks/main.yml
Normal file
|
@ -0,0 +1,66 @@
|
|||
---
|
||||
|
||||
- name: Create ceph config directory
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: /etc/ceph
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "755"
|
||||
|
||||
- name: Generate minimal ceph configuration
|
||||
delegate_to: ceph-mon-01
|
||||
become: true
|
||||
ansible.builtin.command:
|
||||
cmd: ceph config generate-minimal-conf
|
||||
register: ceph_minimal_conf
|
||||
changed_when: false
|
||||
|
||||
- name: Write minimal ceph config
|
||||
become: true
|
||||
ansible.builtin.copy:
|
||||
content: "{{ ceph_minimal_conf.stdout }}"
|
||||
dest: /etc/ceph/ceph.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: "644"
|
||||
notify: Add new line to ceph conf
|
||||
|
||||
- name: Create CephX user and get its key
|
||||
delegate_to: ceph-mon-01
|
||||
become: true
|
||||
ansible.builtin.command:
|
||||
cmd: "sudo ceph fs authorize {{ fs_name }} client.{{ fs_user }} / rw"
|
||||
register: cephfs_user_keyring
|
||||
changed_when: false
|
||||
|
||||
- name: Write CephX user's key
|
||||
become: true
|
||||
ansible.builtin.copy:
|
||||
content: "{{ cephfs_user_keyring.stdout }}"
|
||||
dest: /etc/ceph/ceph.client.{{ fs_user }}.keyring
|
||||
owner: root
|
||||
group: root
|
||||
mode: "600"
|
||||
notify: Add new line to cephfs client keyring
|
||||
|
||||
- name: Make sure files are correctly formed
|
||||
ansible.builtin.meta: flush_handlers
|
||||
|
||||
- name: Create mount directory
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "/mnt/{{ fs_name }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "755"
|
||||
|
||||
- name: Mount the CephFS filesystem
|
||||
become: true
|
||||
ansible.posix.mount:
|
||||
fstype: ceph
|
||||
path: "/mnt/{{ fs_name }}"
|
||||
src: "{{ fs_user }}@.{{ fs_name }}=/"
|
||||
state: mounted
|
Loading…
Reference in a new issue