简体   繁体   English

尝试运行python脚本时出现错误的剧本错误

[英]ansible playbook errors out while trying to to run python script

while doing rolling restart of cluster using ansible i want run python script to verify the rebooted came back without any issues. 在使用ansible进行群集的滚动重启时,我想运行python脚本来验证重启后回来没有任何问题。 so i'm trying to run the python script passing arguments using ansible. 所以我试图运行使用ansible传递参数的python脚本。 below is the code i'm using it fails 以下是我正在使用的代码失败

ERROR! 错误! this task 'python' has extra params, which is only allowed in the following modules: command, win_command, shell, win_shell, script, include, include_vars, include_tasks, include_role, import_tasks, import_role, add_host, group_by, set_fact, raw, meta 此任务“ python”具有额外的参数,仅在以下模块中允许:命令,win_command,shell,win_shell,脚本,include,include_vars,include_tasks,include_role,import_tasks,import_role,add_host,group_by,set_fact,raw,meta

- hosts: tag_name
  gather_facts: yes
  become: true
  serial: 1
  tasks:
    - name: execute python script
      local_action: python script.py -r us-east-1,us-west-2 -n tag -e test -s tag -k "pemfile" -u ec2-user

I believe the error is correct as 'command' and 'shell' are two most common modules for which you can specify the arguments. 我相信该错误是正确的,因为“命令”和“外壳”是您可以为其指定参数的两个最常见的模块。 To execute the python script on the local host with arguments, use 'command' along with 'local_action' as below. 要在带有参数的本地主机上执行python脚本,请使用“ command”和“ local_action”,如下所示。

local_action: command python script.py -r us-east-1,us-west-2 -n tag -e test -s tag -k "pemfile" -u ec2-user

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM