I'm running Ansible 1.5.3 on Ubuntu 12.04 LTS
I've got the following two lines in one of my roles:
- name: Add brightbox repository
apt_repository: repo=ppa:brightbox/ruby-ng
- name: Install brightbox ruby
apt: pkg=ruby1.9.3 state=latest
This outputs the following (Note: abbreviated. Full error log shown below):
stderr: E: There are problems and -y was used without --force-yes
...
WARNING: The following packages cannot be authenticated!
libruby1.9.1 ruby1.9.1 ri1.9.1 ruby1.9.1-dev ruby1.9.1-examples
libruby1.9.1-dbg ruby1.9.1-full ruby1.9.3
This, I believe, is usually a sign that "apt-get update" has not been run - indeed going onto the box, manually running apt-get update, and then rerunning my playbook causes it to install successfully.
Thinking it might be a bug in the apt_repository code or documentation, I bought up a new copy of the server and changed the apt_respository to include the (default) value of true for the update_cache attribute:
- name: Add brightbox repository
apt_repository: repo=ppa:brightbox/ruby-ng update_cache=yes
This made no difference. But when I added update_cache to the apt command instead, it now worked:
- name: Install brightbox ruby
apt: pkg=ruby1.9.3 state=latest update_cache=yes
So I'm a little puzzled as to why the apt_repository command doesn't update the apt index in time to fix the following install task, but the apt take does manage to update the index in time ?
Obviously, I'd rather not update my apt index before every run on the apt module, and logically the only reason I am updating it is for the new repository I've added, so would prefer the apt_repository task to own that responsibility.
Regards,
Ben
FULL ERROR TRACE
==================
stderr: E: There are problems and -y was used without --force-yes
stdout: Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
libgudev-1.0-0 linux-headers-3.2.0-54 gir1.2-gudev-1.0 openjdk-7-jre-lib
linux-headers-3.2.0-54-virtual
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
libgoogle-perftools-dev libgoogle-perftools0 libreadline5 libruby1.9.1
libruby1.9.1-dbg libtcmalloc-minimal0 libunwind7 ri1.9.1 ruby1.9.1
ruby1.9.1-dev ruby1.9.1-examples ruby1.9.1-full
Suggested packages:
graphviz ruby-switch
The following NEW packages will be installed:
libgoogle-perftools-dev libgoogle-perftools0 libreadline5 libruby1.9.1
libruby1.9.1-dbg libtcmalloc-minimal0 libunwind7 ri1.9.1 ruby1.9.1
ruby1.9.1-dev ruby1.9.1-examples ruby1.9.1-full ruby1.9.3
0 to upgrade, 13 to newly install, 0 to remove and 0 not to upgrade.
Need to get 14.1 MB of archives.
After this operation, 48.3 MB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
libruby1.9.1 ruby1.9.1 ri1.9.1 ruby1.9.1-dev ruby1.9.1-examples
libruby1.9.1-dbg ruby1.9.1-full ruby1.9.3
msg: 'apt-get install 'ruby1.9.3' ' failed: E: There are problems and -y was used without --force-yes