[Help] Could not match supplied host pattern

5,064 views
Skip to first unread message

Deanosim

unread,
Jul 15, 2018, 2:35:42 PM7/15/18
to Ansible Project
I'm learning Ansible and other things from this guide https://github.com/Artemmkin/infrastructure-as-code-tutorial/blob/master/docs/06-ansible.md
Only problem is whenever I try and run deply.yml I get
 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match
'all'

 [WARNING]: Could not match supplied host pattern, ignoring: raddit-app


PLAY [Deploy Raddit App] ***********************************************************************************************
skipping: no hosts matched

PLAY RECAP *************************************************************************************************************

I know this is probably caused by the fact the guide was written for 2.4 of Ansible but I'd like to update it to use 2.6 aka the latest.

I can post my hosts.yml deply.yml and ansiblecfg if needed, but all that same info is in the guide I linked.

Any help would be very much appreciated as I'm a noob when It comes to Ansible and I really want to learn it better.

Kai Stian Olstad

unread,
Jul 15, 2018, 3:21:32 PM7/15/18
to ansible...@googlegroups.com
On 15.07.2018 20:35, Deanosim wrote:
> I'm learning Ansible and other things from this guide
> https://github.com/Artemmkin/infrastructure-as-code-tutorial/blob/master/docs/06-ansible.md
> Only problem is whenever I try and run deply.yml I get
> [WARNING]: provided hosts list is empty, only localhost is available.
> Note
> that the implicit localhost does not match
> 'all'
>
> [WARNING]: Could not match supplied host pattern, ignoring: raddit-app
>
>
> PLAY [Deploy Raddit App]
> ***********************************************************************************************
> skipping: no hosts matched
>
> PLAY RECAP
> *************************************************************************************************************
>
> I know this is probably caused by the fact the guide was written for
> 2.4 of
> Ansible but I'd like to update it to use 2.6 aka the latest.

I highly doubt it since this part haven't change for many versions.


> I can post my hosts.yml deply.yml and ansiblecfg if needed, but all
> that
> same info is in the guide I linked.

You would need to, if not we are left to speculate and guess and that is
not very productive.


> Any help would be very much appreciated as I'm a noob when It comes to
> Ansible and I really want to learn it better.

The important thing when you need help is to provide as much information
that you can.
A little to much information is better then to little.

--
Kai Stian Olstad

Deanosim

unread,
Jul 16, 2018, 3:10:42 AM7/16/18
to Ansible Project
ansible.cfg
[defaults]
inventory = ./hosts.yml
private_key_file = ~/.ssh/raddit-user
host_key_checking = False

deploy.yml
---
- name: Deploy Raddit App
  hosts: raddit-app
  tasks:
    - name: Fetch the latest version of application code
      git:
        dest: /home/raddit-user/raddit
      register: clone

    - name: Install application dependencies
      become: true
      bundler:
        state: present
        chdir: /home/raddit-user/raddit
      when: clone.changed
      notify: restart raddit

  handlers:
  - name: restart raddit
    become: true
    systemd: name=raddit state=restarted

hosts.yml
raddit-app:
  hosts:
    raddit-instance
      ansible_host: **IP ADDRESS GOES HERE**
      ansible_user: raddit-user

Kai Stian Olstad

unread,
Jul 16, 2018, 4:33:11 AM7/16/18
to ansible...@googlegroups.com
You are missing a colon after raddit-instance.


--
Kai Stian Olstad

Deanosim

unread,
Jul 16, 2018, 5:02:03 AM7/16/18
to Ansible Project
Ohhhh, this is why you don't do this after 2am at night XD.

Sadly it's still giving me that error even after I added the colon :/, clearly I'm missing something still

Kai Stian Olstad

unread,
Jul 16, 2018, 5:56:50 AM7/16/18
to ansible...@googlegroups.com
On 16.07.2018 11:02, Deanosim wrote:
> Ohhhh, this is why you don't do this after 2am at night XD.
>
> Sadly it's still giving me that error even after I added the colon :/,
> clearly I'm missing something still

If all three files is in the same directory and you are in that
directory when running "ansible-playbook deploy.yml" it should work.

--
Kai Stian Olstad

Deanosim

unread,
Jul 16, 2018, 6:02:08 AM7/16/18
to Ansible Project
Yeah all files are in the same directory and I'm running it from that directory.
Yet for some odd reason it's still giving me that error, I'm wondering if I should setup a fresh vm with ansible to test it on that.
The error again just to show it's the same
 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

 [WARNING]: Could not match supplied host pattern, ignoring: raddit-app


PLAY [Deploy Raddit App] ********************************************************************************************************************************************************************************************************************
skipping: no hosts matched

PLAY RECAP **********************************************************************************************************************************************************************************************************************************

Deanosim

unread,
Jul 16, 2018, 9:26:52 AM7/16/18
to Ansible Project
Okay I manged to get it to work, For some reason on the ubuntu 18.04 version of windows subsystem for linux it just doesn't work, but in a VM of ubuntu 18.04 it works fine
Reply all
Reply to author
Forward
0 new messages