Deploying to production the process fails with the following error:
TASK [deploy : Copy project templates] *****************************************
changed: [12.34.567.891] => (item={'name': '.env config', 'src': 'roles/deploy/templates/env.j2', 'dest': '.env', 'mode': '0600'})
---------------------------------------------------
The task includes an option with an undefined variable. The error was: 'dict
object' has no attribute 'dest'
The error appears to be in '/home/***/Desktop/Projects/site.com/t
rellis/roles/deploy/tasks/build.yml': line 16, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Copy project templates
^ here
fatal: [12.34.567.891]: FAILED! => {}
PLAY RECAP *********************************************************************
12.34.567.891 : ok=16 changed=7 unreachable=0 failed=1 skipped=25 rescued=0 ignored=0
localhost : ok=0 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
exit status 2
For reference my build.yml is the following:
---
- name: Check if deploy_build_before scripts exist
stat:
path: "{{ item }}"
delegate_to: localhost
register: deploy_build_before_paths
with_items: "{{ deploy_build_before | default([]) }}"
- include_tasks: "{{ include_path.item }}"
with_items: "{{ deploy_build_before_paths.results }}"
loop_control:
loop_var: include_path
when: include_path.stat.exists
tags: deploy-build-before
- name: Copy project templates
template:
src: "{{ item.src }}"
dest: "{{ deploy_helper.new_release_path }}/{{ item.dest }}"
mode: "{{ item.mode | default('0644') }}"
with_items: "{{ project.project_templates | default(project_templates) }}"
- name: Check if project folders exist
stat:
path: "{{ deploy_helper.current_path }}/{{ item }}"
register: project_folder_paths
with_items: "{{ project.project_copy_folders | default(project_copy_folders) }}"
- name: Copy project folders
copy:
src: "{{ deploy_helper.current_path }}/{{ item.item }}/"
dest: "{{ deploy_helper.new_release_path }}/{{ item.item }}"
remote_src: true
mode: 'preserve'
with_items: "{{ project_folder_paths.results }}"
when: item.stat.exists
- name: Check if deploy_build_after scripts exist
stat:
path: "{{ item }}"
delegate_to: localhost
register: deploy_build_after_paths
with_items: "{{ deploy_build_after | default([]) }}"
- include_tasks: "{{ include_path.item }}"
with_items: "{{ deploy_build_after_paths.results }}"
loop_control:
loop_var: include_path
when: include_path.stat.exists
tags: deploy-build-after
I’m using Ansible 2.10.16. Could the Ansible version be the problem?