question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Explain use of pre_tasks

See original GitHub issue

Book version: 1.21 Chapter 4 introduces pre_tasks (page 63) with a brief explanation that they’re run before the main set of tasks. It’s not clear (at this point in the book anyway) how that’s any different to just adding a task at the beginning of the tasks section. Assuming the reasoning is covered later in the book, it would be useful to reference that section, or provide a simple explanation at this point of the book.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
geerlingguycommented, Feb 26, 2020

@gaddman - Good point; if you don’t know the context (especially how roles are run prior to tasks) it might seem arbitrary. I’ve made the line read this way to hopefully clear that up:

Ansible lets you run tasks before or after the main tasks (defined in tasks:) or roles (defined in roles:—we’ll get to roles later) using pre_tasks and post_tasks, respectively.

1reaction
ssbarneacommented, Feb 27, 2020

Nobody is removing them, but they do not scale, and for sake of having two ways of writing code, I am inclined to discourage their use. The net is full of users confused about where to stick tasks between roles. Even if I succeed introducing a lint rule for that, it will be optional, so anyone could bypass it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ansible Pre Tasks and Post Tasks Example | Devops Junction
In this article, we are going to see how to use ansible pre tasks and post tasks with examples. ansible pre tasks. What...
Read more >
Set the order of task execution in Ansible with these two ...
First, I'll define pre_tasks and post_tasks. ... My favorite aspect of Ansible is its flexibility: You can use Ansible for configuration ...
Read more >
What is Ansible pre_tasks? How to Update OS, Install Python ...
What is pre_tasks in Ansible? pre_tasks is a task which Ansible executes before executing any tasks mentioned in .yml file.
Read more >
pretask - Wiktionary
AdjectiveEdit. pretask (not comparable). Before commencing a task. AnagramsEdit · kepstra, ...
Read more >
How to specify ansible pretasks for a role? - Stack Overflow
I use the pre_tasks to do some tasks before roles, thanks for Kashyap. ... that should override the user variable defined at apache...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found