7

E405 v4.0.0 Remote package tasks should have a retry Package operations are unreliable as they require network communication and the availability of remote servers. To mitigate the potential problems, retries should be used via register: my_result and until: my_result | success

This shows up when running ansible-lint as the following error:

[405] Remote package tasks should have a retry
plays/sample.yml:31
Task/Handler: Install list of packages

Given the sample code:

- name: Install list of packages
  apt:
    name: [jq, vim, curl, unzip, dnsutils]
    state: present

How to solve this?

Richard Slater
  • 11,612
  • 6
  • 41
  • 81
030
  • 13,235
  • 16
  • 74
  • 173

2 Answers2

8

ansible-lint warning 405 can be quite irritating as in certain cases, i.e. when running locally retrying is very unlikely to make any difference. Actually resolving it is normally simply a case of adding the following:

register: task_result
until: task_result is success
retries: 10
delay: 2

When this is added to task Ansible will retry ten times with a delay of two seconds between each retry until the returncode is 0.

Richard Slater
  • 11,612
  • 6
  • 41
  • 81
  • 2
    Seems like an extremely nitpicky rule to me... there are some cases where this would be nice to have, but in the real world I think I've seen this on package-related tasks maybe < 1% of the time. Which is why I've opened 405 Remote package tasks should have a retry - too nitpicky? – geerlingguy Jan 04 '19 at 03:35
  • I don’t think it’s too nit picky - I find more often than not I add extra lines just to appease Ansible-lint rather than to deliver value, this seems wrong. Retry by default seems sensible. – Richard Slater Jan 04 '19 at 17:44
  • 1% is a huge numer if you the numeber operations done during a deployment. Even 1/1000 would be high enough to request a retry logic. Do not forget the multiplication factor and the cost of a failure. – sorin Feb 04 '19 at 15:41
0
pip install --upgrade ansible-lint>=4.1.0

Rule 405 has been dropped following the discussion in https://github.com/ansible/ansible-lint/issues/456

bbaassssiiee
  • 101
  • 2