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

[RFC] Allow synchronous delegation of restart to alternative init system #76

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions handlers/main.yml
Expand Up @@ -2,6 +2,10 @@
- name: run riak_disk_tune
command: /bin/bash /usr/local/bin/riak_disk_tune.sh

- name: restart riak and ensure enabled
service: name=riak enabled=yes state=restarted
when: riak_init_system == 'system'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I became concerned with variable scope at execution time of the handler. Do you know if this riak_init_system is safe here? I am considering templating the trigger with the variable, and in turn specifying trigger name with system.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better not to change this to variable in notify, because of ansible/ansible#17922

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relevant note is that tasks/main.yml flushes handlers, so variable scope is more predictable in principle in this case


- name: wait for http
wait_for: port={{ riak_http_port }}

Expand Down
2 changes: 1 addition & 1 deletion tasks/Debian.yml
Expand Up @@ -63,4 +63,4 @@
- name: Reload systemd
systemd: state=restarted daemon_reload=yes name=riak enabled=yes
tags: Debian
when: 'ansible_distribution_release == "xenial" or ansible_distribution_release == "jessie"'
when: '(ansible_distribution_release == "xenial" or ansible_distribution_release == "jessie") and (riak_init_system == "system")'
8 changes: 6 additions & 2 deletions tasks/main.yml
Expand Up @@ -42,8 +42,12 @@
when: riak_package == "riak-ts" and riak_shell_nodes is defined

- name: Reboot Riak to accept the new config and ensure it is enabled to start at bootup
service: name=riak enabled=yes state=restarted
when: riak_init_system == 'system'
debug:
msg: "Trigger Riak restart"
notify: restart riak and ensure enabled

- name: Force all notified handlers to run at this point, not waiting for normal sync points, in order to ensure that Riak has been restarted and is starting up
meta: flush_handlers

- name: Wait for Riak to start up before continuing
wait_for: "delay=5 timeout=30 host={{ riak_pb_bind_ip }} port={{ riak_pb_port }} state=started"
Expand Down