geerlingguy / ansible-role-docker

Ansible Role - Docker
https://galaxy.ansible.com/geerlingguy/docker/
MIT License
1.8k stars 851 forks source link

Fix lookup when vars not exists error. #432

Closed zhongyiio closed 4 months ago

zhongyiio commented 10 months ago

When the docker.yml playbook is located in the root directory, it executes correctly due to the coincidental presence of a vars directory.

However, moving this file into the playbooks directory results in the error “No file was found when using first_found.

# Install docker playbook
- hosts: all
  become: yes

  vars_files:
    - ../vars/{{ env }}/docker.yml

  roles:
    - role: geerlingguy.docker
      tags:
        - docker
      when: env == 'develop'
geerlingguy commented 10 months ago

They playbook should typically not exist inside a role directory, rather the role should be included and be located in a roles_path like in ./roles/ with respect to the playbook. What kind of directory structure do you currently have in place?

zhongyiio commented 10 months ago

My directory structure is as follows, docker.yml is the file mentioned in the above text.

ansible.cfg

[defaults]
roles_path = ./roles
.
├── README.md
├── Vagrantfile
├── ansible.cfg
├── inventory
│   └── develop.yml
├── main.yml
├── playbooks
│   ├── docker.yml
│   └── node_exporter.yml
├── requirements.yml
├── roles
│   ├── deploy_docker
│   │   └── tasks
│   │       └── main.yml
│   ├── geerlingguy.docker
│   │   ├── LICENSE
│   │   ├── README.md
│   │   ├── defaults
│   │   │   └── main.yml
│   │   ├── handlers
│   │   │   └── main.yml
│   │   ├── meta
│   │   │   └── main.yml
│   │   ├── molecule
│   │   │   └── default
│   │   │       ├── converge.yml
│   │   │       └── molecule.yml
│   │   ├── tasks
│   │   │   ├── docker-compose.yml
│   │   │   ├── docker-users.yml
│   │   │   ├── main.yml
│   │   │   ├── setup-Debian.yml
│   │   │   └── setup-RedHat.yml
│   │   └── vars
│   │       ├── Alpine.yml
│   │       ├── Archlinux.yml
│   │       └── main.yml
└── vars
    └── develop
        ├── all.vault.yml
        ├── all.yml
        ├── docker.yml
        └── node_exporter.yml
github-actions[bot] commented 6 months ago

This pr has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

github-actions[bot] commented 4 months ago

This pr has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.