Added a nextcloud role
Added a Nextcloud installation and set a static IP in vagrant.
This commit is contained in:
parent
82180d6b0d
commit
7f377e676d
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,6 @@
|
||||
# Vagrant files
|
||||
.vagrant
|
||||
|
||||
# Unneeded ansible file
|
||||
*.retry
|
||||
|
||||
|
14
Vagrantfile
vendored
14
Vagrantfile
vendored
@ -21,6 +21,9 @@ Vagrant.configure("2") do |config|
|
||||
config.vm.box = "debian/stretch64"
|
||||
config.vm.synced_folder ".", "/vagrant", disabled: true
|
||||
|
||||
# Set static IP
|
||||
config.vm.network "private_network", ip: "192.168.121.2"
|
||||
|
||||
# Machine Name
|
||||
config.vm.define :frita do |frita| #
|
||||
end
|
||||
@ -36,14 +39,5 @@ Vagrant.configure("2") do |config|
|
||||
ansible.playbook = "site.yml"
|
||||
end
|
||||
|
||||
# Display IP below
|
||||
config.vm.provision "shell" do |s|
|
||||
s.inline = "
|
||||
ip a | grep 192.168 |
|
||||
awk '{
|
||||
print substr($2, 1, index($2,\"/\") - 1);
|
||||
}'
|
||||
"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
3
ansible.cfg
Normal file
3
ansible.cfg
Normal file
@ -0,0 +1,3 @@
|
||||
[ssh_connection]
|
||||
pipelining=True
|
||||
|
@ -9,13 +9,38 @@ wp_version: 5.0.2
|
||||
wp_sha1_hash: 4a6971d35eb92e2fc30034141b1c865e8c156add
|
||||
|
||||
# WordPress Home Directory
|
||||
# Note: value is a directory is without trailing '/'
|
||||
# Note: value is a directory without trailing '/'
|
||||
wp_dir: /var/www/wordpress
|
||||
|
||||
# Database Settings
|
||||
# WordPress Database Settings
|
||||
wp_db_host: localhost
|
||||
wp_db_name: wordpress
|
||||
wp_db_user: wordpress_user
|
||||
wp_db_pass: Password1
|
||||
wp_db_table_prefix: wp_
|
||||
|
||||
|
||||
### Nextcloud Configuration ###
|
||||
|
||||
# Domain
|
||||
nc_domain: cloud.freeitathens.org
|
||||
nc_admin_email: contact@freeitathens.org
|
||||
|
||||
# Version of Nextcloud to deploy
|
||||
nc_version: 15.0.2
|
||||
nc_sha256_hash: c1f4cc33e39994ddbe6777370b62c30b7ae52136a0530c0b9922770803ca0fea
|
||||
|
||||
# Nextcloud Home Directory
|
||||
# Note: value is a directory without trailing '/'
|
||||
nc_dir: /var/www/nextcloud
|
||||
|
||||
# Nextcloud Database Settings
|
||||
nc_db_host: localhost
|
||||
nc_db_name: nextcloud
|
||||
nc_db_user: nextcloud_user
|
||||
nc_db_pass: Password1
|
||||
|
||||
# Nextcloud Admin
|
||||
nc_admin: admin
|
||||
nc_admin_pass: Password1
|
||||
|
||||
|
134
roles/nextcloud/tasks/main.yml
Normal file
134
roles/nextcloud/tasks/main.yml
Normal file
@ -0,0 +1,134 @@
|
||||
# Copyright (C) 2019 Free I.T. Athens
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# psycopg2 is required for database tasks
|
||||
- name: Install PostgreSQL Support for Python
|
||||
apt: name=python-psycopg2 state=present
|
||||
|
||||
- name: Install PostgreSQL
|
||||
apt: name=postgresql state=present
|
||||
|
||||
- name: Create Database
|
||||
postgresql_db:
|
||||
name: "{{ nc_db_name }}"
|
||||
state: present
|
||||
become_user: postgres
|
||||
|
||||
- name: Create Database User
|
||||
postgresql_user:
|
||||
user: "{{ nc_db_user }}"
|
||||
password: "{{ nc_db_pass }}"
|
||||
db: "{{ nc_db_name }}"
|
||||
state: present
|
||||
become_user: postgres
|
||||
|
||||
- name: Add Database User Permissions
|
||||
postgresql_privs:
|
||||
db: "{{ nc_db_name }}"
|
||||
role: "{{ nc_db_user }}"
|
||||
objs: ALL_IN_SCHEMA
|
||||
privs: SELECT,INSERT,UPDATE,DELETE
|
||||
become_user: postgres
|
||||
|
||||
- name: Install PHP Modules
|
||||
apt:
|
||||
name: [
|
||||
# Required
|
||||
'php-ctype', 'php-curl', 'php-dom',
|
||||
'php-gd', 'php-iconv', 'php-json', 'php-xml',
|
||||
'php-mbstring', 'php-posix', 'php-simplexml',
|
||||
'php-xmlreader', 'php-xmlwriter', 'php-zip',
|
||||
|
||||
# Database Connectors
|
||||
'php-pgsql',
|
||||
|
||||
# Recommended Packages
|
||||
'php-fileinfo', 'php-bz2', 'php-intl',
|
||||
|
||||
# Enhanced Performance
|
||||
'php-redis', 'redis-server',
|
||||
|
||||
# Preview Generation
|
||||
'php-imagick'
|
||||
]
|
||||
state: present
|
||||
notify: Reload Apache2
|
||||
|
||||
- name: Create Public HTML Directory
|
||||
file:
|
||||
path: "{{ nc_dir }}/public_html"
|
||||
state: directory
|
||||
|
||||
- name: Create Nextcloud Directories
|
||||
file:
|
||||
path: "{{ nc_dir }}/public_html/data"
|
||||
state: directory
|
||||
owner: www-data
|
||||
group: www-data
|
||||
|
||||
- name: Create Logs Directory
|
||||
file:
|
||||
path: "{{ nc_dir }}/logs"
|
||||
state: directory
|
||||
|
||||
- name: Download Nextcloud
|
||||
get_url:
|
||||
url: "https://download.nextcloud.com/server/releases/\
|
||||
nextcloud-{{ nc_version }}.tar.bz2"
|
||||
dest: /tmp/nextcloud-{{ nc_version }}.tar.bz2
|
||||
checksum: sha256:{{ nc_sha256_hash }}
|
||||
|
||||
- name: Extract Nextcloud
|
||||
unarchive:
|
||||
src: /tmp/nextcloud-{{ nc_version }}.tar.bz2
|
||||
dest: "{{ nc_dir }}/public_html"
|
||||
owner: www-data
|
||||
group: www-data
|
||||
extra_opts: [--strip-components=1]
|
||||
remote_src: yes
|
||||
|
||||
- name: Install Nextcloud
|
||||
command: |
|
||||
php occ maintenance:install --database pgsql \
|
||||
--database-name {{ nc_db_name }} --database-host {{ nc_db_host }} \
|
||||
--database-user {{ nc_db_user }} --database-pass {{ nc_db_pass }} \
|
||||
--admin-user {{ nc_admin }} --admin-pass {{ nc_admin_pass }} \
|
||||
--data-dir {{ nc_dir }}/public_html/data
|
||||
become_user: www-data
|
||||
args:
|
||||
chdir: "{{ nc_dir }}/public_html"
|
||||
creates: "{{ nc_dir }}/public_html/config/config.php"
|
||||
|
||||
- name: Add Domain Name to Trusted Domains
|
||||
command: |
|
||||
php occ config:system:set trusted_domains 0 --value={{ nc_domain }}
|
||||
become_user: www-data
|
||||
args:
|
||||
chdir: "{{ nc_dir }}/public_html"
|
||||
|
||||
- name: "Enable Apache2 Module: rewrite"
|
||||
apache2_module: name=rewrite state=present
|
||||
|
||||
- name: Apply Apache Configuration
|
||||
template:
|
||||
src: nextcloud.conf.j2
|
||||
dest: /etc/apache2/sites-available/{{ nc_domain }}.conf
|
||||
notify: Reload Apache2
|
||||
|
||||
- name: Enable Apache Website
|
||||
shell: a2ensite {{ nc_domain }}
|
||||
args:
|
||||
creates: /etc/apache2/sites-enabled/{{ nc_domain }}.conf
|
||||
notify: Reload Apache2
|
||||
|
26
roles/nextcloud/templates/nextcloud.conf.j2
Normal file
26
roles/nextcloud/templates/nextcloud.conf.j2
Normal file
@ -0,0 +1,26 @@
|
||||
<VirtualHost *:80>
|
||||
ServerName {{ nc_domain }}
|
||||
|
||||
ServerAdmin {{ nc_admin_email }}
|
||||
DocumentRoot {{ nc_dir }}/public_html
|
||||
|
||||
<Directory {{ nc_dir }}/public_html>
|
||||
|
||||
Options +FollowSymLinks
|
||||
AllowOverride All
|
||||
|
||||
<IfModule mod_dav.c>
|
||||
Dav off
|
||||
</IfModule>
|
||||
|
||||
SetEnv HOME {{ nc_dir }}/public_html
|
||||
SetEnv HTTP_HOME {{ nc_dir }}/public_html
|
||||
|
||||
</Directory>
|
||||
|
||||
ErrorLog {{ nc_dir }}/logs/error.log
|
||||
CustomLog {{ nc_dir }}/logs/access.log combined
|
||||
</VirtualHost>
|
||||
|
||||
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
|
||||
|
Loading…
Reference in New Issue
Block a user