list all files in directory and copy all content.

15 views
Skip to first unread message

Vincent Nambatac

unread,
Jul 19, 2021, 9:42:49 PM7/19/21
to Ansible Project

Hi there , I want to ask what approach  I will do If I want to copy all content in an unzip files. I unzip the files and list all directories. the problem is I want to copy all files inside the directory but only 1 content being copied. Can somebody how to it. Here is my code.


  - name: "Unzip zookeeper package {{ zookeeper_installation_package }} "
    unarchive:
      src: "{{ zookeeper_install_package_host_folder }}/{{ zookeeper_installation_package }}"
      dest: "{{ zookeeper_install_package_host_folder }}"
      list_files: yes
      remote_src: yes
    register: unarchived_list


  - name: Removing {{ zookeeper_install_package_host_folder }}/{{ zookeeper_installation_package }}
    file:
      path: "{{ zookeeper_install_package_host_folder }}/{{ zookeeper_installation_package }}"
      state: absent

  - name: Create symbolic link {{ zookeeper_sym_link }} for {{zookeeper_install_package_host_folder}}/{{ unarchived_list.files[0] }}
    file:
      src: "{{zookeeper_install_package_host_folder}}/{{ unarchived_list.files[0] }}"
      dest: "/opt/zookeeper"
      state: link


--- in the Create symbolic link Task I want to copy all content in my unzip file which is zookeeper.tar and make a symbolic link with it using all the content to /opt/zookeeper directory.



Screenshot from 2021-07-20 09-40-10.png

In this case , only docs directory being copied . instead all the content .


Best regards,
Vincent

Vincent Nambatac

unread,
Jul 19, 2021, 9:49:06 PM7/19/21
to Ansible Project
I suspect what would be the right value in this unarchived_list.files[0] to input to copy all directories. When I tried another number like 1,2,3 only those another directories there are being copied .
Reply all
Reply to author
Forward
0 new messages