Hello the list,

I have  a bunch of machines with some shared file systems. Some of the file 
systems are not mounted on all the machines. For the filesystems that are 
mounted, I'd like to check/create a bunch of symbolic links to those 
filesystems from various places in the filesystem. Some filesystems do not 
have links (yet) but we may do some other things with them later.

So given a YAML inventory file:

all:
  vars:
    filesystems:
      /sharedfs1:
        - source: /sharedfs1/filesets/home
          target: /home
        - source: /sharedfs1/filesets/foo
          target: /opt/foo
        - source: /sharedfs1/filesets/baa
          target: /opt/baa
        - source: /sharedfs1/filesets/lmod
          target: /opt/lmod
        - source: /scale_wlg_persistent/filesets/baz
          target: /quack/baz
     /sharedfs2:
        - source: /sharedfs2/filesets/scratch
          target: /quack/scratch
      /sharedfs3:
      /sharedfs4:
  children:
    hostlist:
      hosts:
        host1:
        host2:

And the following play, which checks the mount point exists

---
- name: Create links to filesets from shared filesystems
  hosts: all
  tasks:
    - name: Check filesystems are mounted
      stat:
        path: "{{ item.key }}"
      register: fsstat
      loop: "{{ filesystems|dict2items }}"

    - name: Which filesystem mount exists?
      debug:
        var: fsstat.stat.path
      when: item.0.stat.path == item.1.key
      loop: "{{ fsstat.results|product(filesystems|dict2items)|list }}"

Now what I want to do for each filesystem mount that exists, I'd like to 
create a link from source to target for each list of link hashes associated 
with each filesystem. Doing this in Python is almost trivial, but a massive 
pain in Ansible/Jinja2

Regards,

Aaron



-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f4f54a75-30c8-4b0d-9ede-79400db6ac96%40googlegroups.com.

Reply via email to