How to fix "Could not match supplied host pattern, ignoring: bigip" errors, works in Ansible, NOT Tower
Asked Answered
G

5

14

I am running Ansible Tower v3.4.1 with Ansible v2.7.6 on an ubuntu 16.04 VM running on VirtualBox. I run a playbook that works when I run it from the command line using "ansible-playbook" but fails when I try to run it from Ansible Tower. I know I must have something misconfigured in ansible tower but I can't find it.

I get this warning no matter what changes I make to the inventory (hosts) file.

$ ansible-playbook 2.7.6

config file = /etc/ansible/ansible.cfg    
configured module search path = [u'/var/lib/awx/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']

ansible python module location = /usr/lib/python2.7/dist-packages/ansible    

executable location = /usr/bin/ansible-playbook
python version = 2.7.12 (default, Nov 12 2018, 14:36:49) [GCC 5.4.0 20160609]

Using /etc/ansible/ansible.cfg as config file

SSH password:     
**/tmp/awx_74_z6yJB4/tmpVlXGCX did not meet host_list requirements**, check plugin documentation if this is unexpected

Parsed /tmp/awx_74_z6yJB4/tmpVlXGCX inventory source with script plugin

PLAYBOOK: addpool.yaml *********************************************************

1 plays in addpool.yaml

 [WARNING]: **Could not match supplied host pattern, ignoring: bigip**

PLAY [Sample pool playbook] ****************************************************
17:05:43

skipping: no hosts matched

I have enabled inventory plugins for YAML, and made my hosts file into a hosts.yml file.

Here's my hosts file:

 192.168.68.253
 192.168.68.254
 192.168.1.165

[centos]
dad2 ansible_ssh_host=192.168.1.165

[bigip]
bigip1 ansible_host=192.168.68.254
bigip2 ansible_host=192.168.68.253

Here's my playbook:

---

- name: Sample pool playbook
  hosts: bigip 
  connection: local

  tasks:
    - name: create web servers pool
      bigip_pool:
        name: web-servers2
        lb_method: ratio-member
        password: admin
        user: admin
        server: '{{inventory_hostname}}'
        validate_certs: no
Garrik answered 11/2, 2019 at 23:28 Comment(0)
G
5

I replaced hosts: bigip with hosts: all and specified the inventory in Tower as bigip which contains only the two hosts I want to change. This seems to provide the output I am looking for.

For the ansible-playbook command line, I added --limit bigip and this seems to provide the output I am looking for.

So things appear to be working, I just don't know whether this is best practice use.

Garrik answered 12/2, 2019 at 15:8 Comment(1)
did you figure out a best practice since ? I'm facing the same issue and except configure hosts: all, there's nothing that seems to work..Warbler
B
1

If you get the error below while running a playbook with the command

ansible-playbook -i test-project/inventory.txt playbook.yml

{"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 172.31.24.10 port 22: Connection timed out", "unreachable": true}

The solution is to add, in the file ansible.cfg:

[defaults]

inventory=/etc/ansible/hosts
Butyraldehyde answered 29/6, 2022 at 11:45 Comment(0)
S
0

I think you need to remove the connection: local.

You have specified in hosts: bigip that you want these tasks to only run on hosts in the bigip group. You then specify connection: local which causes the task to run on the controller node (i.e. localhost), rather than the nodes in the bigip group. Localhost is not a member of the bigip group, and so none of the tasks in the play will trigger.

Swisher answered 12/2, 2019 at 9:30 Comment(2)
Thanks for responding, but that's a little confusing, because that playbook runs properly from the command line using "ansible-playbook". It only fails running from Tower. What would you use for "connection" in Tower?Garrik
By the way, I get the same error result when I remove "connection: local"Garrik
L
0

Check for special characters in absolute path of hosts file or playbook. Incase if you directly copied the path from putty, try copy and paste it from notepad or any editor

Lynlyncean answered 20/8, 2021 at 16:23 Comment(0)
K
0

For me the issue was the format of the /etc/ansible/hosts file. You should use the :children suffix in order to use groups of groups like this:

[dev1]
dev_1 ansible_ssh_host=192.168.1.55 ansible_connection=ssh ansible_ssh_user={{username}} ansible_ssh_pass={{password}} 

[dev2]
dev_2 ansible_ssh_host=192.168.1.68 ansible_connection=ssh ansible_ssh_user={{username}} ansible_ssh_pass={{password}}

[devs:children]
dev1
dev2

Reference: here

Karolyn answered 26/8, 2022 at 10:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.