From 75e5b6401c65da9de8ec4acee0dd54cabdcdb546 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 21 Jul 2014 20:40:58 -0500 Subject: [PATCH] Fixing up shell quoting issues --- library/commands/command | 29 ++++++++++++++----- .../roles/setup_ec2/tasks/main.yml | 2 +- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/library/commands/command b/library/commands/command index f61bd1f7dcc..69e8362bc7f 100644 --- a/library/commands/command +++ b/library/commands/command @@ -92,6 +92,24 @@ EXAMPLES = ''' creates: /path/to/database ''' +# This is a pretty complex regex, which functions as follows: +# +# 1. (^|\s) +# ^ look for a space or the beginning of the line +# 2. (creates|removes|chdir|executable|NO_LOG)= +# ^ look for a valid param, followed by an '=' +# 3. (?P[\'"])? +# ^ look for an optional quote character, which can either be +# a single or double quote character, and store it for later +# 4. (.*?) +# ^ match everything in a non-greedy manner until... +# 5. (?(quote)(?[\'"])?(.*?)(?(quote)(?. - name: generate random string - command: python -c \"import string,random; print ''.join(random.choice(string.ascii_lowercase) for _ in xrange(8));\" + command: python -c "import string,random; print ''.join(random.choice(string.ascii_lowercase) for _ in xrange(8));" register: random_string tags: - prepare