J
J
Jden102021-03-19 11:41:36
Ansible
Jden10, 2021-03-19 11:41:36

Remote launch of a python file?

how to run a python file from one device to another. That is, roughly speaking, I have a computer from which I will send a file to another, and it will start there?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dr. Bacon, 2021-03-19
@bacon

ssh

S
Sand, 2021-03-19
@sand3001

Maybe I didn’t see something, but if ansible is involved, then playbook.yml may look like this:

---
- hosts: all
  vars:
    remote_path: "path/to/file/on/remote"
    path_to_local_file: "local/file/yourfile.py"

  tasks:
    - name: remote path exists?
      file:
        path: "{{ remote_path }}"
        state: directory

    - name: copy your file in place.
      copy:
        src: "{{ path_to_local_file }}"
        dest: "{{ remote_path }}/filename.py"
        mode: 0755

    - name: execute file
      shell: >
        python3  {{ remote_path }}/filename.py
      changed_when: false

Note that ansible must be configured on the machine you want to run it from.
For example, the /etc/ansible/hosts file should contain the addresses of remote machines and be able to connect to them. Also, you may have a different launch command (not shell: > python3 {{ remote_path }}/filename.py), depending on what is meant by
and he will run there

P
Puma Thailand, 2021-03-19
@opium

ssh rdp

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question