jtyr / ansible-run_playbook

An example of how to run an Ansible Playbook programatically
36 stars 11 forks source link

Seeing "Specified limit does not match any hosts." on passing hosts file #2

Closed smalleni closed 8 years ago

smalleni commented 8 years ago

Hi, on passing a host file when creating the runner object I see "Specified limit does not match any hosts." Any clue what I'm missing? The host file looks as follows: [undercloud] undercloud [controller] overcloud-controller-0 [compute] overcloud-compute-0 overcloud-compute-1 Help is greatly appreciated. Thanks!

jtyr commented 8 years ago

Please could you provide more details? Especially whether you defining the equivalent of --limit in the options parameter of the Runner()?

smalleni commented 8 years ago

@jtyr Hey...I'm trying to use your script as is, but changing the playbook and the hosts file which looks like what I pasted above. Not sure what else is required or what I'm missing. Thanks!

jtyr commented 8 years ago

You have to specify for which hosts you want to run your playbook. That should be done by specifying the right subset parameter in the Runner(). in your case it could look like this:

runner = Runner(
        playbook='site.yaml',
        hosts='hosts',
        display=display,
        options={
            'subset': 'compute',
        },
    )
smalleni commented 8 years ago

Thank you. Got past that. Unfortunately the Ansible api is poorly documented :/. Seeing this now..

[stack@manager lib]$ python run.py 

PLAY [Get MySQL Tuner Script] **************************************************
skipping: no hosts matched

PLAY [Checking Undercloud for common Performance Issues] ***********************
skipping: no hosts matched

PLAY [Checking Controller Nodes for common Performance Issues] *****************
skipping: no hosts matched

PLAY [Checking Compute Nodes for common Performance Issues] ********************

TASK [setup] *******************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'startswith'
fatal: [overcloud-compute-0]: FAILED! => {"failed": true, "msg": "Unexpected failure during module execution.", "stdout": ""}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'startswith'
fatal: [overcloud-compute-1]: FAILED! => {"failed": true, "msg": "Unexpected failure during module execution.", "stdout": ""}

NO MORE HOSTS LEFT *************************************************************
    to retry, use: --limit @/home/stack/browbeat/ansible/check/site.retry

PLAY RECAP *********************************************************************
overcloud-compute-0        : ok=0    changed=0    unreachable=0    failed=1   
overcloud-compute-1        : ok=0    changed=0    unreachable=0    failed=1   

I changed verbosity to 3 and still this is all I see. Any help/pointers would be greatly appreciated

jtyr commented 8 years ago

Try verbosity 5.

smalleni commented 8 years ago

same thing :/ any other details that would be of help?

jtyr commented 8 years ago

As you said, the Ansible API is not very well documented. Unfortunately the only way how to make things working is to look how Ansible is doing it in their implementation.

andrewklau commented 8 years ago

@smalleni did you end up finding a solution? Getting the same problem

andrewklau commented 8 years ago

Resolved it by specifying: 'connection': 'smart' or 'connection': 'ssh'