cad
cad

Reputation: 337

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. so i'm trying to run the python script passing arguments using ansible. 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

- 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

Upvotes: 0

Views: 1394

Answers (1)

dhillonfarms
dhillonfarms

Reputation: 154

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.

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

Upvotes: 2

Related Questions