[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
|
||||
gather_facts: false
|
||||
connection: local
|
||||
tags:
|
||||
- check_targets
|
||||
- deploy
|
||||
@ -17,7 +16,6 @@
|
||||
|
||||
- hosts: all
|
||||
gather_facts: false
|
||||
connection: local
|
||||
tags: check_targets
|
||||
tasks:
|
||||
- name: Attendre que le port SSH soit ouvert
|
||||
@ -96,6 +94,41 @@
|
||||
vars:
|
||||
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
|
||||
ansible.builtin.uri:
|
||||
url: "{{ gitea_api_base_url }}/repos/{{ gitea_api_repository }}/releases?pre-release=true"
|
||||
@ -118,36 +151,38 @@
|
||||
label: "{{ item.name }}"
|
||||
loop: "{{ get_releases.json[3:] }}"
|
||||
|
||||
- hosts: all
|
||||
- hosts: 127.0.0.1
|
||||
gather_facts: false
|
||||
connection: local
|
||||
tags: deploy_nginx
|
||||
roles:
|
||||
- name: nginx
|
||||
|
||||
- hosts: all
|
||||
gather_facts: false
|
||||
connection: local
|
||||
tags: deploy
|
||||
tags: clean_tags
|
||||
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
|
||||
diff: false
|
||||
- name: Lister les version
|
||||
ansible.builtin.uri:
|
||||
url: "{{ gitea_api_base_url }}/repos/{{ gitea_api_repository }}/releases"
|
||||
method: GET
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
register: get_releases
|
||||
|
||||
- hosts: all
|
||||
gather_facts: false
|
||||
connection: local
|
||||
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
|
||||
- name: Lister les étiquettes
|
||||
ansible.builtin.uri:
|
||||
url: "{{ gitea_api_base_url }}/repos/{{ gitea_api_repository }}/tags"
|
||||
method: GET
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
register: get_tags
|
||||
|
||||
- name: Supprimer les étiquettes n'ayant pas de version
|
||||
ansible.builtin.uri:
|
||||
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
|
||||
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
|
||||
|
||||
- name: ansible-playbook/check
|
||||
@ -69,8 +68,20 @@ steps:
|
||||
commands:
|
||||
- ansible-playbook .ansible/run.yml --tags deploy --limit 'ykn-www-2245.nyx.ykn.local'
|
||||
|
||||
- name: ansible-playbook/cache
|
||||
- name: ansible-playbook/clean_cache
|
||||
environment:
|
||||
ANSIBLE_CONFIG: .ansible/configuration/ansible.cfg
|
||||
commands:
|
||||
- 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