繁体   English   中英

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

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

在使用ansible进行群集的滚动重启时,我想运行python脚本来验证重启后回来没有任何问题。 所以我试图运行使用ansible传递参数的python脚本。 以下是我正在使用的代码失败

错误! 此任务“ 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

我相信该错误是正确的,因为“命令”和“外壳”是您可以为其指定参数的两个最常见的模块。 要在带有参数的本地主机上执行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