How can I use the mv module Ansible

Refresh

2 weeks ago

Views

9 time

1

I am trying to use the mv module on Ansible but I am not having luck.

In my initial attempt I did the following:

- name: changing the name of the file
  shell: mv /tmp/bundle /opt/Rocket.Chat

And I get the following error:

FAILED! => {"changed": true, "cmd": "mv /tmp/bundle /opt/Rocket.Chat", "delta": "0:00:00.033553", "end": "2019-02-11 06:06:43.273787", "msg": "non-zero return code", "rc": 1, "start": "2019-02-11 06:06:43.240234", "stderr": "mv: cannot move ‘/tmp/bundle’ to ‘/opt/Rocket.Chat/bundle’: File exists", "stderr_lines": ["mv: cannot move ‘/tmp/bundle’ to ‘/opt/Rocket.Chat/bundle’: File exists"], "stdout": "", "stdout_lines": []}

So, I changed it to:

   - name: create directory
       file:
         state: directory
         path: "/opt/Rocket.Chat"

   - name: copy the files
        copy:
          src: "/tmp/bundle"
          dest: "/opt/Rocket.Chat"
          remote_src: yes

    - name: delete the other files
        file: path=/tmp/bundle state=absent

My new error is:

FAILED! => {"changed": false, "msg": "Remote copy does not support recursive copy of directory: /tmp/bundle"}

1 answers

0

Попробуйте первую версию с:

become: true