offending line appears to be state: directory

26 views
Skip to first unread message

Tony Wong

unread,
Jun 14, 2020, 1:34:42 PM6/14/20
to ansible...@googlegroups.com
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:

David Shrewsbury

unread,
Jun 15, 2020, 8:54:37 AM6/15/20
to ansible...@googlegroups.com
'register' indented too much on your 'stat' task


--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CALmkhkqJZ0_6yfqenCcS__XseHg_VZd3paV0%3Da6kOP0PVndAyg%40mail.gmail.com.

Md Asiful Haque

unread,
Jun 17, 2020, 2:19:14 AM6/17/20
to ansible...@googlegroups.com
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

Reply all
Reply to author
Forward
0 new messages