file ... directory only created on 2nd run

14 views
Skip to first unread message

dulh...@mailbox.org

unread,
Jan 21, 2022, 3:46:11 AM1/21/22
to ansible...@googlegroups.com
I have this TASK in a roles tasks/main.yml

it reliably (almost 100% of the occassions I'd say) fails to create the directory 'data' on the 1st run of the playbook.
Also with 100% reliabilty it succeeds with this on a 2nd run

- name: create db dirs
  file:
    path: "{{ db_base }}/{{ item }}"
    state: directory
    owner: root
  become: yes
  loop:
    - data
    - backup
 
 
a missing backup dir does not cause an error directly following playbook TASKS, bust still it seems to me it gets created on the first round most of the times.
any idea what could be causing such a behaviour?

Dick Visser

unread,
Jan 21, 2022, 4:27:41 AM1/21/22
to ansible...@googlegroups.com
Depends on what the actual failure is, you didn't provide any error details.

--
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/1143082708.698237.1642754754422%40office.mailbox.org.


--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

dulh...@mailbox.org

unread,
Jan 21, 2022, 5:19:33 AM1/21/22
to ansible...@googlegroups.com

On 01/21/2022 10:27 AM Dick Visser <dick....@geant.org> wrote:


Depends on what the actual failure is, you didn't provide any error details.
the file TASK itself messages sucessful execution

2022-01-21 10:45:26,850 p=1753880 u=gwagner n=ansible | TASK [resize_vgsys_mariadb : create mariadb 'backup' & 'data' dirs] *************************************************************************************************
2022-01-21 10:45:27,140 p=1753880 u=gwagner n=ansible | changed: [vm-51150-0198.intern] => (item=/opt/db/backup/mysql)
2022-01-21 10:45:27,383 p=1753880 u=gwagner n=ansible | changed: [vm-51150-0198.intern] => (item=/opt/db/data/mysql)

later on another TASK complains about the missing directory

TASK [mariadb_install : prepare install - cp my.cnf >> /opt/db/data/mysql/] *****************************************************************************************
failed: [vm-51150-0198.intern] (item=my.cnf) => changed=false
ansible_loop_var: item
item: my.cnf
msg: Destination directory /opt/db/data/mysql does not exist

Dick Visser

unread,
Jan 21, 2022, 5:41:59 AM1/21/22
to ansible...@googlegroups.com
Put a task just before that, with some debug for instance a directory listing so you can check if it's really there or permission issues etc 

Otherwise looks like a race condition in your playbook 

--
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.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Todd Lewis

unread,
Jan 21, 2022, 7:48:07 AM1/21/22
to Ansible Project
The output you posted - with items "/opt/db/backup/mysql" and "/opt/db/data/mysql" - is not from the task you posted previously. That task had items "backup" and "data".

Either you've inadvertently confused which steps are doing what, or you've left out relevant details in a kind but unsuccessful attempt to minimize your post for our benefit. If the latter, please, more detail is always better than more posts asking for additional detail.

It appears to me you've left out something, possibly relevant, between creation of /opt/db/{backup,data} and /opt/db/{backup,data}/mysql.
Reply all
Reply to author
Forward
0 new messages