# Move files?

**URL:** <https://forum.ansible.com/t/move-files/14165>\
**Category:** Ansible Project\
**Created:** [December 16, 2013, 9:10pm UTC](https://forum.ansible.com/t/move-files/14165 "2013-12-16T21:10:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Jeffrey](https://avatars.discourse-cdn.com/v4/letter/m/6de8d8/32.png) [@Michael\_Jeffrey](https://forum.ansible.com/u/Michael_Jeffrey)\
**Post date:** [December 16, 2013, 9:10pm UTC](https://forum.ansible.com/t/move-files/14165/1 "2013-12-16T21:10:24Z")

</div>

I am a complete newbie to Ansible and I’m piloting the tool at our company by writing a patching update playbook.

I am trying to move all \*repo files in /etc/yum.repos.d to /etc/yum.repos.d/off so we can put our own custom repo file in place there. I know we can disable repos with the yum module, but we have a lot of custom repo files out in the directory on the servers, so I’d like to just move them all to ‘off’ and be done with it.

Is there a way to /bin/mv /etc/yum.repos.d/\*repo /etc/yum.repos.d/off?

Also, if anyone has any tips/advice on pointing to a custom repo site and doing a yum update (and rebooting)… 🙂

–Michael

---

<div class="post-metadata">

**Author:** ![Timothy\_Gerla](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@Timothy\_Gerla](https://forum.ansible.com/u/Timothy_Gerla)\
**Post date:** [December 16, 2013, 9:17pm UTC](https://forum.ansible.com/t/move-files/14165/2 "2013-12-16T21:17:41Z")

</div>

Hi Michael,

To literally answer your question, you probably just want to do something like:

- name: create directory  
file: path=/etc/yum.repos.d/off/ state=directory

- name: move repo files out of the way  
command: mv /etc/yum.repos.d/\*.repo /etc/yum.repos.d/off/ creates=/etc/yum.repos.d/

The creates= argument will cause the task to be skipped if the path specified already exists.

But maybe instead of just moving the repos files out of the way, you could use yum-config-manager instead?

[http://docs.fedoraproject.org/en-US/Fedora/16/html/System\_Administrators\_Guide/sec-Managing\_Yum\_Repositories.html](http://docs.fedoraproject.org/en-US/Fedora/16/html/System_Administrators_Guide/sec-Managing_Yum_Repositories.html)

You could combine this with the creates= or removes= option to the command: call, too, if you can figure out which paths to reference.

-Tim

---

<div class="post-metadata">

**Author:** ![Michael\_Jeffrey](https://avatars.discourse-cdn.com/v4/letter/m/6de8d8/32.png) [@Michael\_Jeffrey](https://forum.ansible.com/u/Michael_Jeffrey)\
**Post date:** [December 17, 2013, 4:16pm UTC](https://forum.ansible.com/t/move-files/14165/3 "2013-12-17T16:16:39Z")

</div>

I tried mv with ‘command’ and it was squawking at /etc/yum.repos.d/\*repo (error: could not stat file) like it wasn’t wildcarding the asterisk. Using ‘shell’ appears to work OK.

I learned if there is no file to move, it errors, but I can throw ignore\_errors at it. I’m learning. 🙂

I’ll look into yum-config-manager. The hard part is each system is unique and configured differently, so that’s why I decided to use the hammer and just move all/any yum repos out of the way and start fresh. 🙂

MJ

---

<div class="post-metadata">

**Author:** ![Timothy\_Gerla](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@Timothy\_Gerla](https://forum.ansible.com/u/Timothy_Gerla)\
**Post date:** [December 17, 2013, 4:18pm UTC](https://forum.ansible.com/t/move-files/14165/4 "2013-12-17T16:18:08Z")

</div>

Sorry, my bad–“command” doesn’t let you use shell wildcards and stuff, but “shell” does, as you found. 🙂

-Tim

---

<div class="post-metadata">

**Author:** ![tannerjc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tannerjc/32/985_2.png) [@tannerjc](https://forum.ansible.com/u/tannerjc)\
**Post date:** [December 17, 2013, 4:19pm UTC](https://forum.ansible.com/t/move-files/14165/5 "2013-12-17T16:19:46Z")

</div>

- shell: if [-f /thepath/\*]; then \<move\_command\>; fi

---

<div class="post-metadata">

**Author:** ![Michael\_Jeffrey](https://avatars.discourse-cdn.com/v4/letter/m/6de8d8/32.png) [@Michael\_Jeffrey](https://forum.ansible.com/u/Michael_Jeffrey)\
**Post date:** [December 17, 2013, 9:02pm UTC](https://forum.ansible.com/t/move-files/14165/6 "2013-12-17T21:02:31Z")

</div>

Thanks, Tim & James. I appreciate the help for this newbie.

-MJ
