[EVO] Récupérer la dernière version de production
This commit is contained in:
parent
d12e24a06f
commit
5074cfb9b2
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
- hosts: all
|
- hosts: all
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
connection: local
|
|
||||||
tags:
|
tags:
|
||||||
- check_targets
|
- check_targets
|
||||||
- deploy
|
- deploy
|
||||||
@ -17,7 +16,6 @@
|
|||||||
|
|
||||||
- hosts: all
|
- hosts: all
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
connection: local
|
|
||||||
tags: check_targets
|
tags: check_targets
|
||||||
tasks:
|
tasks:
|
||||||
- name: Attendre que le port SSH soit ouvert
|
- name: Attendre que le port SSH soit ouvert
|
||||||
@ -96,6 +94,41 @@
|
|||||||
vars:
|
vars:
|
||||||
release_id: "{{ make_release.json.id }}"
|
release_id: "{{ make_release.json.id }}"
|
||||||
|
|
||||||
|
- hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
tags: deploy_nginx
|
||||||
|
roles:
|
||||||
|
- name: nginx
|
||||||
|
|
||||||
|
- hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
tags: deploy
|
||||||
|
tasks:
|
||||||
|
- name: Déployer l'application
|
||||||
|
ansible.posix.synchronize:
|
||||||
|
src: "{{ playbook_dir }}/{{ app_name }}"
|
||||||
|
dest: /var/www
|
||||||
|
archive: true
|
||||||
|
delete: true
|
||||||
|
tags: deploy
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
tags: clean_cache
|
||||||
|
tasks:
|
||||||
|
- name: Vider le cache de l'application
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /var/cache/nginx/{{ app_name }}
|
||||||
|
state: absent
|
||||||
|
become: true
|
||||||
|
diff: false
|
||||||
|
|
||||||
|
- hosts: 127.0.0.1
|
||||||
|
gather_facts: false
|
||||||
|
connection: local
|
||||||
|
tags: clean_releases
|
||||||
|
tasks:
|
||||||
- name: Lister les pré-version
|
- name: Lister les pré-version
|
||||||
ansible.builtin.uri:
|
ansible.builtin.uri:
|
||||||
url: "{{ gitea_api_base_url }}/repos/{{ gitea_api_repository }}/releases?pre-release=true"
|
url: "{{ gitea_api_base_url }}/repos/{{ gitea_api_repository }}/releases?pre-release=true"
|
||||||
@ -118,36 +151,38 @@
|
|||||||
label: "{{ item.name }}"
|
label: "{{ item.name }}"
|
||||||
loop: "{{ get_releases.json[3:] }}"
|
loop: "{{ get_releases.json[3:] }}"
|
||||||
|
|
||||||
- hosts: all
|
- hosts: 127.0.0.1
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
connection: local
|
connection: local
|
||||||
tags: deploy_nginx
|
tags: clean_tags
|
||||||
roles:
|
|
||||||
- name: nginx
|
|
||||||
|
|
||||||
- hosts: all
|
|
||||||
gather_facts: false
|
|
||||||
connection: local
|
|
||||||
tags: deploy
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Déployer l'application
|
- name: Lister les version
|
||||||
ansible.posix.synchronize:
|
ansible.builtin.uri:
|
||||||
src: "{{ playbook_dir }}/{{ app_name }}"
|
url: "{{ gitea_api_base_url }}/repos/{{ gitea_api_repository }}/releases"
|
||||||
dest: /var/www
|
method: GET
|
||||||
archive: true
|
headers:
|
||||||
delete: true
|
Content-Type: application/json
|
||||||
tags: deploy
|
register: get_releases
|
||||||
become: true
|
|
||||||
diff: false
|
|
||||||
|
|
||||||
- hosts: all
|
- name: Lister les étiquettes
|
||||||
gather_facts: false
|
ansible.builtin.uri:
|
||||||
connection: local
|
url: "{{ gitea_api_base_url }}/repos/{{ gitea_api_repository }}/tags"
|
||||||
tags: clean_cache
|
method: GET
|
||||||
tasks:
|
headers:
|
||||||
- name: Vider le cache de l'application
|
Content-Type: application/json
|
||||||
ansible.builtin.file:
|
register: get_tags
|
||||||
path: /var/cache/nginx/{{ app_name }}
|
|
||||||
state: absent
|
- name: Supprimer les étiquettes n'ayant pas de version
|
||||||
become: true
|
ansible.builtin.uri:
|
||||||
diff: false
|
url: "{{ gitea_api_base_url }}/repos/{{ gitea_api_repository }}/tags/{{ item }}"
|
||||||
|
method: DELETE
|
||||||
|
headers:
|
||||||
|
Content-Type: application/json
|
||||||
|
status_code: 204
|
||||||
|
when:
|
||||||
|
- get_releases.json | length > 0
|
||||||
|
- item | length > 0
|
||||||
|
loop: "{{ releases_by_name | symmetric_difference(tags_by_name) }}"
|
||||||
|
vars:
|
||||||
|
releases_by_name: "{{ get_releases.json | map(attribute='name') }}"
|
||||||
|
tags_by_name: "{{ get_tags.json | map(attribute='name') }}"
|
||||||
|
15
.drone.yml
15
.drone.yml
@ -30,7 +30,6 @@ steps:
|
|||||||
|
|
||||||
- name: ansible-galaxy
|
- name: ansible-galaxy
|
||||||
commands:
|
commands:
|
||||||
- sed -i 's#ssh://gitea@git.ykn.fr:12393#https://gitea.ykn.fr#g' .ansible/requirements.yml
|
|
||||||
- ansible-galaxy install -r .ansible/requirements.yml -p .ansible/roles
|
- ansible-galaxy install -r .ansible/requirements.yml -p .ansible/roles
|
||||||
|
|
||||||
- name: ansible-playbook/check
|
- name: ansible-playbook/check
|
||||||
@ -69,8 +68,20 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- ansible-playbook .ansible/run.yml --tags deploy --limit 'ykn-www-2245.nyx.ykn.local'
|
- ansible-playbook .ansible/run.yml --tags deploy --limit 'ykn-www-2245.nyx.ykn.local'
|
||||||
|
|
||||||
- name: ansible-playbook/cache
|
- name: ansible-playbook/clean_cache
|
||||||
environment:
|
environment:
|
||||||
ANSIBLE_CONFIG: .ansible/configuration/ansible.cfg
|
ANSIBLE_CONFIG: .ansible/configuration/ansible.cfg
|
||||||
commands:
|
commands:
|
||||||
- ansible-playbook .ansible/run.yml --tags clean_cache --limit 'nyx_rproxies'
|
- ansible-playbook .ansible/run.yml --tags clean_cache --limit 'nyx_rproxies'
|
||||||
|
|
||||||
|
- name: ansible-playbook/clean_releases
|
||||||
|
environment:
|
||||||
|
ANSIBLE_CONFIG: .ansible/configuration/ansible.cfg
|
||||||
|
commands:
|
||||||
|
- ansible-playbook .ansible/run.yml --tags clean_releases
|
||||||
|
|
||||||
|
- name: ansible-playbook/clean_tags
|
||||||
|
environment:
|
||||||
|
ANSIBLE_CONFIG: .ansible/configuration/ansible.cfg
|
||||||
|
commands:
|
||||||
|
- ansible-playbook .ansible/run.yml --tags clean_tags
|
||||||
|
Reference in New Issue
Block a user