0

Can't copy files ,because I get this error "Not a directory"

- name: Copy file with owner and permissions
  copy:
    src: files/
    dest: /opt/day/scripts
    owner: author
    group: aem
    mode: '0744'
    force: yes        

What could be the cause of that? What does that mean?

WhoAmI
  • 1,013
  • 2
  • 9
  • 19

1 Answers1

0

Copy the file in templates directory and Consider using the following ansible module

- name: transfer the scripts
  template:
    src: "{{ item }}"
    dest: "{{ destination_dir_path }}/{{ item | basename }}"
    mode: 0777
    owner: author
    group: aem
  with_fileglob:
    - templates/*.*
  • Directory structure of role
$ ls 
ls
defaults  tasks  templates
  • You would need to copy the files to the template directory. Let me know if this helps.
codeaprendiz
  • 2,703
  • 1
  • 25
  • 49
  • Doesn't fileglob copy only files, without folders? – WhoAmI Jul 10 '20 at 14:56
  • yes,but also [copy](https://docs.ansible.com/ansible/latest/modules/copy_module.html) copies the files from local to remote machines. If you want directories to be created, then consider using [file](https://docs.ansible.com/ansible/latest/modules/file_module.html) module – codeaprendiz Jul 10 '20 at 15:01