offending line appears to be state: directory

any idea what is wrong with my playbook here?

  • name: Retrieve info about the mount directory
    stat:
    path: “{{ mount_dir_path }}”
    register: mount_dir_stat_first
    tags:
  • prereqs

If the mount directory doesn’t already exist it is created

  • name: Create the mount directory
    become: yes
    become_method: yes
    file:
    path: “{{ mount_dir_path }}”
    state: directory
    mode: 0777
    become: yes
    become_method: sudo
    when: mount_dir_stat_first.stat.exists == False
    tags:
  • prereqs

We run stat again to get info about the mount directory post-creation. This info will be used

within when statements to make sure that the directory exists and isn’t already being used.

It’s a crude check and I would like to devise a better method.

  • name: Retrieve info about the mount directory
    stat:
    path: “{{ mount_dir_path }}”
    register: mount_dir_stat_created
    tags:

  • prereqs

  • name: Mount the ISO
    mount:
    path: “{{ mount_dir_path }}”
    src: “{{ repo_dir }}/{{ vcsa_iso}}”
    fstype: iso9660
    opts: ro,noauto
    state: mounted
    become: yes
    become_method: sudo
    when: mount_dir_stat_created.stat.wusr == True
    tags:

‘register’ indented too much on your ‘stat’ task

Can you try wih this. And if there is any error please the details error you can try with -vv flag while running the playbook.

# If the mount directory doesn't already exist it is created
- name: Create the mount directory
file:
path: "{{ mount_dir_path }}"
state: directory
mode: 0777
become: yes
become_method: sudo
when: mount_dir_stat_first.stat.exists == False
tags:
- prereqs