Skip to content

Commit 927e975

Browse files
committed
Adding logic to take case the /export/home mount before delting /export/home
DLPX-89763 DLPX-86523 delphix-platform changes PR URL: https://www.github.com/delphix/delphix-platform/pull/477
1 parent 7371dbd commit 927e975

File tree

2 files changed

+101
-3
lines changed
  • debian
  • files/common/var/lib/delphix-platform/ansible/10-delphix-platform/roles/delphix-platform/tasks

2 files changed

+101
-3
lines changed

debian/preinst

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash -eux
2+
#
3+
# Copyright 2024 Delphix
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
case $1 in
19+
upgrade)
20+
# Checking the fstab file if the /export/home entry
21+
# is present in the /etc/fstab, In case of container
22+
# upgrade the file is already changed by the
23+
# container-upgrade script and we dont need to do
24+
# it again.
25+
fs_tab=/etc/fstab
26+
auto_master=/etc/auto.master
27+
28+
if grep -q "\/export\/home" "$fs_tab"; then
29+
sed -i 's|/export/home|/home|g' "$fs_tab"
30+
mount /home
31+
fi
32+
33+
if [[ -e $auto_master ]]; then
34+
if grep -q "\/home\s+auto_home\s+-nobrowse" "$auto_master"; then
35+
sed -i 's|/home auto_home -nobrowse|#/home auto_home -nobrowse|g' "$auto_master"
36+
systemctl restart autofs
37+
fi
38+
fi
39+
40+
passwd_file=/etc/passwd
41+
if grep -q "\/export\/home" "$passwd_file"; then
42+
sed -i 's/\/export\/home/\/home/g' /etc/passwd
43+
fi
44+
45+
;;
46+
esac
47+
48+
exit 0

files/common/var/lib/delphix-platform/ansible/10-delphix-platform/roles/delphix-platform/tasks/main.yml

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# it below; otherwise that task will fail.
2323
#
2424
- file:
25-
path: /export/home
25+
path: /home
2626
state: directory
2727
mode: 0755
2828

@@ -35,7 +35,7 @@
3535
shell: /bin/bash
3636
create_home: yes
3737
comment: Delphix User
38-
home: /export/home/delphix
38+
home: /home/delphix
3939

4040
#
4141
# In order for this locale to be used (e.g. by virtualization) we need
@@ -635,7 +635,7 @@
635635
636636
- name: Source bash completion
637637
blockinfile:
638-
dest: "/export/home/delphix/.bashrc"
638+
dest: "/home/delphix/.bashrc"
639639
block: |
640640
. /etc/bash_completion.d/systemctl
641641
. /etc/bash_completion.d/zfs
@@ -684,3 +684,53 @@
684684
path: /etc/environment
685685
state: absent
686686
regexp: '^\s*PATH\s*='
687+
688+
#
689+
# Soft link creation in case it doesn't exist
690+
#
691+
- name: Check export
692+
ansible.builtin.stat:
693+
path: /export
694+
register: export_status
695+
696+
- name: Check export home
697+
ansible.builtin.stat:
698+
path: /export/home
699+
when: export_status.stat.exists and export_status.stat.isdir
700+
register: export_home_status
701+
702+
#
703+
# Before deleting the /export/home directory if the
704+
# home data set is mounted on /export/home if its
705+
# mounted remove if first and then go ahead.
706+
#
707+
- name: Check if the path is mounted
708+
ansible.builtin.shell: |
709+
mount | grep /export/home
710+
register: mount_status
711+
ignore_errors: yes
712+
713+
- name: Unmount the path if it is mounted
714+
ansible.builtin.mount:
715+
path: /export/home
716+
state: unmounted
717+
when: mount_status.rc == 0
718+
719+
- name: Delete home directory
720+
ansible.builtin.file:
721+
path: /export/home
722+
state: absent
723+
when: not export_status.stat.exists or export_home_status.stat.exists and export_home_status.stat.isdir
724+
725+
- name: Create export directory
726+
ansible.builtin.file:
727+
path: /export
728+
state: directory
729+
mode: 0755
730+
when: not export_status.stat.exists
731+
732+
- name: Create the soft link
733+
ansible.builtin.file:
734+
src: /home
735+
dest: /export/home
736+
state: link

0 commit comments

Comments
 (0)