1
votes

I try to use ansible-pull and synchronize module to sync files from a remote server to the local server. I use ansible-pull it failed and shows 'skipping: no hosts matched' but when I copy the playbook file to my local server and run as ansible-playbook, it works.

my hosts setting

localhost ansible_connection=local

[sync_server]
sync_1 ansible_host=11.22.33.44

playbook file

---
 - name: Sync Test
    hosts: sync_server
    tasks:

      - name: Start Sync
        synchronize:
          mode: pull
          src: /home/sourcefiles
          dest: /home/syncfiles/
  • ansible version 2.5.1
  • python version 2.7.17
  • Sync server and client os ubuntu 18.04
1
Welcome to SO! See How to create a Minimal, Reproducible Example. Include at least the ansible-pull command and the output. - Vladimir Botka

1 Answers

0
votes

Without a little bit more detail (notably, the command you're actually executing, or at least a lightly modified version without your real VCS repository), it looks like you might not be invoking your playbook with a hosts/inventory file specified OR your inventory might not be parsed properly.

You can run ansible-inventory --graph to see a list of the hosts which have been "detected" with this inventory. You should also check ansible-config dump | grep DEFAULT_HOST_LIST to see whether you're specifying the path to your inventory.

If this is where the issue lies, then you should try one of the following:

  1. Configure an ansible.cfg with (at least) the following lines:
[defaults]
inventory = hosts
  1. Try ansible-pull using the switch --inventory (which can be shortened to -i) followed by path to your inventory file, like this: ansible-pull --inventory hosts --url http://example.org/my/vcs.git playbook.yml