Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansible-tasks produced unnecessary empty item task #86

Open
pfuntner opened this issue Jan 15, 2021 · 0 comments
Open

ansible-tasks produced unnecessary empty item task #86

pfuntner opened this issue Jan 15, 2021 · 0 comments

Comments

@pfuntner
Copy link
Owner

I worked up a fix (a090631) to include an empty task when there is no item that applies for any host but I see it creating an empty item task even when there is one non-empty task:

Task type  Role                 Task                                                        Item                                                                                        play                            Run ansible-role-clamav
task                            Gathering Facts                                                                                                                                         ok               ok                ok            ...
task       ansible-role-clamav  Include OS-Specific variables                                                                                                                           ok               ok                ok            ...
task       ansible-role-clamav  include_tasks
task       ansible-role-clamav  Define clamav_daemon.                                                                                                                                   ok               ok                ok            ...
task       ansible-role-clamav  Define clamav_freshclam_daemon.                                                                                                                         ok               ok                ok            ...
task       ansible-role-clamav  Define clamav_packages.                                                                                                                                 ok               ok                ok            ...
task       ansible-role-clamav  Ensure ClamAV packages are installed.                       epel-release                                                                                ok               failed            changed       ...
task       ansible-role-clamav  Ensure ClamAV packages are installed.                       clamav                                                                                      changed          failed            changed       ...
task       ansible-role-clamav  Ensure ClamAV packages are installed.                       clamav-update                                                                               ok               failed            ok            ...
task       ansible-role-clamav  Ensure ClamAV packages are installed.                       clamav-scanner-systemd                                                                      failed           failed            changed       ...
task       ansible-role-clamav  Ensure ClamAV packages are installed.                       clamav-base                                                                                                                                  ...
task       ansible-role-clamav  Ensure ClamAV packages are installed.                       clamav-daemon                                                                                                                                ...
task       ansible-role-clamav  Ensure ClamAV packages are installed.
task       ansible-role-clamav  Run freshclam after ClamAV packages change.                                                                                                                                                changed       ...
task       ansible-role-clamav  include_tasks [2]                                                                                                                                                                                        ...
task       ansible-role-clamav  Ensure Freshclam service is available.                                                                                                                                                     changed       ...
task       ansible-role-clamav  Reload systemd after adding service.                                                                                                                                                       ok            ...
task       ansible-role-clamav  Change configuration for the ClamAV daemon.                 {u'regexp': u'^.*Example$', u'state': u'absent'}                                                                               changed       ...
task       ansible-role-clamav  Change configuration for the ClamAV daemon.                 {u'regexp': u'^.*LocalSocket .*$', u'line': u'LocalSocket /var/run/clamav/clamd.ctl'}                                                        ...
task       ansible-role-clamav  Change configuration for the ClamAV daemon.                 {u'regexp': u'^.*LocalSocket .*$', u'line': u'LocalSocket /var/run/clamd.scan/clamd.sock'}                                     changed       ...
task       ansible-role-clamav  Change configuration for the ClamAV daemon.
task       ansible-role-clamav  Ensure ClamAV daemon is running (if configured).                                                                                                                                           changed       ...
task       ansible-role-clamav  Ensure ClamAV freshclam daemon is running (if configured).                                                                                                                                 changed       ...
handler    ansible-role-clamav  restart clamav daemon   

Here's the output from ansible-playbook I was parsing when this happened: stdout-fixed.txt

I tried to recreate this with ansible/no-items.yml but couldn't get it to happen:

[ubuntu@pfuntner-ubuntu ~]$ ansible-playbook -e '{"hosts": "aws-centos8,gcp-centos8", "items": ["foo", "bar"]}' ~/ansible/no-items.yml | grep -v 'gcp-centos8.*foo' | grep -v 'aws-centos8.*bar' | ansible-tasks
Task type  Role  Task                       Item  aws-centos8  gcp-centos8
play             Test a loop with no items
task             Gathering Facts                  ok           ok
task             Before                           ok           ok
task             Loop                       foo   ok
task             Loop                       bar                ok
task             After                            ok           ok
[ubuntu@pfuntner-ubuntu ~]$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant