Running Python script via ansible

后端 未结 2 1052
礼貌的吻别
礼貌的吻别 2021-01-01 10:29

I\'m trying to run a python script from an ansible script. I would think this would be an easy thing to do, but I can\'t figure it out. I\'ve got a project structure like th

2条回答
  •  悲&欢浪女
    2021-01-01 11:15

    If you want to be able to use a relative path to your script rather than an absolute path then you might be better using the role_path magic variable to find the path to the role and work from there.

    With the structure you are using in the question the following should work:

    - name: run my script!
      command: ./mypythonscript.py
      args:
        chdir: "{{ role_path }}"/files
      delegate_to: 127.0.0.1
      run_once: true
    

提交回复
热议问题