Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sit.cephfs: Add proxy enbaled shares with vfs_ceph_new(non-mgr) #128

Merged
3 changes: 3 additions & 0 deletions playbooks/ansible/roles/ctdb.setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
- name: Enable samba management by ctdb
command: '{{ config.paths.ctdb.bin }}/ctdb event script enable legacy 50.samba'

- name: Configure libcephfs_proxy socket path for smbd
command: systemctl set-environment LIBCEPHFSD_SOCKET=/run/samba/libcephfsd.sock

- name: Restart ctdb
service: name=ctdb state=restarted enabled=yes

Expand Down
11 changes: 11 additions & 0 deletions playbooks/ansible/roles/samba.setup/files/smbd_connect_proxy.te
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

module smbd_connect_proxy 1.0;

require {
type smbd_t;
type unconfined_t;
class unix_stream_socket connectto;
}

#============= smbd_t ==============
allow smbd_t unconfined_t:unix_stream_socket connectto;
40 changes: 11 additions & 29 deletions playbooks/ansible/roles/samba.setup/tasks/cephfs/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,15 @@
line: "CTDB_SAMBA_SKIP_SHARE_CHECK=yes"
state: present

- name: Temporarily allow cap_dac_override for smbd from SELinux
block:
- name: Remove any existing policy package
command: semodule -r smbd_dac_override
failed_when: false

- name: Copy required type enforcement file
copy:
src: smbd_dac_override.te
dest: /tmp

- name: Compile SELinux module file
command: checkmodule -M -m -o smbd_dac_override.mod smbd_dac_override.te
args:
chdir: /tmp
# We create the socket under /run/samba/ to avoid SELinux AVC denial
# https://github.com/samba-in-kubernetes/sit-environment/pull/128#issuecomment-2624527331
- name: Run libcephfsd for proxy
shell: LIBCEPHFSD_SOCKET=/run/samba/libcephfsd.sock nohup /usr/sbin/libcephfsd &> /var/log/ceph/libcephfsd.log &

- name: Build SELinux policy package
command: semodule_package -o smbd_dac_override.pp -m smbd_dac_override.mod
args:
chdir: /tmp

- name: Load SELinux policy package
command: semodule -i smbd_dac_override.pp
args:
chdir: /tmp

- name: Remove temporary policy files
file:
path: /tmp/smbd_dac_override.*
state: absent
- name: Temporarily allow cap_dac_override for smbd from SELinux
include_tasks: custom_selinux_policy.yml
vars:
module_name: "{{ item }}"
with_items:
- smbd_dac_override
- smbd_connect_proxy
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
- name: Remove any existing policy package
command: semodule -r "{{ module_name }}"
failed_when: false

- name: Copy required type enforcement file
copy:
src: "{{ module_name }}.te"
dest: /tmp

- name: Compile SELinux module file
command: checkmodule -M -m -o "{{ module_name }}.mod" "{{ module_name }}.te"
args:
chdir: /tmp

- name: Build SELinux policy package
command: semodule_package -o "{{ module_name }}.pp" -m "{{ module_name }}.mod"
args:
chdir: /tmp

- name: Load SELinux policy package
command: semodule -i "{{ module_name }}.pp"
args:
chdir: /tmp

- name: Remove temporary policy files
file:
path: "/tmp/{{ module_name }}.*"
state: absent
32 changes: 3 additions & 29 deletions playbooks/ansible/roles/samba.setup/tasks/xfs/main.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,5 @@
---
- name: Temporarily allow cap_dac_override for smbd from SELinux
block:
- name: Remove any existing policy package
command: semodule -r smbd_dac_override
failed_when: false

- name: Copy required type enforcement file
copy:
src: smbd_dac_override.te
dest: /tmp

- name: Compile SELinux module file
command: checkmodule -M -m -o smbd_dac_override.mod smbd_dac_override.te
args:
chdir: /tmp

- name: Build SELinux policy package
command: semodule_package -o smbd_dac_override.pp -m smbd_dac_override.mod
args:
chdir: /tmp

- name: Load SELinux policy package
command: semodule -i smbd_dac_override.pp
args:
chdir: /tmp

- name: Remove temporary policy files
file:
path: /tmp/smbd_dac_override.*
state: absent
include_tasks: custom_selinux_policy.yml
vars:
module_name: smbd_dac_override
8 changes: 8 additions & 0 deletions playbooks/ansible/roles/sit.cephfs/tasks/git/centos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@
name:
- libcephfs-devel
- librados-devel
state: present

- name: Install CephFS proxy components
yum:
name:
- libcephfs-proxy2
- libcephfs-daemon
state: present
7 changes: 7 additions & 0 deletions playbooks/ansible/roles/sit.cephfs/tasks/repo/centos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
name: samba-vfs-cephfs
state: present

- name: Install CephFS proxy components
yum:
name:
- libcephfs-proxy2
- libcephfs-daemon
state: present

- name: Install CTDB RADOS helper
when: config.data.ctdb_mutex == 'rados'
yum:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ vfs objects = acl_xattr ceph_snapshots
{%- endif %} {{ vfs }}
{{ vfs }}:config_file = /etc/ceph/sit.ceph.conf
{{ vfs }}:user_id = sit
{%- if method == 'vfs-new-proxy' +%}
{{ vfs }}:proxy = yes
{%- endif +%}
path = {{ subvol }}
{%- else +%}
path = {{ path }}
Expand Down
2 changes: 1 addition & 1 deletion playbooks/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ environments:
data:
branch: main
ctdb_mutex: rados
methods: ['kclient', 'vfs', 'vfs-new']
methods: ['kclient', 'vfs', 'vfs-new', 'vfs-new-proxy']

nodes:
setup:
Expand Down
Loading