What you have is just a list of tasks.
A playbook is something different, and it contains that list of tasks.
Take a look at
https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_intro.html#playbook-syntax



On Wed, 26 Apr 2023 at 09:15, Ashok Reddy <[email protected]> wrote:

> Hi All,
>
> The ansible playbook is
>
> - name: "Stop {{ app_name }}"
>
>   ansible.builtin.command: "sudo pm2 stop API && sudo pm2 delete API"
>
>   failed_when: false
>
>
> - name: Flush pm2 logs
>
>   ansible.builtin.command: "sudo pm2 flush"
>
>   failed_when: false
>
>
> - name: Remove startup script
>
>   ansible.builtin.command: "sudo pm2 unstartup"
>
>   failed_when: false
>
>
>
> - name: Trigger the api.yml if there are any changes
>
>   stat:
>
>     path: /apps/{{ app_name }}/dist
>
>   register: change_api
>
>
> - name: Run task if dir has changed
>
>   debug:
>
>     msg: "Dir has changed"
>
>   when: change_api.stat.mtime != change_api.stat.ctime and app == "api"
>
>
> - include: "website.yml"
>
>   when: app == "website"
>
>
> - name: "Start {{ app_name }}"
>
>   ansible.builtin.command: "cd /apps/{{ app_name }}; sudo npm run
> start:pm2"
>
>
> - name: "Save process list to dump file"
>
>   ansible.builtin.command: "sudo pm2 save"
>
>
> - name: "Configure {{ app_name }} to start on boot"
>
>   ansible.builtin.command: "sudo pm2 startup"
>
>
> - debug:
>
>     msg: "Deployment has been completed. Please validate."
>
>
> The error is:
>
>
> ERROR! 'ansible.builtin.command' is not a valid attribute for a Play
>
>
> The error appears to be in '/Users/deploy/tasks/main.yml': line 1, column
> 3, but may
>
> be elsewhere in the file depending on the exact syntax problem.
>
>
> The offending line appears to be:
>
>
>
> - name: "Stop {{ app_name }}"
>
>   ^ here
>
> We could be wrong, but this one looks like it might be an issue with
>
> missing quotes. Always quote template expression brackets when they
>
> start a value. For instance:
>
>
>     with_items:
>
>       - {{ foo }}
>
>
> Should be written as:
>
>
>     with_items:
>
>       - "{{ foo }}"
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAKRLcHghkV7G81HhGh7AUb%3D_OA6Dpm_5X2eseEcMVjRasjXPWg%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAKRLcHghkV7G81HhGh7AUb%3D_OA6Dpm_5X2eseEcMVjRasjXPWg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAF8BbLYKaxvaHO-RAjX%2Bd9qqKrxRHwSua3Lu9JcFS6j-irOeFw%40mail.gmail.com.

Reply via email to