-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaybook.yml
More file actions
99 lines (85 loc) · 2.83 KB
/
Copy pathplaybook.yml
File metadata and controls
99 lines (85 loc) · 2.83 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
---
- name: Install a Ray head node or worker
hosts: all
vars:
_ray_head_node: "{{ ray_head_node | default(false, true) | bool }}"
_ray_head_node_address: "{{ ray_head_node_address | default('', true) }}"
_ray_dashboard_port: "{{ ray_dashboard_port | default('8265', true) }}"
_ray_client_server_port: "{{ ray_client_server_port | default('10001', true) }}"
_ray_head_node_port: "{{ ray_head_node_port | default('6379', true) }}"
_ray_env: "{{ ray_env | default('') }}"
_ray_public_key: "{{ ray_public_key | default('') }}"
_ray_fail_hard: "{{ ray_fail_hard | default(false, true) | bool }}"
gather_facts: false
tasks:
# todo add storage location
# todo scan for head node?
- name: Create user ray
ansible.builtin.user:
name: ray
state: present
- name: Setup ssh key
when: (_ray_public_key | length) > 0
ansible.posix.authorized_key:
user: ray
state: present
key: "{{ _ray_public_key }}"
- name: Allow ray user to control systemd service
community.general.sudoers:
name: ray-systemctl
state: present
user: ray
nopassword: true
commands:
- /usr/bin/systemctl start ray.service
- /usr/bin/systemctl restart ray.service
- /usr/bin/systemctl stop ray.service
- name: Install ray
become: true
become_user: ray
ansible.builtin.command: uv tool install "ray[default]"
- name: Create find_ip script
ansible.builtin.copy:
src: find_private_network.sh
dest: /usr/local/bin/find_private_network.sh
owner: root
group: root
mode: "0655"
- name: Create start_ray script
ansible.builtin.template:
src: start_ray.sh.j2
dest: /usr/local/bin/start_ray.sh
owner: root
group: root
mode: "0655"
- name: Test find network interface
ansible.builtin.command:
cmd: /usr/local/bin/find_private_network.sh
register: find_private_network
- name: Fail if no private network
when: find_private_network.rc != 0
ansible.builtin.fail:
msg: "No private network found! Result of script: {{ find_private_network.stdout }}"
- name: Create Ray systemd service
ansible.builtin.template:
src: ray.service.j2
dest: /etc/systemd/system/ray.service
owner: ray
group: ray
mode: "0644"
notify:
- Start Ray systemd service
- Fail if ray is not active
handlers:
- name: Start Ray systemd service
ansible.builtin.systemd:
name: ray
state: started
daemon_reload: true
- name: Fail if ray is not active
when: _ray_fail_hard
become: true
become_user: ray
ansible.builtin.command: uv tool run ray status
retries: 10
delay: 5