Hi, I'm trying to run a command when a file matching a regex does not exist.
My use case is I am unzipping an artifact - ec2-api-tools.zip This will unzip to a directory that includes the version number - e.g. ec2-api-tools-1.6.13.0 I want to check if there is a directory that matches the regex 'ec2-api-tools-*' and only run the unzip command if it doesn't exist. I don't want to tie the script to a particular version as it will change over time. This is the approach I took - - name: download ec2 command line tools command: chdir=~/tools wget http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip creates=ec2-api-tools.zip - name: Register if ec2 directory exists command: chdir=~/tools test -d ec2-api-tools-* ignore_errors: True register: ec2_tools_installed - name: unzip ec2-tools command: chdir=~/tools unzip ec2-api-tools.zip when: ec2_tools_installed.rc == 1 The problem is the 'test -d ec2-api-tools-*' always fails. The command passes fine if I run it from the machine itself. The script will work if I change the ec2-api-tools-* to match the exact version number. So what I'm wondering is - Why does the * in the 'test -d ec2-api-tools-*' command not work correctly? Is there a better way of accomplishing this that I'm just not seeing? I imagine it's a common enough use case. Thanks in advance, Michael -- 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-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d08978c0-2ce4-4051-8daf-28d5f85596c9%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.