Unverified Commit 11125a36 authored by Marc Crebassa's avatar Marc Crebassa Committed by GitHub
Browse files

Merge pull request #77 from egmont1227/multi-os

Added support for Multi os
parents df0cd9ac c8a0e892
......@@ -84,8 +84,6 @@ nextcloud_hsts: false # recommended >= 15552000
nextcloud_apps: {}
# [SYSTEM]
nextcloud_websrv_user: "www-data"
nextcloud_websrv_group: "www-data"
#nextcloud_mysql_root_pwd: "secret"
php_custom: false
---
# [system]
# system_configuration for php5:
php_ver: 5
php_dir: "/etc/php5"
php_bin: "php5-fpm"
php_pkg_apcu: "php5-apcu"
......
---
# [system]
# system_configuration for php 7.0:
php_ver: "7.0"
php_dir: "/etc/php/7.0"
php_bin: "php-fpm7.0"
php_pkg_apcu: "php-apcu"
......
---
# [system]
# system_configuration for php 7.0:
php_ver: "7.2"
# system_configuration for php 7.2:
php_dir: "/etc/php/7.2"
php_bin: "php-fpm7.2"
php_pkg_apcu: "php-apcu"
......
......@@ -5,14 +5,19 @@
name: mysql
state: restarted
- name: start nginx
- name: start http
service:
name: nginx
name: "{{ nextcloud_websrv }}"
state: started
- name: reload nginx
- name: restart http
service:
name: nginx
name: "{{ nextcloud_websrv }}"
state: restarted
- name: reload http
service:
name: "{{ nextcloud_websrv }}"
state: reloaded
- name: start php-fpm
......@@ -25,21 +30,6 @@
name: php{{ php_ver }}-fpm
state: reloaded
- name: start apache2
service:
name: apache2
state: started
- name: restart apache2
service:
name: apache2
state: restarted
- name: reload apache2
service:
name: apache2
state: reloaded
- name: start redis
service:
name: redis-server
......
---
- name: "[APACHE] - Required and recommended packages are installed."
package: "name={{ apache2_deps + php_pkg_spe }} state=present"
vars:
apache2_deps:
- apache2
- smbclient
- "libapache2-mod-php{{ php_ver }}"
- "php{{ php_ver }}-ldap"
- "php{{ php_ver }}-imap"
- "php{{ php_ver }}-gd"
- "php{{ php_ver }}-json"
- "php{{ php_ver }}-curl"
- "php{{ php_ver }}-intl"
# notify: start apache2
- name: "[APACHE] - the server is running"
service:
name: apache2
state: started
- name: "[APACHE] - APCu is installed."
package: "name={{ php_pkg_apcu }} state=present"
when: ansible_distribution_release not in [ "trusty" ]
- block:
# load APCu from backports as the default version for trusty is obsolete.
- name: "[APACHE] - Configure trusty backports."
apt_repository:
repo: "deb http://fr.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse"
state: present
update_cache: yes
ignore_errors: yes # fix for travis ci
- name: "[APACHE] - Install APCu from backports."
apt: "name={{ php_pkg_apcu }} state=present default_release=trusty-backports"
when: ansible_distribution_release == "trusty"
- name: "[APACHE] - enable APC for php CLI"
lineinfile:
dest: "{{ php_dir }}/cli/php.ini"
......@@ -59,7 +23,7 @@
- { regexp: 'opcache.save_comments', line: 'opcache.save_comments=1' }
- { regexp: 'opcache.revalidate_freq', line: 'opcache.revalidate_freq=1' }
# validate: "/usr/sbin/{{ php_bin }} -t #%s"
notify: reload apache2
notify: reload http
- name: "[APACHE] - Required Apache2 modules are enabled"
apache2_module: state=present name={{ item }}
......@@ -69,24 +33,24 @@
- env
- dir
- mime
notify: restart apache2
notify: restart http
- name: "[APACHE] - Ssl Apache2 module is enabled"
apache2_module: state=present name={{ item }}
with_items:
- ssl
when: (nextcloud_install_tls | bool)
notify: restart apache2
notify: restart http
- name: "[APACHE] - generate Nextcloud configuration for apache"
template:
dest: /etc/apache2/sites-available/nc_{{ nextcloud_instance_name }}.conf
src: "{{ nextcloud_websrv_template }}"
notify: reload apache2
notify: reload http
- name: "[APACHE] - Enable Nextcloud site in apache conf"
file:
path: /etc/apache2/sites-enabled/nc_{{ nextcloud_instance_name }}.conf
src: /etc/apache2/sites-available/nc_{{ nextcloud_instance_name }}.conf
state: link
notify: reload apache2
notify: reload http
---
- name: "[NGINX] - Required and recommended packages are installed."
package: "name={{ nginx_deps + php_pkg_spe }} state=present"
vars:
nginx_deps:
- nginx
- smbclient
- "php{{ php_ver }}-fpm"
- "php{{ php_ver }}-gd"
- "php{{ php_ver }}-ldap"
- "php{{ php_ver }}-imap"
- "php{{ php_ver }}-json"
- "php{{ php_ver }}-curl"
- "php{{ php_ver }}-intl"
notify: [ "start nginx", "start php-fpm" ]
- name: "[NGINX] - APCu is installed."
package: "name={{ php_pkg_apcu }} state=present"
when: ansible_distribution_release not in [ "trusty" ]
- block:
# load APCu from backports as the default version for trusty is obsolete.
- name: "[NGINX] - Configure trusty backports."
apt_repository:
repo: "deb http://fr.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse"
state: present
update_cache: yes
- name: "[NGINX] - Install APCu from backports."
apt: "name={{ php_pkg_apcu }} state=present default_release=trusty-backports"
when: ansible_distribution_release == "trusty"
- name: "[NGINX] - the server is running"
service:
name: nginx
state: started
- name: "[NGINX] - remove some commented line in php-fpm conf"
lineinfile:
dest: "{{ php_dir }}/fpm/pool.d/www.conf"
......@@ -92,24 +57,24 @@
template:
dest: /etc/nginx/sites-available/php_handler.cnf
src: templates/nginx_php_handler.j2
notify: reload nginx
notify: reload http
- name: "[NGINX] - php handler is enabled"
file:
path: /etc/nginx/sites-enabled/php_handler
src: /etc/nginx/sites-available/php_handler.cnf
state: link
notify: reload nginx
notify: reload http
- name: "[NGINX] - generate Nextcloud configuration for nginx"
template:
dest: /etc/nginx/sites-available/nc_{{ nextcloud_instance_name }}.cnf
src: "{{ nextcloud_websrv_template }}"
notify: reload nginx
notify: reload http
- name: "[NGINX] - Enable Nextcloud in nginx conf"
file:
path: /etc/nginx/sites-enabled/nc_{{ nextcloud_instance_name }}
src: /etc/nginx/sites-available/nc_{{ nextcloud_instance_name }}.cnf
state: link
notify: reload nginx
notify: reload http
---
# tasks file for nextcloud
# load os specific variables
- include_tasks: ./setup_env.yml
tags: always
# load os specific variables
# install required packages
- include_tasks: php_install.yml
tags: always
- block:
- name: Verify permission for installed TLS certificates
......
......@@ -52,7 +52,7 @@
vars:
# mariadb is equal to mysql for occ
nextcloud_tmp_backend: "{{ 'mysql' if nextcloud_db_backend == 'mariadb' else nextcloud_db_backend }}"
notify: "reload {{ nextcloud_websrv }}"
notify: reload http
- name: "[NC] - Verify config.php - check filesize"
stat: path="{{ nextcloud_webroot }}/config/config.php"
......
---
- name: "[INSTALL] - Required and recommended packages are installed."
package:
name: "{{ item }}"
state: present
with_items:
- "{{ nextcloud_websrv }}"
- smbclient
- "php{{ php_ver }}-gd"
- "php{{ php_ver }}-ldap"
- "php{{ php_ver }}-imap"
- "php{{ php_ver }}-json"
- "php{{ php_ver }}-curl"
- "php{{ php_ver }}-intl"
- "php{{ php_ver }}-mcrypt"
notify:
- start http
- name: "[INSTALL] - Apache Required package is installed."
package:
name: "libapache2-mod-php{{ php_ver }}"
state: present
when: nextcloud_websrv == "apache2"
notify:
- start http
- name: "[INSTALL] - NGINX Required package is installed."
package:
name: "php{{ php_ver }}-fpm"
state: present
when: nextcloud_websrv == "nginx"
notify:
- start http
- start php-fpm
- name: "[INSTALL] - PHP extra Packages are installed."
package:
name: "{{ item }}"
state: present
with_items:
- "{{ php_pkg_spe }}"
- name: "[INSTALL] - APCu is installed."
package:
name: "{{ php_pkg_apcu }}"
state: present
when : ansible_distribution_release not in [ "trusty" ]
- block:
# load APCu from backports as the default version for trusty is obsolete.
- name: "[INSTALL] - Configure trusty backports."
apt_repository:
repo: "deb http://fr.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse"
state: present
update_cache: yes
- name: "[INSTALL] - Install APCu from backports."
package:
name: "{{ php_pkg_apcu }}"
state: latest
default_release: trusty-backports
when: ansible_distribution_release == "trusty"
......@@ -5,26 +5,27 @@
msg: "New versions require nextcloud_trusted_domain to be declared as a list."
when: nextcloud_trusted_domain is string
- name: "[ENV] include OS static vars"
include_vars: '{{ item }}'
loop:
- '{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml'
- '{{ ansible_os_family }}.yml'
- name: "[ENV] - ca-certificate are up to date"
# needed for downloading from download.nextcloud.com as the site use letsencrypt certificates
# letsencrypt may not be trusted on older OS
apt: cache_valid_time=86400 update_cache=yes name=ca-certificates state=latest # noqa 403
apt:
name: "{{ item }}"
state: present
update_cache: yes
cache_valid_time: 86400
loop:
- acl
- ca-certificates
when: ansible_os_family in [ "Debian" ]
- block:
- name: "[ENV] - Load environment for OS using php 5"
include_vars: "{{ role_path }}/defaults/php5_env.yml"
when: ansible_distribution_release in [ "trusty", "jessie" ]
- name: "[ENV] - Load environment for OS using php 7.0"
include_vars: "{{ role_path }}/defaults/php7.0_env.yml"
when: ansible_distribution_release in [ "xenial", "stretch" ]
- name: "[ENV] - Load environment for OS using php 7.2"
include_vars: "{{ role_path }}/defaults/php7.2_env.yml"
when: ansible_distribution_release in [ "bionic" ]
when: not php_custom
- name: "[ENV] - Load PHP environment from OS specific variable"
include_vars: "../defaults/php{{ php_ver }}_env.yml"
# fix for debian not using sudo :
# finding out if sudo is installed or not
......@@ -44,9 +45,3 @@
- nc_sudo_installed_result.rc is defined
- nc_sudo_installed_result.rc != 0
# fix for ubuntu 14.04 with permission issue for unprivileged user :
- name: "[NC] - Adding ACL on trusty."
apt:
name: acl
state: present
when: ansible_distribution_release == "trusty"
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
config.vm.define "ubuntu-trusty" do |vagrant1|
vagrant1.vm.box = "ubuntu/trusty64"
vagrant1.vm.synced_folder ".", "/vagrant", disabled: true
vagrant1.ssh.forward_agent = true
vagrant1.vm.network "forwarded_port", guest: 80, host: 18080
vagrant1.vm.provision "ansible" do |ansible|
ansible.playbook = "vagrant.yml"
end
end
config.vm.define "debian-jessie" do |vagrant1|
vagrant1.vm.box = "debian/jessie64"
vagrant1.vm.synced_folder ".", "/vagrant", disabled: true
vagrant1.ssh.forward_agent = true
vagrant1.vm.network "forwarded_port", guest: 80, host: 18080
vagrant1.vm.provision "ansible" do |ansible|
ansible.playbook = "vagrant.yml"
end
end
config.vm.define "ubuntu-xenial" do |vagrant1|
vagrant1.vm.box = "ubuntu/xenial64"
vagrant1.vm.synced_folder ".", "/vagrant", disabled: true
vagrant1.ssh.forward_agent = true
vagrant1.vm.network "forwarded_port", guest: 80, host: 18080
vagrant1.vm.provision "shell",
inline: "apt install -y python-minimal"
vagrant1.vm.provision "ansible" do |ansible|
ansible.playbook = "vagrant.yml"
end
end
config.vm.define "debian-stretch" do |vagrant1|
vagrant1.vm.box = "debian/stretch64"
vagrant1.vm.synced_folder ".", "/vagrant", disabled: true
vagrant1.ssh.forward_agent = true
vagrant1.vm.network "forwarded_port", guest: 80, host: 18080
vagrant1.vm.provision "ansible" do |ansible|
ansible.playbook = "vagrant.yml"
end
end
config.vm.define "ubuntu-bionic" do |vagrant1|
vagrant1.vm.box = "ubuntu/bionic64"
vagrant1.vm.synced_folder ".", "/vagrant", disabled: true
vagrant1.ssh.forward_agent = true
vagrant1.vm.network "forwarded_port", guest: 80, host: 18080
vagrant1.vm.provision "shell",
inline: "apt install -y python-minimal"
vagrant1.vm.provision "ansible" do |ansible|
ansible.playbook = "vagrant.yml"
end
end
config.vm.define "centos7" do |vagrant1|
vagrant1.vm.box = "centos/7"
vagrant1.vm.synced_folder ".", "/vagrant", disabled: true
vagrant1.ssh.forward_agent = true
vagrant1.vm.network "forwarded_port", guest: 80, host: 18080
vagrant1.vm.provision "ansible" do |ansible|
ansible.playbook = "vagrant.yml"
end
end
end
---
- hosts:
- debian-jessie
- ubuntu-trusty
- debian-stretch
- ubuntu-xenial
- ubuntu-bionic
- centos7
become: True
remote_user: root
vars:
nextcloud_full_url: https://download.nextcloud.com/server/releases/nextcloud-15.0.12.zip
nextcloud_version_major: 15
nextcloud_websrv: "apache2"
nextcloud_webroot: "/srv/nextcloud/webroot"
nextcloud_db_backend: "mysql"
nextcloud_install_redis_server: true
nextcloud_apps:
files_external: ""
roles:
- ../../aalaesar.install_nextcloud
---
nextcloud_websrv_user: "www-data"
nextcloud_websrv_group: "www-data"
---
php_ver: 7.2
Debian-jessie.yml
\ No newline at end of file
Debian-stretch.yml
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment