0

So, this is ansible 2.10, and i'm trying to copy multiple files using with_items and it seems that it does not work. My tryout are more or less on the form of (this is a task):

---
- name: Sync md tools
ansible.builtin.copy:
dest: /root/bin/
src: "{{ playbook_dir }}/../additions/mdraid/{{ item }}"
with_items:
- mdadm_readd_dev
- md_check
owner: root
group: root
mode: '0700'
force: yes

I'm aware of ansible.posix.synchronize and of src_dir/ dst_dir/ format, but i would like to be able so specify a list. Is there a way to copy a specific list of multiple files with ansible.builtin.copy?

Adrian Sevcenco
  • 311
  • 1
  • 8
  • `it does not work` => can you please define what that means exactly ? Are you really running the example as is ? Because it is not a valid ansible task definition. – Zeitounator Mar 21 '21 at 19:57
  • ok, i found the solution here https://stackoverflow.com/a/36700613/624734 – Adrian Sevcenco Mar 21 '21 at 20:58
  • 1
    Please fix indentation in your question. Your issue looks like you're mixing task keyword `with_items` in the middle of module parameters. – zigarn Mar 22 '21 at 04:02
  • yup, it was an indentation problem that i finally noticed in my above posted link. thanks! – Adrian Sevcenco Mar 22 '21 at 08:29

1 Answers1

1

Bad syntax, ie. bad indentation. ansible-lint or ansible-playbook <playbook> -C would tell you more.

Jiri B
  • 361
  • 1
  • 12