yaegashi / ansible-role-blockinfile

Ansible role which contains blockinfile module
97 stars 18 forks source link

blockinfile with_items #17

Open vbotka opened 8 years ago

vbotka commented 8 years ago

Hello, I have hard time to figure out how to get the blocks properly formatted.

With the task

- name: Configure Direcotries in {{apache_conf_path}}/httpd.conf
  blockinfile:
    dest: "{{apache_conf_path}}/httpd.conf"
    backup: "yes"
    marker: "# {mark} ANSIBLE MANAGED BLOCK"
    insertafter: "# <Directory> blocks below."
    block: |
      {{item}}
  with_items: "{{apache_Directory_blocks}}"

and variable

apache_Directory_blocks:                                                                                                             
  - <Directory "/usr/local/www/roundcube">                                                                                           
      Options Indexes FollowSymLinks                                                                                                 
    </Directory>                                                                                                                     

I see the the block in one line

<Directory "/usr/local/www/roundcube"> Options Indexes FollowSymLinks </Directory>

What am I missing? Thank you for your effort!

-vlado

matty87a commented 6 years ago

i realise this is a year late - but i believe the var should be set as:

apache_Directory_blocks:
   - |                                                                                                          
<Directory "/usr/local/www/roundcube">                                                                                           
      Options Indexes FollowSymLinks                                                                                                 
</Directory>