NEWB howto modify /etc/apt/sources.list

747 views
Skip to first unread message

Tim Jabaut

unread,
Apr 22, 2015, 9:20:04 AM4/22/15
to ansible...@googlegroups.com
I am new to Ansible and looking for a simple way to modify the /etc/apt/sources.list file in Debian to include the contrib repo.

I seem to find ways to pull a file down, but how does one edit an existing conf file?

Brian Coca

unread,
Apr 22, 2015, 11:29:13 AM4/22/15
to ansible...@googlegroups.com
I would advise using the apt_repository module, template or even copy
modules, but for existing files you might need to use lineinfile.

--
Brian Coca

Tim Jabaut

unread,
Apr 22, 2015, 1:03:40 PM4/22/15
to ansible...@googlegroups.com
So Brian I am trying apt_repositoy but getting errors.

If I am using Debian Wheezy and want to add the non-free repo, I would expect that I should use the following ad-hoc statement:

ansible test -m apt_repository -a ‘repo=deb http://ftp.us.debian.org/debian/ wheezy main contrib state=present'

This produces an error about parameters, so I tried the following as well:

ansible test -m apt_repository -a ‘repo="deb http://ftp.us.debian.org/debian/ wheezy main contrib" state=present'

Also does not work... Any suggestions?

Serge van Ginderachter

unread,
Apr 22, 2015, 1:07:13 PM4/22/15
to ansible...@googlegroups.com

On 22 April 2015 at 19:03, Tim Jabaut <tja...@gmail.com> wrote:
I am trying apt_repositoy but getting errors.


​it might help to paste those exact errors

Tim Jabaut

unread,
Apr 22, 2015, 1:42:15 PM4/22/15
to ansible...@googlegroups.com
I would be happy too; however; I am not able to cut and paste from a Fusion window, and if I ssh into my Ansible control node the environment variable for Ansible is not persistant.

Any suggestions?

Serge van Ginderachter

unread,
Apr 22, 2015, 1:46:48 PM4/22/15
to ansible...@googlegroups.com

On 22 April 2015 at 19:42, Tim Jabaut <tja...@gmail.com> wrote:
Any suggestions?


​a link to a screen​shot?

Tim Jabaut

unread,
Apr 22, 2015, 2:00:36 PM4/22/15
to ansible...@googlegroups.com
1)
root@ansibleControl:~# ansible mediaserver -m apt_repository -a ‘repo=deb http://ftp.us.debian.org/debian/ wheezy main contrib state=present'
> ^C

2)
root@ansibleControl:~# ansible mediaserver -m apt_repository -a 'repo=deb http://ftp.us.debian.org/debian/ wheezy main contrib non-free state=present'
192.168.154.243 | FAILED >> {
    "failed": true,
    "msg": "this module requires key=value arguments (['repo=deb', 'http://ftp.us.debian.org/debian/', 'wheezy', 'main', 'contrib', 'non-free', 'state=present'])"
}

Tim Jabaut

unread,
Apr 22, 2015, 2:12:49 PM4/22/15
to ansible...@googlegroups.com
So this works, or at least reports that it was successful:

root@ansibleControl:~# ansible mediaserver -m apt_repository -a "repo='deb http://ftp.us.debian.org/debian/ wheezy main contrib non-free' state=present"
192.168.154.243 | success >> {
    "changed": false,
    "repo": "deb http://ftp.us.debian.org/debian/ wheezy main contrib non-free",
    "state": "present"
}

However when I goto the .243 server the non-free repo is not listed.

Serge van Ginderachter

unread,
Apr 22, 2015, 2:15:39 PM4/22/15
to ansible...@googlegroups.com

On 22 April 2015 at 20:00, Tim Jabaut <tja...@gmail.com> wrote:
​​
ansible mediaserver -m apt_repository -a 'repo=deb http://ftp.us.debian.org/debian/ wheezy main contrib non-free state=present'

​your quoting is bad here

​​ansible mediaserver -m apt_repository -a 'repo="deb http://ftp.us.debian.org/debian/ wheezy main contrib non-free" state=present'

Tim Jabaut

unread,
Apr 22, 2015, 2:18:28 PM4/22/15
to ansible...@googlegroups.com
right, so the following does not throw an error: 

ansible mediaserver -m apt_repository -a "repo='deb http://ftp.us.debian.org/debian/ wheezy main contrib non-free' state=present"

but it does not change anything either.
Reply all
Reply to author
Forward
0 new messages