Is there a command line option that allows to not output ignored tasks?
Currently and by default, ansible-playbook outputs thetask name followed by a line “skipping: {{ inventory_hostname }}” and if used with with_items then the skipping line gets repeated for each item with its current value. I wonder if it was possible to skip this output if a task got ignored completely.
Use case: within our huge repository of roles we sometimes want to executed only very little parts of them and as we use role dependencies and other includes, etc. we introduced lots of conditions so that we have fine-tuned control over what’s actually being executed. That is great because we can make use of default role variables and many other things that we are re-using by this approach. However, this list of ignored tasks now gets pretty long sometimes and it is not so pretty anymore. That’s why we’d be glad to just not output them at all if a specific option was given.
Nope, there’s no option for this.
I generally like to contain option sprawl.
You might want to use “group_by” to target just the hosts you want in many cases as it will avoid duplicate output.
Thanks Michael,
The grouping is no issue and I don’t see duplicate output either. Let me give you an example:
I have roles like common, mysql, apache, many others and a role migrate.
In common and mysql, there are some default variables that might get overwritten by hosts or groups, it depends on the used inventory.
Now, I have a playbook that only runs the role “migrate” (it migrates a live webserver to a development server) and for that role to operate properly I want to make sure that the default variables from common and mysql get read-in as usual. So I have the following play:
- name: “Migration”
hosts: “{{myhosts}}”
connection: ssh
accelerate: “{{accelerate}}”
gather_facts: false
sudo: no
pre_tasks:
- name: “Migrate | Find out current username”
local_action: shell whoami
register: current_user
roles:
- { role: common, when: ignore_these_tasks is defined }
- { role: mysql, when: ignore_these_tasks is defined }
- { role: migrate }
This is running common and mysql, so it reads their default variables too. But because of the condition “ignore_these_tasks” all their tasks get ignored, which is exactly what I want. But I get an output for each of their tasks because they get ignored.
It’s not a big deal, but certainly a very nice to have.
"The grouping is no issue "
I think you might be misunderstanding me. Take a look at “group_by” in the module docs.
It’s a way to select tasks dynamically based on a condition, and will not produce duplicate output for different hosts.
Generally speaking though, it’s not a major concern for me and I don’t want to add a flag for this, since I want to control option sprawl.
I'm in the same boat as Jürgen (group_by doesn't cut it for me in this
situation) and would like to see an option for this as well, actually.
I can understand wanting to limit the number of options, but is this
something that would be considered if it was added as an option in the
configuration file, as opposed to a flag on the command line?
I would definitely accept a configuration file option.