使用Ansible

时间:2017-07-29 09:45:04

标签: ansible

我有两个不同的nfs共享,并希望将它们安装在linux机器上。请提出任何其他可能性

-  name: mount the nfsshare in client side
     mount:
       fstype: nfs
       opts: defaults
       dump: 0
       passno: 0
       state: mounted
       src: 192.168.0.55:/nfsshare       ##one share
       src: 192.168.0.55:/nfsshare_2     ##second share
       path: "{{ item }}"
     with_items:
       - /mnt/nfs_mount               ##mount point 1
       - /mnt/nfs_mount2              ##mount point  2

输出必须是fstab:

192.168.0.55:/nfsshare  /mnt/nfs_mount defaults 0 0
192.168.0.55:/nfsshare_2  /mnt/nfs_mount_2  defaults 0 0

2 个答案:

答案 0 :(得分:0)

首先定义你的词典:

 <c:if test="${not empty message}">
          <p id="panel">${message}</p>
      </c:if>

然后循环:

nfsmounts:
  - {  path: "/mnt/nfs_mount", src: "192.168.0.55:/nfsshare" }
  - {  path: "/mnt/nfs_mount_2", src: "192.168.0.55:/nfsshare_2" }

如果需要,您可以使用dic来参数化- name: mount the nfsshare in client side mount: fstype: nfs opts: defaults dump: 0 passno: 0 state: mounted src: {{ item.src }} path: "{{ item.path }}" with_items: nfsmounts 任务的更多参数

答案 1 :(得分:0)

---
- hosts: all
  become: yes
  vars:
    nfsmounts:
      - {  path: "/mnt/nfs_mount", src: "192.168.0.55:/nfsshare" }
      - {  path: "/mnt/nfs_mount_2", src: "192.168.0.55:/nfsshare_2" }
  tasks:
      - name: mount the nfsshare in client side
        mount:
          fstype: nfs
          opts: defaults
          dump: 0
          passno: 0
          state: mounted
          src: "{{item.src}}"
          path: "{{item.path}}"
        with_items: "{{nfsmounts}}"