Hope I have framed the title correctly. I am trying to loop over the first play using with_sequence and then use the output of the first play as the input of another, but the issue is the second play also uses a sequence. I can't get my around how I could achieve that.
create root directory
file:
path: dir{{ item }}
with_sequence: 1-6
register: outdirs
mount using above directory
mount:
state: mounted
src: xxxx{{ item }}
path: *outdirs.dir1*
fstype: nfs
with_sequence: 21-26
Thanks
CodePudding user response:
Use the results
from first task to loop on the next one and add your offset:
- name: Create root directory
file:
path: "dir{{ item }}"
state: directory
with_sequence: 1-6
register: outdirs
- name: Mount root dir
vars:
nfs_offset: 20
nfs_number: "{{ item.item | int nfs_offset | int }}"
mount:
state: mounted
src: "xxxx{{ nfs_number }}"
path: "{{ item.path }}"
fstype: nfs
loop: "{{ outdirs.results }}"