- hosts: all
remote_user: deepcompute
become: true
become_method: sudo
tasks:
- name: Adding SSH key
authorized_key:
user: deepcompute
state: present
manage_dir: yes
key: "{{lookup('file','/home/deepcompute/personal/test_class/data.pub')}}"
- name: Adding mount point in fstab
lineinfile:
path: /etc/fstab
line: "user@machine1.servers.nferx.com:/home/deepcompute/hpcentraldata/ /example_mount/ fuse.sshfs _netdev,user,idmap=user,transform_symlinks,identityfile=/home/deepcompute/.ssh/id_rsa,allow_other,default_permissions,reconnect,ServerAliveInterval=20,ServerAliveCountMax=5,uid=1000,gid=1000 0 0"
- name: Mount Directory Example
file:
path: /example_mount
state: directory
notify:
- Change Permission
handlers:
- name: Change Permission
file:
path: /example_mount
owner: user
group: user
state: directory
notify:
- Add mount point
- name: Add mount point
mount:
path: /example_mount
src: user@machine2.servers.nferx.com:/home/deepcompute/hpcentraldata
fstype: ext4
state: mounted
opts: bind
因此在上面的脚本中,我将在新服务器中创建一个安装点。
答案 0 :(得分:0)
使用mount模块。
- mount:
src: 'user@machine1.servers.nferx.com:/home/deepcompute/hpcentraldata/'
name: '/example_mount/'
fstype: 'fuse.sshfs'
opts: '_netdev,user,idmap=user,transform_symlinks,identityfile=/home/deepcompute/.ssh/id_rsa,allow_other,default_permissions,reconnect,ServerAliveInterval=20,ServerAliveCountMax=5,uid=1000,gid=1000'