Search code examples
shellansiblemv

Using Ansible to move subdirectories and files in a given path to a parent


I need to move files from /var/www/html/internal/packages.confluent.io/rpm/5.5 to /var/www/html/internal

I am using the below script to perform the move. I also trtied it with command in stead of shell

The below script moves the files from under the 5.5 directory to /var/www/html/internal/5.5. I need them to be under /var/www/html/internal

- name: Move confluent packages to /var/www/html/internal
  command: mv /var/www/html/internal/packages.confluent.io/rpm/5.5 /var/www/html/internal/
  when: internal_stat.stat.exists

How should I formulate the command to make sure the files and subdirectories are moved under /var/www/html/internal and not /var/www/html/internal/5.5 ?

Thanks


Solution

  • I was doing

    mv /var/www/html/internal/packages.confluent.io/rpm/5.5/*.* /var/www/html/internal/

    that was not copying the subdirectories only files. It seems I have to do

    mv /var/www/html/internal/packages.confluent.io/rpm/5.5/* /var/www/html/internal/.

    Initially I had thought that wouldn't copy the files, only directories, but this seems to work for both files and directories. This does not move the . files, I will research that later