Re: [ansible-project] wait_for module
Thanks Kai for sorting this out. I have rectified the indentations & other corrections and its working now ...will add more logic to get the desired output.Appreciate your prompt help Kai.. On Wed, Nov 8, 2017 at 12:22 PM, Kai Stian Olstad < ansible-project+l...@olstad.com> wrote: > On 08.11.2017 07:20, coach rhca wrote: > >> Thanks Kai for that insight , i have taken out the port=22 and include the >> timeout=600 option in wait_for module in order to check the services by >> login to server. Also can we set different timeout values for different >> host in wait_for module. >> > > You can have a variable for each host that you specify the timeout. > > Can you please throw some light as i am created a >> playbook for reboot and calling it in other playbook by specifying >> specific >> host. like below but its not working . >> > > There is a lot of errors in your playbook, you should read up on YAML file > syntax. > http://docs.ansible.com/ansible/latest/YAMLSyntax.html > > And then study the other examples you find all over the documentation and > remember to pay attention to the indentation since that is very important > in YAML. > > > --- >> tasks: >>shell: sleep 2 && shutdown -r now >>async: 1 >>poll: 0 >>ignore_errors: true >> > > This is a task file, it can't have "tasks:" in it. > Remove the tasks and add a dash in front of the shell line and make sure > the indentation is correct. > > > server.yml >> >> --- >> - name: for the individual hosts >> - hosts: 192.168.3.154 <( This server requires to wait for the >> server to come online after reboot ) >> > > Since you are using the name, you can't have the dash on hosts: > > > tasks: >>include: tasks/restart1.yml >> > > The include is missing a dash, and need to be indented properly. > > >- name: wait for the server to be online >> local_action: wait_for host={{ inventory_hostname }} state=started >> delay=5 timeout=120 >> >> - hosts: 192.168.3.153 < ( this server doesnot require to >> wait for the server to come back after reboot ) >> tasks: >>- include: tasks/restart1.yml >> > > Here the indentation is incorrect. > > -- > Kai Stian Olstad > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Ansible Project" group. > To unsubscribe from this topic, visit https://groups.google.com/d/to > pic/ansible-project/5UvPWbQGyT4/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > ansible-project+unsubscr...@googlegroups.com. > To post to this group, send email to ansible-project@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/ms > gid/ansible-project/5baaa1c3a2a9b6ca225f09612873e24b%40olstad.com. > > For more options, visit https://groups.google.com/d/optout. > -- 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-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CALguqPKAdad8ReNReeih75HsuyRLtVDkRY%2BFzUjuG__4pHDo0g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] wait_for module
On 08.11.2017 07:20, coach rhca wrote: Thanks Kai for that insight , i have taken out the port=22 and include the timeout=600 option in wait_for module in order to check the services by login to server. Also can we set different timeout values for different host in wait_for module. You can have a variable for each host that you specify the timeout. Can you please throw some light as i am created a playbook for reboot and calling it in other playbook by specifying specific host. like below but its not working . There is a lot of errors in your playbook, you should read up on YAML file syntax. http://docs.ansible.com/ansible/latest/YAMLSyntax.html And then study the other examples you find all over the documentation and remember to pay attention to the indentation since that is very important in YAML. --- tasks: shell: sleep 2 && shutdown -r now async: 1 poll: 0 ignore_errors: true This is a task file, it can't have "tasks:" in it. Remove the tasks and add a dash in front of the shell line and make sure the indentation is correct. server.yml --- - name: for the individual hosts - hosts: 192.168.3.154 <( This server requires to wait for the server to come online after reboot ) Since you are using the name, you can't have the dash on hosts: tasks: include: tasks/restart1.yml The include is missing a dash, and need to be indented properly. - name: wait for the server to be online local_action: wait_for host={{ inventory_hostname }} state=started delay=5 timeout=120 - hosts: 192.168.3.153 < ( this server doesnot require to wait for the server to come back after reboot ) tasks: - include: tasks/restart1.yml Here the indentation is incorrect. -- Kai Stian Olstad -- 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-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5baaa1c3a2a9b6ca225f09612873e24b%40olstad.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] wait_for module
Thanks Kai for that insight , i have taken out the port=22 and include the timeout=600 option in wait_for module in order to check the services by login to server. Also can we set different timeout values for different host in wait_for module.Can you please throw some light as i am created a playbook for reboot and calling it in other playbook by specifying specific host. like below but its not working . --- tasks: shell: sleep 2 && shutdown -r now async: 1 poll: 0 ignore_errors: true server.yml --- - name: for the individual hosts - hosts: 192.168.3.154 <( This server requires to wait for the server to come online after reboot ) tasks: include: tasks/restart1.yml - name: wait for the server to be online local_action: wait_for host={{ inventory_hostname }} state=started delay=5 timeout=120 - hosts: 192.168.3.153 < ( this server doesnot require to wait for the server to come back after reboot ) tasks: - include: tasks/restart1.yml But its giving me the syntax errors including error of duplicate tasks etc. Thanks for helping On Tue, Nov 7, 2017 at 11:20 PM, Kai Stian Olstad < ansible-project+l...@olstad.com> wrote: > On 07. nov. 2017 18:22, coach rhca wrote: > > Thanks Kai , looking for something like the server is rebooted and looks > > for the processes or service and then move to the next server reboots and > > check the service and goes to the next hosts and does the same. > > You can do something like this. > > - shell: sleep 2 && /sbin/shutdown -r now > async: 1 > poll: 0 > > - wait_for: > port: 22 > host: '{{ inventory_hostname }}' > search_regex: OpenSSH > delay: 10 > delegate_to: localhost > > - service: > name: service-name > state: started > check_mode: yes > register: r > > - fail: > msg: Something went wrong > when: r.state != 'started' > > > But if your process is listening on a port that you can check, then you > can use wait_for directly. > > > -- > Kai Stian Olstad > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Ansible Project" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/ansible-project/5UvPWbQGyT4/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > ansible-project+unsubscr...@googlegroups.com. > To post to this group, send email to ansible-project@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/ansible-project/400495c5-da75-5922-2e2a-9e07773cb68c%40olstad.com. > For more options, visit https://groups.google.com/d/optout. > -- 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-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CALguqPK04q6TkUzNbmTacUk6cjMoDKT-aO-LOrvHyzspQ4m%2Bkw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] wait_for module
On 07. nov. 2017 18:22, coach rhca wrote: > Thanks Kai , looking for something like the server is rebooted and looks > for the processes or service and then move to the next server reboots and > check the service and goes to the next hosts and does the same. You can do something like this. - shell: sleep 2 && /sbin/shutdown -r now async: 1 poll: 0 - wait_for: port: 22 host: '{{ inventory_hostname }}' search_regex: OpenSSH delay: 10 delegate_to: localhost - service: name: service-name state: started check_mode: yes register: r - fail: msg: Something went wrong when: r.state != 'started' But if your process is listening on a port that you can check, then you can use wait_for directly. -- Kai Stian Olstad -- 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-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/400495c5-da75-5922-2e2a-9e07773cb68c%40olstad.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] wait_for module
Thanks Kai , looking for something like the server is rebooted and looks for the processes or service and then move to the next server reboots and check the service and goes to the next hosts and does the same. On Mon, Nov 6, 2017 at 8:51 PM, Kai Stian Olstad < ansible-project+l...@olstad.com> wrote: > On 06. nov. 2017 06:52, coach.r...@gmail.com wrote: > > After rebooting the host and need to check if that process is back > online. > > Is there a way in ansible (or "wait_for module" ) to check the service or > > process to be running after a reboot. could you please share your insight > > about it.Thank you.. > > > For the reboot you can use > > - name: Restart server > shell: sleep 2 && /sbin/shutdown -r now > async: 1 > poll: 0 > > > If you can use wait_for depends on what your process is doing, > wait_for can do many things you find it in the documentation[1]. > > To check if a service is running you have service module that can do that. > > > [1] https://docs.ansible.com/ansible/latest/wait_for_module.html > > -- > Kai Stian Olstad > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Ansible Project" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/ansible-project/5UvPWbQGyT4/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > ansible-project+unsubscr...@googlegroups.com. > To post to this group, send email to ansible-project@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/ansible-project/00af81da-be7e-a516-35dc-96078bd0b734%40olstad.com. > For more options, visit https://groups.google.com/d/optout. > -- 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-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CALguqPLg_UDYKeezGk2aMtomkVHnZYDtK5Yan3wchtuWC8_u%2Bw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] wait_for module
On 06. nov. 2017 06:52, coach.r...@gmail.com wrote: > After rebooting the host and need to check if that process is back online. > Is there a way in ansible (or "wait_for module" ) to check the service or > process to be running after a reboot. could you please share your insight > about it.Thank you.. For the reboot you can use - name: Restart server shell: sleep 2 && /sbin/shutdown -r now async: 1 poll: 0 If you can use wait_for depends on what your process is doing, wait_for can do many things you find it in the documentation[1]. To check if a service is running you have service module that can do that. [1] https://docs.ansible.com/ansible/latest/wait_for_module.html -- Kai Stian Olstad -- 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-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/00af81da-be7e-a516-35dc-96078bd0b734%40olstad.com. For more options, visit https://groups.google.com/d/optout.