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

时间:2019-01-03 20:06:42

标签: python ansible

在使用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 < / p>

- 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

1 个答案:

答案 0 :(得分:1)

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