0
votes

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
1
For future reference, when you paste preformatted code into the post, immediately select it and type Ctrl+K or click the {} button in the interface. That will format the code properly. - glibdud
sure thanks. will do that next time - cad

1 Answers

2
votes

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