find command ambiguity

36 views
Skip to first unread message

Arbab Nazar

unread,
Aug 4, 2015, 8:44:46 AM8/4/15
to Ansible Project
Hi Everyone, I have an ambiguity in the find command. Can somebody clarify it. I have paste the tasks down(copy from some blog post on the net). I have an ambiguity in the second task where it says

reboot_hint.stdout.find("reboot") != -1

What does it mean, that run this task if you will not find the "reboot" word in the value of reboot_init variable?
OR
run this task if you will find the "reboot" word in the value of reboot_init variable?

Thanks in advance

- name: Check for reboot hint.
  shell: if [ $(readlink -f /vmlinuz) != /boot/vmlinuz-$(uname -r) ]; then echo 'reboot'; else echo 'no'; fi
  ignore_errors: true
  register: reboot_hint

- name: Rebooting ...
  command: shutdown -r now "Ansible kernel update applied"
  async: 0
  poll: 0
  ignore_errors: true
  when: kernelup|changed or reboot_hint.stdout.find("reboot") != -1
  register: rebooting

- name: Wait for thing to reboot...
  pause: seconds=45
  when: rebooting|changed

Scott Sturdivant

unread,
Aug 4, 2015, 9:33:47 AM8/4/15
to Ansible Project
It means that the task will run if it does find the string 'reboot' in the stdout of the registered reboot_hint variable.  It's just calling this:  https://docs.python.org/2/library/string.html#string.find

--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/cb5908ea-9587-4df4-b414-af3e9988a639%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages