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

Normalize share and volume creation #86

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions playbooks/ansible/cluster-cephfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ ctdb_network_public_interface_name: "eth2"
samba_netbios_name: "SIT-CEPHFS-TEST"

samba_shares:
- cluster_volume: "samba"
share_name: "share"
- name: share
samba:
options:
"acl_xattr:ignore system acls": "yes"
6 changes: 2 additions & 4 deletions playbooks/ansible/cluster-glusterfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ ctdb_cluster_replica_count: "{{ config.groups['cluster']|length }}"
samba_netbios_name: "SIT-GLUSTERFS-TEST"

samba_shares:
- cluster_volume: "vol-replicate"
share_name: "replicate"
- name: vol-replicate
samba:
options:
"acl_xattr:ignore system acls": "yes"
Expand All @@ -90,8 +89,7 @@ samba_shares:
performance.readdir-ahead: 'on'
performance.parallel-readdir: 'on'

- cluster_volume: "vol-disperse"
share_name: "disperse"
- name: vol-disperse
samba:
options:
"acl_xattr:ignore system acls": "yes"
Expand Down
6 changes: 3 additions & 3 deletions playbooks/ansible/cluster-xfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ ctdb_network_public_interface_name: "eth2"
samba_netbios_name: "SIT-XFS-TEST"

samba_shares:
- cluster_volume: "samba"
share_name: "share"
device: "/dev/vdb"
- name: share
samba:
options:
"acl_xattr:ignore system acls": "yes"
xfs:
device: "/dev/vdb"
8 changes: 4 additions & 4 deletions playbooks/ansible/roles/client.prep/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

- name: Create backend mount points
file:
path: "{{ config.paths.mount }}/backends/{{ item.share_name }}-{{ config.be.name }}-{{ config.be.variant }}"
path: "{{ config.paths.mount }}/backends/{{ item.name }}"
state: directory
with_items: "{{ samba_shares }}"

- name: Make the backend filesystems accessible from the client
command: >-
sshfs -o reconnect
root@{{ config.groups['cluster'][0] }}:{{ config.paths.mount }}/{{ item.cluster_volume }}
{{ config.paths.mount }}/backends/{{ item.share_name }}-{{ config.be.name }}-{{ config.be.variant }}
root@{{ config.groups['cluster'][0] }}:{{ config.paths.mount }}/{{ item.name }}
{{ config.paths.mount }}/backends/{{ item.name }}
with_items: "{{ samba_shares }}"

