How to start Ray cluster head node with ansible?

226 views
Skip to first unread message

Joey Cheng

unread,
Jul 3, 2021, 12:36:44 AM7/3/21
to Ansible Project
Hello folks,

I'm using ansible to deploy Ray cluster. I'm initializing head node as following:

 - name: Start Ray on head node
   ansible.builtin.command: ray start --head --port=6379
   environment:
       PATH: /opt/anaconda3/bin
    register: result

I printed the result and it looks fine. But when I run "ray status" in bash, it shows "Could not find any running Ray instance" error. Also, I tried typing "ray start --head --port=6379" directly in bash, everything is fine. 

So why these give different result? What's the difference between the bash that I use and the one ansible.builtin.command uses?

Luca 'remix_tj' Lorenzetto

unread,
Jul 3, 2021, 1:40:00 AM7/3/21
to ansible...@googlegroups.com
Hello,

Have you tried using shell instead of command?

From shell docs:

It is almost exactly like the command module but runs the command through a shell (/bin/sh) on the remote node.

From command docs:

The command(s) will not be processed through the shell, so variables like $HOME and operations like "<", ">", "|", ";" and "&" will not work. Use the shell module if you need these features.

Luca

--
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-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a35692da-8ae4-43d1-99e0-a699d18d184cn%40googlegroups.com.

Stefan Hornburg (Racke)

unread,
Jul 3, 2021, 11:10:36 AM7/3/21
to ansible...@googlegroups.com
On 03/07/2021 06:36, Joey Cheng wrote:
> Hello folks,
>
> I'm using ansible to deploy Ray cluster. I'm initializing head node as following:
>
> / - name: Start Ray on head node/
> /   ansible.builtin.command: ray start --head --port=6379/
> /   environment: /
> /       PATH: /opt/anaconda3/bin/
> /    register: result/
>
> I printed the result and it looks fine. But when I run "ray status" in bash, it shows "Could not find any running Ray instance" error. Also, I tried typing "ray start --head --port=6379" directly in bash, everything is fine.
>
> So why these give different result? What's the difference between the bash that I use and the one ansible.builtin.command uses?
>

I think the "command" module doesn't use a shell at all, it executes the command from a Python skript.
That also means it doesn't read any of the bash configuration files, thus relevant environment variables
might be missing. Also check whether the task above uses the same user as the direct bash invocation.

Regards
Racke

> --
> 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-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a35692da-8ae4-43d1-99e0-a699d18d184cn%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/a35692da-8ae4-43d1-99e0-a699d18d184cn%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

Joey Cheng

unread,
Jul 3, 2021, 2:32:00 PM7/3/21
to Ansible Project
Hello guys,

Thanks for your reply! I tried shell module and it's still not working. I'm currently using

- name: Start ray on headnode
  become: false
  delegate_to: 127.0.0.1
  ansible.builtin.command: ssh ubuntu@{{floating_ip}} 'export PATH=/opt/anaconda3/bin:$PATH; ray start --head --port=6379'

and it works fine for now. Free free to let me know if any elegant solution!

Best,
Joey
Reply all
Reply to author
Forward
0 new messages