Reputation: 887
I have created a role to deploy stack. Where I am taking care of role back also (If stack is failed, roll back up to certain tasks). However While everything is going smooth, on the console rollback tasks are displayed as skipped
tasks (in non verbose mode also).
TASK: [deploy-stack | Deleting_Validation_Template] ***************************
skipping: [10.17.10.150]
TASK: [deploy-stack | shell echo 'Template Validation has Failed'] ************
skipping: [10.17.10.150]
TASK: [deploy-stack | Deploying_the_Stack..] **********************************
changed: [10.17.10.150]
1) Is it possible to hide skipped
tasks from the console?
2) I have noticed, if I am not running playbook in super verbose mode (ansible-playbook stack.yml -vvvv), ansible log file is not populating the detailed information (basically what we see in console, is going into the ansible log file /var/log/ansible.log
). Is it possible to define log level to push more information in to log file, while running playbook in non verbose mode (ansible-playbook stack.yml) ?
Upvotes: 3
Views: 4426
Reputation: 68239
1) As stated in the comment above you can turn off printing statuses of skipped tasks, but not the names of them – parameter display_skipped_hosts
If you want to customize the output further, you need some code and make you own stdout plugin for Ansible:
v2_runner_on_*
methods, so if you don't want to print skipped tasks' names you need to capture the name into global dict inside v2_playbook_on_task_start
but not print them out in this method, and then later print or not print it inside v2_runner_on_*
methods (see use of self.stats
and task._uuid
in profile_tasks.py for reference)2) There is no easy solution to this, because default logger shares the same method that is used to print info to console.
But if you do you own custom stdout plugin, you can print verbose info supplying log_only=True
to self._display.display
method (see v2_playbook_on_stats
in default.py callback for example).
Alternatively you can make another callback plugin used just for logging.
Upvotes: 2