Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Docker task fails if Docker version is another more recent version is already installed, i.e. Docker is going to be downgraded) #20

Closed
CristianCantoro opened this issue Apr 28, 2018 · 3 comments

Comments

@CristianCantoro
Copy link

CristianCantoro commented Apr 28, 2018

I am writing a playbook and running it several times, so Docker is alreay installed on my target machine.
In the playbook, other then ansible-docker I have another role to update packages. So Docker (I am using the ce edition) has been installed and automatically upgraded to 18.03.1 from channel stable:

$ dpkg -l 'docker*'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  docker-ce      18.03.1~ce-0 amd64        Docker: the open-source applicati

This is my playbook configuration:

docker_edition: "ce"
docker_channel: "stable"
docker_version: "18.03.0"

When I execute the playbook I get the following error:

TASK [ansible-docker : Install Docker]
***************************************** 
fatal: [host]: FAILED! =>
{"cache_update_time": 1524950924, "cache_updated": false, "changed": false,
"msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o
\"Dpkg::Options::=--force-confold\"     install 'docker-
ce=18.03.0~ce-0~ubuntu' -o APT::Install-Recommends=no' failed: E: Packages
were downgraded and -y was used without --allow-downgrades.\n", "rc": 100,
"stderr": "E: Packages were downgraded and -y was used without --allow-
downgrades.\n", "stderr_lines": ["E: Packages were downgraded and -y was used
without --allow-downgrades."], "stdout": "Reading package lists...\nBuilding
dependency tree...\nReading state information...\nRecommended packages:\n
aufs-tools cgroupfs-mount | cgroup-lite pigz\nThe following packages will be
DOWNGRADED:\n  docker-ce\n0 upgraded, 0 newly installed, 1 downgraded, 0 to
remove and 0 not upgraded.\n", "stdout_lines": ["Reading package lists...",
"Building dependency tree...", "Reading state information...", "Recommended
packages:", "  aufs-tools cgroupfs-mount | cgroup-lite pigz", "The following
packages will be DOWNGRADED:", "  docker-ce", "0 upgraded, 0 newly installed,
1 downgraded, 0 to remove and 0 not upgraded."]}

I am not even sure that this is a "proper" bug of this ansible role and I am not sure what should be the most reasonable expected behavior in this case. I am reporting it just to point out this behavior.

@nickjj
Copy link
Owner

nickjj commented Apr 28, 2018

Hi,

Currently Ansible doesn't support the --allow-downgrades option. Technically you could get around this by using force: True on the task that installs the package but I'm not sold on doing that.

In the mean time, the quickest way to get around this would be to run sudo apt-get remove --purge docker-ce on the box and then re-run this role.

@CristianCantoro
Copy link
Author

CristianCantoro commented Apr 29, 2018

@nickjj said:

In the mean time, the quickest way to get around this would be to run sudo apt-get remove --purge docker-ce on the box and then re-run this role.

That's what I did. Then I modified docker_version to "18.03.1".

@xamanu
Copy link

xamanu commented Jun 29, 2018

I also ran into the same problem as described here (see duplicate issue #26). Just an idea: Wouldn't it make sense to take the latest version from the repository as long as the variables docker_version and docker_compose_version are not set actively. At least this is what I naively expected 🤕

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants