Hi, 

I have a variables.yml file in which I store variables in this format:

patterns:
  - file: file_1.xml
    regexp: 17701
    replace: 17706
  - file: file_2.xml
    regexp: 17701
    replace: 17706
  - file: file_3.xml
    regexp: 17701
    replace: 17706

then, in my playbook I first import these variables:

    - name: Read pattern replaces from file and save them as variables
      include_vars: ~/path_to_file/variables.yml

and then do replaces on these files like this:

    - name: perform pattern replaces for files
      local_action:
        module: replace
        follow: yes
        path: '~/path_to_files/{{ item.file }}'
        regexp: '{{ item.regexp }}'
        replace: '{{ item.replace }}'
      with_items: 
        - "{{ patterns }}"

All works well, but I need to be able to specify files with regexp in the 
variables.yml file. Something like below:

patterns:
  - file: file_*.xml
    regexp: 17701
    replace: 17706
  - file: other_file.xml
    regexp: a
    replace: b

This will fail as replace module will output that 'file_*.xml' cannot be 
found

I can do this by using shell module and sed command but I'd really like to 
stick to using the correct modules instead of falling back to bash. Do you 
have any suggestion on how to achieve something like this?

thanks!
  

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fd53c05d-a718-4410-a487-7de108cf3a09%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to