Ansible查找卷磁盘名称

时间:2016-02-28 09:36:08

标签: ansible ansible-playbook

我试图编写一个剧本来格式化某个音量,但我无法选择正确的音频

这是我正在做的事情

---
- hosts: all
  gather_facts: no
  remote_user: root
  tasks:
  - name: create file system on storage lun
    filesystem: fstype=xfs  dev=/dev/mapper/mpath* 

我尝试在mpath之后匹配任何一个角色,但*似乎没有效果。

1 个答案:

答案 0 :(得分:3)

通配符在那里不起作用。您需要在其他任务中或从设置模块中获取此信息。

示例:

- command: ls /dev/mapper/mpath*
  register: mapper
- filesystem: fstype=xfs dev="{{ mapper.stdout_lines[0] }}"

没有测试过上述内容,但这是一般的想法。