Lio*_*ion 4 smb centos ansible
我需要挂载一个 smb 共享才能访问 Ansible 中的大型共享安装文件。这使用 CLI 工作:
- name: Mount share
become: yes
shell: "mount.cifs {{ smb_share.path }} {{ smb_share.mount_point }} -o user={{ smb_share.user }},password={{ smb_share.password }},mfsymlinks,exec"
Run Code Online (Sandbox Code Playgroud)
但是,这有两个缺点:
mountmountAnsible 中有一个模块。但由于此共享仅用于安装并使用凭据,因此我不想永久安装它。该boot参数看起来是我需要的,遗憾的是不适用于 Linux:
Determines if the filesystem should be mounted on boot.
Only applies to Solaris systems.
Run Code Online (Sandbox Code Playgroud)
我仍然尝试设置,boot: no但如文档中所述,它仍然/etc/fstab使用纯文本密码创建一个条目。
是否有任何替代方法可以使用任何 Ansible 模块在 CentOS 7 上临时安装 Windows 共享?
我不知道 ansible 中存在一些临时挂载特定模块。但是从文档中,您可以通过以下方式使用mount模块:
- name: Mount network share
mount:
src: //path/to/windows/share
path: /mnt
fstype: cifs
opts: 'username=example@domain,password=Password1!'
state: mounted
become: true
- name: Unmount network share
mount:
path: /mnt
state: absent
become: true
Run Code Online (Sandbox Code Playgroud)
第一个任务state=mounted将在/etc/fstab 中创建记录并挂载该网络共享,第二个任务state=absent可以用来卸载挂载的共享并从/etc/fstab 中删除相应的记录。这是我想到的最佳选择。
| 归档时间: |
|
| 查看次数: |
2328 次 |
| 最近记录: |