# apt\_repository strikes back

**URL:** <https://forum.ansible.com/t/apt-repository-strikes-back/13176>\
**Category:** Ansible Project\
**Created:** [July 22, 2013, 11:13pm UTC](https://forum.ansible.com/t/apt-repository-strikes-back/13176 "2013-07-22T23:13:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander\_Saltanov](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Alexander\_Saltanov](https://forum.ansible.com/u/Alexander_Saltanov)\
**Post date:** [July 22, 2013, 11:13pm UTC](https://forum.ansible.com/t/apt-repository-strikes-back/13176/1 "2013-07-22T23:13:48Z")

</div>

Hi!

I’ve just made the second PR against apt\_repository. It has the same features as before, but now it has no additional dependences completely.  
Please feel free to grab it from my github repo at [https://github.com/sashka/ansible](https://github.com/sashka/ansible) or from PR itself: [https://github.com/ansible/ansible/pull/3630](https://github.com/ansible/ansible/pull/3630)

Let me know if it fails.

One note: I make no assumption on URL handling, so url with trailing slash and w/o trailing slash are treated as different URL.

Alexander.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 23, 2013, 12:20am UTC](https://forum.ansible.com/t/apt-repository-strikes-back/13176/2 "2013-07-23T00:20:16Z")

</div>

For those that do not remember this, I believe this no longer auto-adds deb-src URLs and works on more distributions.

Testing from Debian/Ubuntu users (and comments on the ticket) are much appreciated!

Thanks Alexander!

---

<div class="post-metadata">

**Author:** ![Kai\_Weber](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@Kai\_Weber](https://forum.ansible.com/u/Kai_Weber)\
**Post date:** [July 23, 2013, 1:08pm UTC](https://forum.ansible.com/t/apt-repository-strikes-back/13176/3 "2013-07-23T13:08:55Z")

</div>

❦ Alexander Saltanov \<alexander.saltanov@gmail.com\>:

> I've just made the second PR against apt\_repository. It has the same  
> features as before, but now it has no additional dependences completely.

Did not try it for now, but if I read the code correctly I wonder if it is  
a drop in replacement?

As far as I can see for every apt\_repository a own file in sources.list.d is  
created. If I added a repository with the current version it lands in  
sources.list. Is this considered? Does removing them from sources.list work  
with your solution?

---

<div class="post-metadata">

**Author:** ![Alexander\_Saltanov](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Alexander\_Saltanov](https://forum.ansible.com/u/Alexander_Saltanov)\
**Post date:** [July 23, 2013, 1:21pm UTC](https://forum.ansible.com/t/apt-repository-strikes-back/13176/4 "2013-07-23T13:21:20Z")

</div>

Yes, it works as drop-in replacement. It reads source specs from any valid source file (sources.list and sources.list.d/\*)

Only new sources (if it had never existed in sources.list) will be created in sources.list.d.

Maybe it would make sense to have an option to switch the behavior, but I'd rather go with one way.

I prefer sources.list.d as better maintainable way, but may be you know more contras than pros. Please let me know.

A.

---

<div class="post-metadata">

**Author:** ![Kai\_Weber](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@Kai\_Weber](https://forum.ansible.com/u/Kai_Weber)\
**Post date:** [August 6, 2013, 7:46pm UTC](https://forum.ansible.com/t/apt-repository-strikes-back/13176/5 "2013-08-06T19:46:28Z")

</div>

❦ Michael DeHaan \<michael@ansibleworks.com\>:

> Testing from Debian/Ubuntu users (and comments on the ticket) are much  
> appreciated!

I finally found some time to test the apt\_repository. I am very satisfied to  
not have to install another package (python-software-properties) to manage my  
apt configuration.

I did not find a problem. I tested adding and removing. I use it like this:

- name: Common | Setup empty sources.list  
&nbsp;&nbsp;template: src=sources.list.j2 dest=/etc/apt/sources.list  
&nbsp;&nbsp;tags: common

- name: Common | Add security repository  
&nbsp;&nbsp;apt\_repository: repo='deb [http://security.debian.org/](http://security.debian.org/) wheezy/updates main contrib non-free'  
&nbsp;&nbsp;tags: common

I'll add a comment to the pull request ticket.

---

<div class="post-metadata">

**Author:** ![Alexander\_Saltanov](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Alexander\_Saltanov](https://forum.ansible.com/u/Alexander_Saltanov)\
**Post date:** [August 6, 2013, 7:57pm UTC](https://forum.ansible.com/t/apt-repository-strikes-back/13176/6 "2013-08-06T19:57:09Z")

</div>

Thanks. I'll look into issue tomorrow morning CEST.

A.
