Answer the question
In order to leave comments, you need to log in
How to write a playbook for Ansible correctly?
I'm trying to attach Ansible to the project to simplify the deployment.
To update the code on the VPS, you must perform the following steps:
---
- hosts: production
tasks:
- name: Stop app
shell: ./stop.sh
- name: Start git pull
git: [email protected]:repo/projectname.git version=master dest=/home/user/projects/projectname
sudo: yes
sudo_user: user
notify:
- Start eslint
handlers:
- name: Start eslint
shell: ./eslint.sh
notify:
- Start build
- name: Start build
shell: ./build.sh
notify:
- Start builddocs
- name: Start builddocs
shell: ./builddocs.sh
notify:
- Start updatekey
- name: Start updatekey
shell: ./updatekey.sh
notify:
- Start app
- name: Start app
shell: ./start.sh
Answer the question
In order to leave comments, you need to log in
what kind of tin you have
, look at the ready-made scripts,
your scripts should be scattered into commands in the ansible itself and not call them
, well, you just need to execute them in turn and not call them in a chain through handlers,
start and stop the task in systemd and use it through service
The documentation is very clear, it is enough for understanding. But you need to know English.
By the way, your example is old. Here is the old task format, and the use of sudo instead of become.
In addition, instead of shell, you had to use service to start / stop.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question