80 lines
1.9 KiB
YAML

# tasks file for deploy-web
- name: "git archive {{ item }}"
local_action:
module: git
repo: "https://{{ git_username | urlencode }}:{{ git_password | urlencode }}@git.valczeryba.ovh/v4l3n71n/{{ item.git_name }}.git"
dest: "/home/valentin/src/"
archive: "/tmp/{{ item.git_name }}.tar.gz"
force: yes
update: yes
when: "item.git_name is defined"
with_items:
- "{{ project }}"
- name: "Create directory "
file:
path: "/var/www/{{ item.git_name }}"
state: directory
owner: www-data
group: www-data
mode: '500'
when: "item.git_name is defined"
with_items:
- "{{ project }}"
vars:
ansible_become: yes
ansible_become_method: sudo
ansible_become_password: "{{ sudo_password }}"
- name: "Extract repo "
unarchive:
src: "/tmp/{{ item.git_name }}.tar.gz"
dest: "/var/www/{{ item.git_name }}"
owner: www-data
group: www-data
mode: '500'
when: "item.git_name is defined"
with_items:
- "{{ project }}"
vars:
ansible_become: yes
ansible_become_method: sudo
ansible_become_password: "{{ sudo_password }}"
- name: "Copy configure nginx"
copy:
src: "{{ item.conf_name }}"
dest: "/etc/nginx/sites-available"
when: "item.conf_name is defined"
with_items:
- "{{ project }}"
vars:
ansible_become: yes
ansible_become_method: sudo
ansible_become_password: "{{ sudo_password }}"
- name: "Create symlink"
file:
src: "/etc/nginx/sites-available/{{ item.conf_name }}"
dest: "/etc/nginx/sites-enabled/{{ item.conf_name }}"
state: link
when: "item.conf_name is defined"
with_items:
- "{{ project }}"
vars:
ansible_become: yes
ansible_become_method: sudo
ansible_become_password: "{{ sudo_password }}"
- name: restart nginx
service:
name: nginx
state: restarted
vars:
ansible_become: yes
ansible_become_method: sudo
ansible_become_password: "{{ sudo_password }}"