debugMinor
Ansible expected paths error
Viewed 0 times
errorpathsansibleexpected
Problem
I have a webserver playbook containing the following:
My folder structure is
```
.
├── ansible
│ ├── ansible
│ ├── ansible.cfg
│ ├── ansible.pub
│ ├── dev
│ ├── docker-compose.yml
│ ├── Docker.zip
│ ├── env
│ │ ├── ansible
│ │ ├── ansible.pub
│ │ ├── Dockerfile
│ │ ├── init-fake.conf
│ │ ├── ssh_config
│ │ └── ssh_host_config
│ ├── playbooks
│ │ ├── database.yml
│ │ ├── hostname.yml
│ │ └── loadbalancer.yml
│ ├── startup.sh
│ └── temp
│ ├── ansible
│ ├── ansible.cfg
│ ├── ansible.pub
│ ├── dev
│ ├── docker-compose.yml
│ └── Docker.zip
├── ansible.cfg
├── ansible.pub
├── control.yml
├── database.yml
├── demo
│ └── demo.conf
├── dev
├── docker-compose.yml
├── Docker.zip
├── env
│ ├── ansible
│ ├── ansible.pub
│ ├── Dockerfile
│ ├── init-fake.conf
│ ├── ssh_config
│ └── ssh_host_config
├── loadbalancer.yml
├── main.yml
├── playbooks
│ ├── hostname.yml
│ ├── stack_restart.yml
│ └── stack_status.yml
├── roles
│ ├── apache2
│ │ ├── defaults
│ │ │ └── main.yml
│ │ ├── files
│ │ ├── handlers
│ │ │ └── main.yml
│ │ ├── meta
│ │ │ └── main.yml
│ │ ├── README.md
│ │ ├── tasks
│ │ │ └── main.yml
│ │ ├── templates
│ │ ├── tests
│ │ │ ├── inventory
│ │ │ └── test.yml
│ │ └── vars
│ │ └── main.yml
│ ├── control
│ │ ├── defaults
│ │ │ └── main.yml
│ │ ├── files
│ │ ├── handlers
│ │ │ └── main.yml
│ │ ├── meta
│ │ │ └── main.yml
│ │ ├── README.md
│ │ ├── tasks
│ │ │ └── main.yml
│ │ ├── templates
│ │ ├── tests
│ │ │ ├── inventory
│ │ │ └── test.yml
│ │ └── vars
│ │ └── main.yml
│ ├── demo_app
│ │ ├── defaults
│ │ │ └── main.yml
│ │ ├── files
│ │ │ └── ap
- hosts: webserver
become: true
roles:
- apache2
- { role: demo_app, db_user: demo, db_pass: demo, db_name: demo }My folder structure is
```
.
├── ansible
│ ├── ansible
│ ├── ansible.cfg
│ ├── ansible.pub
│ ├── dev
│ ├── docker-compose.yml
│ ├── Docker.zip
│ ├── env
│ │ ├── ansible
│ │ ├── ansible.pub
│ │ ├── Dockerfile
│ │ ├── init-fake.conf
│ │ ├── ssh_config
│ │ └── ssh_host_config
│ ├── playbooks
│ │ ├── database.yml
│ │ ├── hostname.yml
│ │ └── loadbalancer.yml
│ ├── startup.sh
│ └── temp
│ ├── ansible
│ ├── ansible.cfg
│ ├── ansible.pub
│ ├── dev
│ ├── docker-compose.yml
│ └── Docker.zip
├── ansible.cfg
├── ansible.pub
├── control.yml
├── database.yml
├── demo
│ └── demo.conf
├── dev
├── docker-compose.yml
├── Docker.zip
├── env
│ ├── ansible
│ ├── ansible.pub
│ ├── Dockerfile
│ ├── init-fake.conf
│ ├── ssh_config
│ └── ssh_host_config
├── loadbalancer.yml
├── main.yml
├── playbooks
│ ├── hostname.yml
│ ├── stack_restart.yml
│ └── stack_status.yml
├── roles
│ ├── apache2
│ │ ├── defaults
│ │ │ └── main.yml
│ │ ├── files
│ │ ├── handlers
│ │ │ └── main.yml
│ │ ├── meta
│ │ │ └── main.yml
│ │ ├── README.md
│ │ ├── tasks
│ │ │ └── main.yml
│ │ ├── templates
│ │ ├── tests
│ │ │ ├── inventory
│ │ │ └── test.yml
│ │ └── vars
│ │ └── main.yml
│ ├── control
│ │ ├── defaults
│ │ │ └── main.yml
│ │ ├── files
│ │ ├── handlers
│ │ │ └── main.yml
│ │ ├── meta
│ │ │ └── main.yml
│ │ ├── README.md
│ │ ├── tasks
│ │ │ └── main.yml
│ │ ├── templates
│ │ ├── tests
│ │ │ ├── inventory
│ │ │ └── test.yml
│ │ └── vars
│ │ └── main.yml
│ ├── demo_app
│ │ ├── defaults
│ │ │ └── main.yml
│ │ ├── files
│ │ │ └── ap
Solution
The task which fails is:
If you have a look at your folder structure and more specifically the
The
Or create a
Setting an absolute path to the directory in the task will also work, but don't think it's an elegant solution.
- name: copy demo app source
copy: src=demo/app/ dest=/var/www/demo mode=0755
notify: restart apache2If you have a look at your folder structure and more specifically the
demo_app role, you have:│ ├── demo_app
│ │ ├── defaults
│ │ │ └── main.yml
│ │ ├── files
│ │ │ └── app
│ │ │ ├── demo.py
│ │ │ └── requirements.txt
│ │ ├── handlers
│ │ │ └── main.yml
│ │ ├── meta
│ │ │ └── main.yml
│ │ ├── README.md
│ │ ├── tasks
│ │ │ └── main.yml
│ │ ├── templates
│ │ │ └── demo.wsgi.j2
│ │ ├── tests
│ │ │ ├── inventory
│ │ │ └── test.yml
│ │ └── vars
│ │ └── main.ymlThe
copy task will look for the src in demo_app/files/. So, either change your task to:- name: copy demo app source
copy: src=app dest=/var/www/demo mode=0755
notify: restart apache2Or create a
demo directory in demo_app/files/ and place the app directory in it (like demo_app/files/demo/app/).Setting an absolute path to the directory in the task will also work, but don't think it's an elegant solution.
Code Snippets
- name: copy demo app source
copy: src=demo/app/ dest=/var/www/demo mode=0755
notify: restart apache2│ ├── demo_app
│ │ ├── defaults
│ │ │ └── main.yml
│ │ ├── files
│ │ │ └── app
│ │ │ ├── demo.py
│ │ │ └── requirements.txt
│ │ ├── handlers
│ │ │ └── main.yml
│ │ ├── meta
│ │ │ └── main.yml
│ │ ├── README.md
│ │ ├── tasks
│ │ │ └── main.yml
│ │ ├── templates
│ │ │ └── demo.wsgi.j2
│ │ ├── tests
│ │ │ ├── inventory
│ │ │ └── test.yml
│ │ └── vars
│ │ └── main.yml- name: copy demo app source
copy: src=app dest=/var/www/demo mode=0755
notify: restart apache2Context
StackExchange DevOps Q#735, answer score: 7
Revisions (0)
No revisions yet.