How to move rename a file using an Ansible task on a remote system

0 votes

Hi Guys,

I have some files in the remote system. I want to move those files when a particular task will run. How can I control that?

Sep 17, 2020 in Ansible by akhtar
• 38,260 points
20,508 views

1 answer to this question.

0 votes

Hi@akhtar,

You can use the command module to move your files. But before running that task, you should check if the file is present or not as shown below.

- name: state check
  stat: path=/path/to/foo
  register: foo_stat
- name: Move foo to bar
  command: mv /path/to/foo /path/to/bar
  when: foo_stat.stat.exists
answered Sep 17, 2020 by MD
• 95,460 points

Related Questions In Ansible

0 votes
1 answer

How to overwrite the content of a file in remote systems using Ansible playbook?

Hi@akhtar, You can find one argument in the ...READ MORE

answered Aug 2, 2020 in Ansible by MD
• 95,460 points
14,401 views
0 votes
1 answer

How to create a new encrpted file using Ansible Vault?

If you are creating a new file ...READ MORE

answered Jan 29, 2019 in Ansible by Kyraa
1,026 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,034 views
+2 votes
1 answer
0 votes
1 answer

How to start httpd service in a remote system using Ansible?

Hi@akhtar, Ansible has a module named service. This ...READ MORE

answered Jul 30, 2020 in Ansible by MD
• 95,460 points
3,368 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP