Hi,
Kinda new to Ansible and I’m struggling with the following:
I want to update a MYSQL server → httpd → varnish server. in that order.
I want to check, after the server rebooted, if the service mysqld or httpd is started before I continue with the httpd or varnish server.
Right now I have this but the post task runs way to fast before the server is restarted so it returns that the service is started:
Following is a code snippit, for the app server i instructed it to wait for port 80 and service httpd. but its the same.
Question is: How do I check if the server and service is up and running before I continue with the other servers in the playbook.
Thanks!
- hosts: dbservers
user: root
serial: 1
tasks:
- name: upgrade all packages + when done restart server
yum: name=* state=latest
notify: - restart server db
handlers: - name: restart server db
command: reboot
post_tasks:
- name: wait for db server to come up
wait_for: host={{ inventory_hostname }} port=3306 state=started timeout=80 - name: make sure mysql is started
service: name=mysqld state=started