snippetMinor
How to solve "E405: Remote package tasks should have a retry" in Ansible?
Viewed 0 times
packagetaskse405solvehowremoteshouldansiblehaveretry
Problem
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
Given the sample code:
How to solve this?
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 packagesGiven the sample code:
- name: Install list of packages
apt:
name: [jq, vim, curl, unzip, dnsutils]
state: presentHow to solve this?
Solution
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: 2When this is added to task Ansible will retry ten times with a delay of two seconds between each retry until the
returncode is 0.Code Snippets
register: task_result
until: task_result is success
retries: 10
delay: 2Context
StackExchange DevOps Q#5829, answer score: 8
Revisions (0)
No revisions yet.