[owncloud-autofs] Configure automount
parent
2a0b488c15
commit
21d4aace4f
|
@ -9,25 +9,33 @@
|
|||
retries: 3
|
||||
until: apt_result is succeeded
|
||||
|
||||
#- name: Configure autofs deamon
|
||||
# template:
|
||||
# src: "{{ item }}.j2"
|
||||
# dest: "/etc/{{ item }}"
|
||||
# mode: 0644
|
||||
# loop:
|
||||
# - default/autofs
|
||||
# - auto.master
|
||||
# notify: Restart autofs service
|
||||
- name: Configure autofs deamon
|
||||
template:
|
||||
src: "{{ item }}.j2"
|
||||
dest: "/etc/{{ item }}"
|
||||
mode: 0644
|
||||
loop:
|
||||
- default/autofs
|
||||
- auto.master
|
||||
notify: Restart autofs service
|
||||
|
||||
#- name: Configure home-adh autofs
|
||||
# template:
|
||||
# src: "auto.master.d/{{ item.0 }}.j2"
|
||||
# dest: "/etc/auto.master.d/{{ item.0 }}"
|
||||
# mode: "{{ item.1 }}"
|
||||
# loop:
|
||||
# - ["home-adh.autofs", "0644"]
|
||||
# - ["home-adh.sh", "0755"]
|
||||
# notify: Restart autofs service
|
||||
- name: Configure home-adh autofs
|
||||
template:
|
||||
src: "auto.master.d/{{ item.0 }}.j2"
|
||||
dest: "/etc/auto.master.d/{{ item.0 }}"
|
||||
mode: "{{ item.1 }}"
|
||||
loop:
|
||||
- ["home-owncloud.autofs", "0644"]
|
||||
- ["home-owncloud.sh", "0755"]
|
||||
notify: Restart autofs service
|
||||
|
||||
- name: Create /home-owncloud/ directory
|
||||
file:
|
||||
path: /home-owncloud
|
||||
state: directory
|
||||
mode: 0750
|
||||
owner: www-data
|
||||
group: root
|
||||
|
||||
- name: Install autoclean cron
|
||||
template:
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
# {{ ansible_managed }}
|
||||
/home-owncloud /etc/auto.master.d/home-owncloud.sh -t60
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
# {{ ansible_managed }}
|
||||
|
||||
# Certains user dans owncloud ont été créés sous la forme user_1234 ce qui faisait planter le autofs
|
||||
# ceci est un fix
|
||||
USER=$(echo $1 | sed "s/_[1-9]*$//")
|
||||
|
||||
# On quitte si l'utilisateur $USER n'existe pas
|
||||
if ! /usr/bin/id -- "$USER" &>/dev/null; then
|
||||
logger -p local0.error -t autofs "user $USER n'existe pas"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
UHOME=$(eval echo ~$USER)
|
||||
UGROUP=$(/usr/bin/id -gn $USER)
|
||||
|
||||
# Rafraîchi les stats du dossier
|
||||
/bin/ls ${UHOME}/OwnCloud/ &>/dev/null || /bin/ls ${UHOME} &>/dev/null
|
||||
|
||||
# Création du dossier OwnCloud s'il n'existe pas ou n'appartient pas a l'utilisateur
|
||||
if [ ! -d "${UHOME}/OwnCloud" ] || ! (
|
||||
/usr/bin/find ${UHOME}/OwnCloud/ -maxdepth 0 -user $USER -group ${UGROUP} |
|
||||
/bin/grep -q ${UHOME}/OwnCloud/
|
||||
); then
|
||||
mkdir ${UHOME}/OwnCloud &&
|
||||
chmod 700 ${UHOME}/OwnCloud &&
|
||||
chown $USER:${UGROUP} ${UHOME}/OwnCloud
|
||||
|
||||
if [ ! -d "${UHOME}/OwnCloud" ] || ! (
|
||||
/usr/bin/find ${UHOME}/OwnCloud/ -maxdepth 0 -user $USER -group ${UGROUP} |
|
||||
/bin/grep -q ${UHOME}/OwnCloud/
|
||||
); then
|
||||
logger -p local0.error -t autofs "impossible de créer le dossier ${UHOME}/OwnCloud"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
logger -p local0.info -t autofs "Dossier ${UHOME}/OwnCloud créé"
|
||||
fi
|
||||
|
||||
chmod 750 /home-owncloud &&
|
||||
chown www-data:root /home-owncloud &&
|
||||
echo "-fstype=fuse.bindfs,map=$USER/www-data:@$UGROUP/@www-data,resolve-symlinks :${UHOME}/OwnCloud"
|
|
@ -0,0 +1,29 @@
|
|||
# {{ ansible_managed }}
|
||||
#
|
||||
# Sample auto.master file
|
||||
# This is a 'master' automounter map and it has the following format:
|
||||
# mount-point [map-type[,format]:]map [options]
|
||||
# For details of the format look at auto.master(5).
|
||||
#
|
||||
#/misc /etc/auto.misc
|
||||
#
|
||||
# NOTE: mounts done from a hosts map will be mounted with the
|
||||
# "nosuid" and "nodev" options unless the "suid" and "dev"
|
||||
# options are explicitly given.
|
||||
#
|
||||
#/net -hosts
|
||||
#
|
||||
# Include /etc/auto.master.d/*.autofs
|
||||
# The included files must conform to the format of this file.
|
||||
#
|
||||
+dir:/etc/auto.master.d
|
||||
#
|
||||
# Include central master map if it can be found using
|
||||
# nsswitch sources.
|
||||
#
|
||||
# Note that if there are entries for /net or /misc (as
|
||||
# above) in the included master map any keys that are the
|
||||
# same will not be seen as the first read key seen takes
|
||||
# precedence.
|
||||
#
|
||||
#+auto.master
|
|
@ -0,0 +1,15 @@
|
|||
#
|
||||
# Init system options
|
||||
# {{ ansible_managed }}
|
||||
#
|
||||
# If the kernel supports using the autofs miscellanous device
|
||||
# and you wish to use it you must set this configuration option
|
||||
# to "yes" otherwise it will not be used.
|
||||
#
|
||||
USE_MISC_DEVICE="yes"
|
||||
#
|
||||
# Use OPTIONS to add automount(8) command line options that
|
||||
# will be used when the daemon is started.
|
||||
#
|
||||
#OPTIONS=""
|
||||
#
|
Loading…
Reference in New Issue