summaryrefslogtreecommitdiffstats
path: root/roles/cuda/handlers/main.yml
blob: adba3b7e52a228575a00fdc148cb12d79f1b3717 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
---
# handlers file for ansible-role-cuda
- name: reload systemd unit files
  shell: systemctl daemon-reload

- name: Initialize the GPUs
  command: /bin/bash /usr/local/bin/cuda_init.sh
  when:
    - cuda_init
    - cuda_init_restart_service

- name: Restart cuda_init service
  service:
    name: cuda_init
    state: restarted
  when:
    - cuda_init
    - cuda_init_restart_service
    - ansible_service_mgr == "systemd"

- name: ZZ CUDA Restart server
  command: sleep 2 && /sbin/shutdown -r now "Node software upgrade reboot"
  async: 1
  poll: 0
  ignore_errors: true
  when:
    - cuda_packages_installation.changed
    - cuda_restart_node_on_install

# define the variable running_as_ansible_pull in the ansible-pull playbook, like local.yml 
- name: ZZ CUDA Wait for server to restart
  wait_for:
    host: "{{ ansible_ssh_host | default(inventory_hostname) }}"
    state: started
    delay: 30
    timeout: 300
  connection: local
  become: false
  when:
    - cuda_restart_node_on_install
    - (running_as_ansible_pull is not defined or running_as_ansible_pull == False)

# vim:ft=ansible: