# behavior of changing apt\_repository is to add a new line and preserving the old data

**URL:** <https://forum.ansible.com/t/behavior-of-changing-apt-repository-is-to-add-a-new-line-and-preserving-the-old-data/15564>\
**Category:** Ansible Project\
**Created:** [June 27, 2014, 10:50am UTC](https://forum.ansible.com/t/behavior-of-changing-apt-repository-is-to-add-a-new-line-and-preserving-the-old-data/15564 "2014-06-27T10:50:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhong\_ming\_wu](https://avatars.discourse-cdn.com/v4/letter/z/ee59a6/32.png) [@zhong\_ming\_wu](https://forum.ansible.com/u/zhong_ming_wu)\
**Post date:** [June 27, 2014, 10:50am UTC](https://forum.ansible.com/t/behavior-of-changing-apt-repository-is-to-add-a-new-line-and-preserving-the-old-data/15564/1 "2014-06-27T10:50:45Z")

</div>

I had the following

- name: add my repository  
apt\_repository: repo=“deb [http://repo.local.example.com/apt/u14](http://repo.local.example.com/apt/u14) abcd main”

Then I changed it to

- name: add my repository  
apt\_repository: repo=“deb [http://repo.local.example.com/apt/u14](http://repo.local.example.com/apt/u14) xyz main”

Ansible just add a new line to the existing file in

/etc/apt/sources.list.d/

Is there any case where this behavior makes sense? In my case, this breaks things because the server with ‘abcd’ distribution does not exist any more and ‘apt-get update’ fails

Z M Wu

---

<div class="post-metadata">

**Author:** ![Enrique\_Paredes](https://avatars.discourse-cdn.com/v4/letter/e/3bc359/32.png) [@Enrique\_Paredes](https://forum.ansible.com/u/Enrique_Paredes)\
**Post date:** [June 27, 2014, 2:44pm UTC](https://forum.ansible.com/t/behavior-of-changing-apt-repository-is-to-add-a-new-line-and-preserving-the-old-data/15564/2 "2014-06-27T14:44:15Z")

</div>

if you only want to add a file in /apt/sour

---

<div class="post-metadata">

**Author:** ![Enrique\_Paredes](https://avatars.discourse-cdn.com/v4/letter/e/3bc359/32.png) [@Enrique\_Paredes](https://forum.ansible.com/u/Enrique_Paredes)\
**Post date:** [June 27, 2014, 2:48pm UTC](https://forum.ansible.com/t/behavior-of-changing-apt-repository-is-to-add-a-new-line-and-preserving-the-old-data/15564/3 "2014-06-27T14:48:09Z")

</div>

if you want to add a file in apt/sources.d use the copy module instead.

I don’t know any other uses to add-apt-repository than adding ppas.

(sorry for the trucated previous message)
