Hello,
I am trying to remove unused kernel packages when the command output is
larger than 1
the tasks looks like this:
- name: Check if kernel upgrade is available
command: dpkg -l linux-image* | grep ii | wc -l 2>&1
register: kernelinstalled
- name: Delete unused linux kernels
command: apt-get remove $(dpkg -l linux-image* | grep ii | grep -v
$(uname -r) | awk '{print $2}')
when: kernelinstalled.stdout >= 2
however when I run a check of the playbook I get the following failure:
TASK [nginx : Delete unused linux kernels]
*************************************
fatal: [10.160.125.74]: FAILED! => {"failed": true, "msg": "The conditional
check 'kernelinstalled.stdout >= 2' failed. The error was: error while
evaluating conditional (kernelinstalled.stdout >= 2): 'dict object' has no
attribute 'stdout'\n\nThe error appears to have been in
'/etc/ansible/roles/nginx/tasks/main.yml': line 20, column 3, but may\nbe
elsewhere in the file depending on the exact syntax problem.\n\nThe
offending line appears to be:\n\n#\n- name: Delete unused linux kernels\n
^ here\n"}
Any idea how can I make that work?
Regards,
Peter
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/47a09c71-46c6-466c-a474-b1b96de74987%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.