1
0
Fork 0

Create playbooks

This commit is contained in:
Ethanell 2022-05-02 17:37:21 +02:00
parent 7526625df8
commit bf5873560c
8 changed files with 117 additions and 11 deletions

View file

@ -0,0 +1,17 @@
---
- name: "Unzip"
ansible.builtin.unarchive:
src: "{{ ansistrano_release_path.stdout }}/projectsend-{{ release }}.zip"
dest: "{{ ansistrano_release_path.stdout }}"
remote_src: true
- name: "Remove archive"
file:
path: "{{ ansistrano_release_path.stdout }}/projectsend-{{ release }}.zip"
state: absent
#- name: "Update dependencies"
# include_tasks: "dependencies.yml"
- name: "Configure"
include_tasks: "configure.yml"

View file

@ -0,0 +1,16 @@
---
- name: "Copy sample"
copy:
src: "{{ ansistrano_release_path.stdout }}/includes/sys.config.sample.php"
dest: "{{ ansistrano_release_path.stdout }}/includes/sys.config.php"
remote_src: true
- name: "Setup DB"
ansible.builtin.lineinfile:
path: "{{ ansistrano_release_path.stdout }}/includes/sys.config.php"
regexp: "{{ item.regex }}"
line: "{{ item.line }}"
loop:
- {regex: "^define\\('DB_NAME', '.*'\\);$", line: "define('DB_NAME', '{{ db_name }}');"}
- {regex: "^define\\('DB_USER', '.*'\\);$", line: "define('DB_USER', '{{ db_user }}');"}
- {regex: "^define\\('DB_PASSWORD', '.*'\\);$", line: "define('DB_PASSWORD', '{{ db_password }}');"}

View file

@ -0,0 +1,15 @@
---
- name: "Install PHP dependencies"
community.general.composer:
command: install
working_dir: "{{ ansistrano_release_path.stdout }}"
- name: "Install JS dependencies"
community.general.npm:
path: "{{ ansistrano_release_path.stdout }}"
- name: "Compile SCSS"
ansible.builtin.command:
cmd: "./node_modules/gulp/bin/gulp.js"
chdir: "{{ ansistrano_release_path.stdout }}"
#Todo: creates: ""

9
hosts.yml Normal file
View file

@ -0,0 +1,9 @@
all:
hosts:
ubuntu:
vars:
scope: "prod"
release: "r1335"
db_name: "projectsend_{{ scope }}"
db_user: "projectsend_{{ scope }}"
db_password: "test"

38
playbook-app.yml Normal file
View file

@ -0,0 +1,38 @@
- name: "App Install"
hosts: "all"
become: true
become_user: www-data
vars:
proxy: "http://proxy.univ-lyon1.fr:3128/"
ansistrano_deploy_from: "{{ playbook_dir }}/" # Where my local project is (relative or absolute path)
ansistrano_deploy_to: "/var/www/{{ scope }}/projectsend" # Base path to deploy to.
ansistrano_keep_releases: 2 # Releases to keep after a new deployment. See "Pruning old releases".
ansistrano_shared_paths:
- upload
# Shared paths and basedir shared files creation.
# By default the shared paths directories and base directories for shared files are created automatically if not exists. But in some scenarios those paths could be symlinks to another directories in the filesystem, and the deployment process would fails. With these variables you can disable the involved tasks. If you have two or three shared paths, and don't need creation only for some of them, you always could disable the automatic creation and add a custom task in a hook.
ansistrano_ensure_shared_paths_exist: yes
ansistrano_ensure_basedirs_shared_files_exist: yes
# Deployment strategy - method used to deliver code. Options are copy, download, git, rsync, rsync_direct, svn, or s3.
ansistrano_deploy_via: download
# Copy, download and s3 have an optional step to unarchive the downloaded file which can be used by adding _unarchive.
# The rsync_direct strategy omits a file copy on the target offering a slight speed increase if you are deploying to shared hosts, are experiancing bad file-performance, or serve static assets from the same host you deploy your app to and rsync many files.
# You can check all the options inside tasks/update-code folder!
ansistrano_allow_anonymous_stats: no
ansistrano_get_url: "https://github.com/projectsend/projectsend/releases/download/{{ release }}/projectsend-{{ release }}.zip"
# Hooks: custom tasks if you need them
ansistrano_after_update_code_tasks_file: "{{ playbook_dir }}/ansistrano_tasks/after_update.yml"
environment:
http_proxy: "{{ proxy }}"
https_proxy: "{{ proxy }}"
APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE: DontWarn
roles:
- ansistrano.deploy

View file

@ -1,11 +0,0 @@
- name: Server Install
hosts: "localhost"
### Pour eviter les problème de timeout sur le server lors d'installation de key
### Config à ajouter en début de playbook
vars:
proxy: "http://proxy.univ-lyon1.fr:3128/"
environment:
http_proxy: "{{proxy}}"
https_proxy: "{{proxy}}"
APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE: DontWarn

17
playbook-server.yml Normal file
View file

@ -0,0 +1,17 @@
- name: "Server Install"
hosts: "all"
become: true
vars:
proxy: "http://proxy.univ-lyon1.fr:3128/"
environment:
http_proxy: "{{ proxy }}"
https_proxy: "{{ proxy }}"
APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE: DontWarn
roles:
- apt
- mariadb
- php
- nodejs
- nginx

5
playbook.yml Normal file
View file

@ -0,0 +1,5 @@
- name: "Setup server"
import_playbook: playbook-server.yml
- name: "Setup app"
import_playbook: playbook-app.yml