- name: Copy index.html to site directory
win_copy:
src: files/index.html
dest: "{{ ansible_iis_root}}\\{{ ansible_site_folder }}\\index.html"
foreach (website in websites) {
win_copy:
src: files/index.html
dest: "{{ ansible_iis_root}}\\{{ ansible_site_folder }}\\index.html"
}
- win_copy:
src: files/index.html
dest: '{{ ansible_iis_root }}\{{ item }}\index.html'
with_items:
- site 1
- site 2
What that syntax means is that it will run that task for each item/string that you define and substitute the variable {{ item }} with the current loop value. You can define the list beforehand as a variable and set with_items: '{{ iis_sites }}' if you want to drive it through config.
One thing to note, I would avoid using double quote when setting Windows paths, if you don't use quotes or just a single quote, you don't need to escape the backslashes which is easier to write.