- name: Create the test-info.yml file with test cluster information
Expand All @@ -35,6 +35,6 @@
private_interfaces: "{{ ctdb_network_private_interfaces }}"
public_interfaces: "{{ ctdb_network_public_interfaces }}"
exported_sharenames: >-
{{ samba_shares | map(attribute='share_name') |
{{ samba_shares | map(attribute='name') |
map('regex_replace', '$', '-' + config.be.name + '-' + config.be.variant) | list }}
test_backend: "{{ config.be.name }}"
7 changes: 3 additions & 4 deletions playbooks/ansible/roles/ctdb.setup/tasks/cephfs/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
name: 'sit.{{ config.be.name }}'
tasks_from: new_volume
vars:
volume:
name: "ctdb"
path: "{{ ctdb_lock_path }}"
mode: "0777"
name: "ctdb"
path: "{{ ctdb_lock_path }}"
mode: "0777"
13 changes: 7 additions & 6 deletions playbooks/ansible/roles/ctdb.setup/tasks/glusterfs/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
name: 'sit.{{ config.be.name }}'
tasks_from: new_volume
vars:
name: "{{ ctdb_cluster_volume }}"
path: "{{ ctdb_lock_path }}"
mount_opts: "_netdev,transport=tcp,xlator-option=*client*.ping-timeout=10"
volume:
name: "{{ ctdb_cluster_volume }}"
type: "replicate"
backends: "{{ ctdb_brick_location }}/ctdb"
subvolume_size: "{{ ctdb_cluster_replica_count }}"
mount: "{{ ctdb_lock_path }}"
mount_opts: "_netdev,transport=tcp,xlator-option=*client*.ping-timeout=10"
glusterfs:
type: "replicate"
bricks: "{{ ctdb_brick_location }}/ctdb"
subvolume_size: "{{ ctdb_cluster_replica_count }}"

- name: SELinux - Allow CTDB to access recovery lockfile from FUSE mount
seboolean:
Expand Down

This file was deleted.

8 changes: 0 additions & 8 deletions playbooks/ansible/roles/samba.setup/tasks/glusterfs/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,3 @@
yum:
name: samba-vfs-glusterfs
state: present

- name: Mount glusterfs using fuse mount and set world writable permissions
include_tasks:
file: "glusterfs/fix_share_permissions.yml"
vars:
volume: "localhost:/{{ item.cluster_volume }}"
with_items: "{{ samba_shares }}"
run_once: true
46 changes: 24 additions & 22 deletions playbooks/ansible/roles/samba.setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

- name: Create Samba share directories
file:
path: "{{ config.paths.mount }}/{{ item.cluster_volume }}"
path: "{{ config.paths.mount }}/{{ item.name }}"
state: directory
mode: 0777
loop: "{{ samba_shares }}"
Expand Down Expand Up @@ -47,28 +47,30 @@
group: root
mode: '0644'

- name: Add share configuration
block:
- name: Create the share configuration using backend
include_role:
name: 'sit.{{ config.be.name }}'
tasks_from: new_share.yml
vars:
volume: "{{ item.cluster_volume }}"
path: "{{ config.paths.mount }}/{{ item.cluster_volume }}"
file: "{{ config.paths.samba.etc }}/smb.shares/{{ name }}.conf"
options: "{{ item.samba.options }}"
with_items: "{{ samba_shares }}"

- name: Include share configuration into smb.conf
lineinfile:
path: "{{ config.paths.samba.etc }}/smb.conf"
line: "include = {{ config.paths.samba.etc }}/smb.shares/{{ name }}.conf"
insertafter: EOF
with_items: "{{ samba_shares }}"
- name: Create the share configuration using backend
include_role:
name: 'sit.{{ config.be.name }}'
tasks_from: new_share.yml
vars:
name: '{{ item.share_name }}-{{ config.be.name }}-{{ config.be.variant }}'
name: "{{ item.name }}"
path: "{{ config.paths.mount }}/{{ item.name }}"
file: "{{ config.paths.samba.etc }}/smb.shares/{{ item.name }}.conf"
volume: "{{ item }}"
with_items: "{{ samba_shares }}"

- name: Set mount permissions
file:
path: "{{ config.paths.mount }}/{{ item.name }}"
mode: 0777
with_items: "{{ samba_shares }}"

- name: Include share configuration into smb.conf
lineinfile:
path: "{{ config.paths.samba.etc }}/smb.conf"
line: "include = {{ config.paths.samba.etc }}/smb.shares/{{ item.name }}.conf"
insertafter: EOF
with_items: "{{ samba_shares }}"

- name: Update selinux contexts
command: restorecon -R "{{ config.paths.mount }}/{{ item.cluster_volume }}"
command: restorecon -R "{{ config.paths.mount }}/{{ item.name }}"
loop: "{{ samba_shares }}"

This file was deleted.

8 changes: 0 additions & 8 deletions playbooks/ansible/roles/samba.setup/tasks/xfs/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
---
- name: Make shares world writable
include_tasks:
file: "xfs/fix_share_permissions.yml"
vars:
path: "{{ config.paths.mount }}/{{ item.cluster_volume }}"
volume: "{{ item.device }}"
with_items: "{{ samba_shares }}"
run_once: true
10 changes: 0 additions & 10 deletions playbooks/ansible/roles/sit.cephfs/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,3 @@
{{ ceph_conf.stdout }}

{{ ceph_auth.stdout }}

- name: Create Ceph subvolumes for samba shares
include_tasks:
file: new_volume.yml
vars:
volume:
name: "{{ item.share_name }}-{{ config.be.name }}-{{ config.be.variant }}"
path: "{{ config.paths.mount }}/{{ item.cluster_volume }}"
mode: "0777"
loop: "{{ samba_shares }}"
4 changes: 4 additions & 0 deletions playbooks/ansible/roles/sit.cephfs/tasks/new_share.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
- name: Create the CephFS subvolume
include_tasks:
file: new_volume.yml

- name: Get the subvolume's path
command: >
/root/cephadm shell --
Expand Down
11 changes: 6 additions & 5 deletions playbooks/ansible/roles/sit.cephfs/tasks/new_volume.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@
- name: Create the CephFS subvolume
command: >
/root/cephadm shell --
ceph fs subvolume create sit_fs {{ volume.name }}
--mode {{ volume.mode | default('0755') }}
ceph fs subvolume create sit_fs {{ name }}
--mode {{ mode | default('0755') }}
run_once: true

- name: Wait until subvolume is ready
command: /root/cephadm shell -- ceph fs subvolume info sit_fs {{ volume.name }}
command: /root/cephadm shell -- ceph fs subvolume info sit_fs {{ name }}
register: ceph_status
until: ceph_status.stdout | from_json | json_query("state") == "complete"
retries: 100
delay: 1
run_once: true

- name: Get the subvolume's path
command: >
/root/cephadm shell --
ceph fs subvolume getpath sit_fs {{ volume.name }}
ceph fs subvolume getpath sit_fs {{ name }}
run_once: true
register: ceph_subvol

- name: Create the mount
mount:
path: "{{ volume.path }}"
path: "{{ path }}"
fstype: ceph
opts: "conf=/etc/ceph/sit.ceph.conf,name=sit"
src: "{{ config.nodes[config.groups['cluster'][0]].networks.private }}:6789:{{ ceph_subvol.stdout }}"
Expand Down
14 changes: 5 additions & 9 deletions playbooks/ansible/roles/sit.cephfs/templates/smb_share.conf.j2
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
[{{ name }}]
comment = For samba share of subvolume {{ volume }}
[{{ name }}-{{ config.be.name }}-{{ config.be.variant }}]
comment = Volume '{{ name }}' from {{ config.be.name }}({{ config.be.variant }})
vfs objects = acl_xattr
{%- if config.be.variant == 'vfs' %} ceph
ceph:config_file = /etc/ceph/sit.ceph.conf
ceph:user_id = sit
{%- endif +%}
browseable = yes
read only = no
{%- if config.be.variant == 'vfs' +%}
path = {{ subvol }}
{%- else +%}
path = {{ path }}
{%- endif +%}
{%- if options is defined +%}
{%- for option, value in options.items() +%}
browseable = yes
read only = no
{%- for option, value in volume.samba.options.items() | default([]) +%}
{{ option }} = {{ value }}
{%- endfor +%}
{%- endif +%}
12 changes: 0 additions & 12 deletions playbooks/ansible/roles/sit.glusterfs/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,3 @@

- name: Ensure glusterd service is enabled
service: name=glusterd state=started enabled=yes

- include_tasks:
file: new_volume.yml
vars:
volume:
name: "{{ item.cluster_volume }}"
type: "{{ item.glusterfs.type }}"
backends: "{{ item.glusterfs.bricks }}"
subvolume_size: "{{ item.glusterfs.subvolume_size }}"
options: "{{ item.glusterfs.options }}"
mount: "{{ config.paths.mount }}/{{ item.cluster_volume }}"
with_items: "{{ samba_shares }}"
4 changes: 4 additions & 0 deletions playbooks/ansible/roles/sit.glusterfs/tasks/new_share.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
- name: Create the GlusterFS volume
include_tasks:
file: new_volume.yml

- name: Create share config file
template:
src: "smb_share.conf.j2"
Expand Down
28 changes: 14 additions & 14 deletions playbooks/ansible/roles/sit.glusterfs/tasks/new_volume.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@
- name: Create Replicate Volumes
gluster_volume:
state: present
name: "{{ volume.name }}"
bricks: "{{ volume.backends }}"
name: "{{ name }}"
bricks: "{{ volume.glusterfs.bricks }}"
cluster: "{{ config.groups['cluster'] }}"
replicas: "{{ volume.subvolume_size }}"
replicas: "{{ volume.glusterfs.subvolume_size }}"
run_once: yes
when: volume.type == 'replicate'
when: volume.glusterfs.type == 'replicate'

- name: Create Dispersed Volumes
gluster_volume:
state: present
name: "{{ volume.name }}"
bricks: "{{ volume.backends }}"
name: "{{ name }}"
bricks: "{{ volume.glusterfs.bricks }}"
cluster: "{{ config.groups['cluster'] }}"
disperses: "{{ volume.subvolume_size }}"
disperses: "{{ volume.glusterfs.subvolume_size }}"
force: yes
run_once: yes
when: volume.type == 'disperse'
when: volume.glusterfs.type == 'disperse'

- name: Set volume options
gluster_volume:
state: present
name: "{{ volume.name }}"
options: "{{ volume.options }}"
name: "{{ name }}"
options: "{{ volume.glusterfs.options }}"
run_once: yes
when: volume.options is defined
when: volume.glusterfs.options is defined

- name: Mount volume
mount:
path: "{{ volume.mount }}"
src: "localhost:/{{ volume.name }}"
path: "{{ path }}"
src: "localhost:/{{ name }}"
fstype: glusterfs
opts: "{{ volume.mount_opts | default(omit) }}"
opts: "{{ mount_opts | default(omit) }}"
state: mounted
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
[{{ name }}]
comment = For samba share of volume {{ volume }}
[{{ name }}-{{ config.be.name }}-{{ config.be.variant }}]
comment = Volume '{{ name }}' from {{ config.be.name }}({{ config.be.variant }})
vfs objects = acl_xattr glusterfs
glusterfs:volume = {{ volume }}
glusterfs:volume = {{ name }}
glusterfs:logfile = /var/log/samba/{{ name }}.%M.log
glusterfs:loglevel = 7
path = /
read only = no
{%- if options is defined +%}
{%- for option, value in options.items() +%}
{%- for option, value in volume.samba.options.items() | default([]) +%}
{{ option }} = {{ value }}
{%- endfor +%}
{%- endif +%}
6 changes: 0 additions & 6 deletions playbooks/ansible/roles/sit.xfs/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
---
- name: Create the XFS filesystem
filesystem:
dev: "{{ item.device }}"
force: true
fstype: xfs
loop: "{{ samba_shares }}"
Loading
Loading