hosting-backend/ansible/deploy_site.yml
Alexis Bruneteau c813386e18 working
2025-06-04 21:53:28 +02:00

41 lines
1.1 KiB
YAML

- hosts: web
become: yes
vars:
static_site_local_path: "{{ lookup('env', 'PWD') }}/storage/app/private/portfolios/{{ sitename }}/{{ siteid }}"
kube_manifest_local_path: "{{ lookup('env', 'PWD') }}/storage/app/kube/{{ sitename }}"
target_path: /var/www/{{ sitename }}/{{ siteid }}
remote_kube_path: /tmp/kube/{{ sitename }}
tasks:
- name: Ensure target directory exists
file:
path: "{{ target_path }}"
state: directory
owner: root
group: root
mode: '0755'
- name: Copy static site files
copy:
src: "{{ static_site_local_path }}/"
dest: "{{ target_path }}/"
mode: '0644'
- name: Ensure remote kube directory exists
file:
path: "{{ remote_kube_path }}"
state: directory
mode: '0755'
- name: Copy kube manifests to remote server
copy:
src: "{{ kube_manifest_local_path }}/"
dest: "{{ remote_kube_path }}/"
mode: '0644'
- name: Apply Kubernetes manifests
shell: |
kubectl apply -f {{ remote_kube_path }} -n hosting-deploy
args:
executable: /bin/bash