finished setup of lamp stack plus owncloud src. testing needed.

This commit is contained in:
2024-11-29 16:46:55 +01:00
parent bb209219aa
commit 8eb001f390
12 changed files with 198 additions and 1 deletions

View File

@@ -0,0 +1,4 @@
domain_base: softbox.net
hostname: owncloud.{{ domain_base }}
owncloud_core_path: "/var/www/owncloud"

View File

@@ -0,0 +1,5 @@
---
- name: restart apache
service:
name: apache2
state: restarted

View File

@@ -0,0 +1,35 @@
- name: Set hostname
ansible.builtin.hostname:
name: "{{ hostname}}"
- name: "Enable recommended Apache Modules."
apache2_module: "name={{ item }} state=present"
with_items:
- dir
- env
- headers
- mime
- rewrite
- setenvif
notify: restart apache
- name: Add Apache virtualhost for Owncloud
template:
src: "templates/owncloud.dav.conf.j2"
dest: "/etc/apache2/sites-available/owncloud.dav.conf"
owner: root
group: root
mode: 0644
notify: restart apache
- name: Enable the ownCloud site.
command: >
a2ensite owncloud.dav
creates=/etc/apache2/sites-enabled/owncloud.dav.conf
notify: restart apache
- name: Disable the default site.
command: >
a2dissite 000-default
removes=/etc/apache2/sites-enabled/000-default.conf
notify: restart apache

View File

@@ -0,0 +1,61 @@
---
- name: Get software for apt repository management.
apt:
state: present
name:
- python3-apt
- python3-pycurl
- name: Add ondrej repository for later versions of PHP.
apt_repository:
repo: "ppa:ondrej/php"
update_cache: yes
- name: "Install Apache, MySQL, PHP, and other dependencies."
apt:
state: present
name:
- acl
- git
- curl
- wget
- unzip
- openssl
- redis-server
- mariadb-server
- libpcre3-dev
- apache2
- libapache2-mod-php7.4
- php7.4
- php7.4-imagick
- php7.4-common
- php7.4-curl
- php7.4-gd
- php7.4-imap
- php7.4-intl
- php7.4-json
- php7.4-mbstring
- php7.4-gmp
- php7.4-bcmath
- php7.4-mysql
- php7.4-ssh2
- php7.4-xml
- php7.4-zip
- php7.4-apcu
- php7.4-redis
- php7.4-ldap
- php-phpseclib
- bzip2
- rsync
- jq
- inetutils-ping
- ldap-utils
- name: Disable the firewall (since this is behind a firewall)
service: name=ufw state=stopped
- name: "Start Apache, MySQL, and PHP."
service: "name={{ item }} state=started enabled=yes"
with_items:
- apache2
- mysql

View File

@@ -0,0 +1,24 @@
---
- name: Install LAMP stack dependencies
include_tasks:
file: dependencies.yml
- name: Configure Apache.
include_tasks:
file: apache.yml
- name: Configure PHP.
include_tasks:
file: php.yml
- name: Configure MySQL.
include_tasks:
file: mysql.yml
- name: Create occ helper script.
include_tasks:
file: occ.yml
- name: Download ownCloud.
include_tasks:
file: owncloud.yml

View File

@@ -0,0 +1,7 @@
- name: Create a MySQL database for ownCloud.
mysql_user:
name: "owncloud"
password: "{{ mysql_passwd }}"
priv: "owncloud.*:ALL"
host: localhost
state: present

View File

@@ -0,0 +1,7 @@
- name: Create a helper script for running occ commands.
template:
src: "templates/occ.j2"
dest: "/usr/local/bin/occ"
owner: root
group: root
mode: 0755

View File

@@ -0,0 +1,17 @@
---
- name: Download ownCloud source.
ansible.builtin.get_url:
url: https://download.owncloud.com/server/stable/owncloud-complete-latest.tar.bz2
dest: "/tmp/owncloud-complete-latest.tar.bz2"
- name: Extract the archive.
ansible.builtin.unarchive:
src: "/tmp/owncloud-complete-latest.tar.bz2"
dest: "/var/www/owncloud"
owner: www-data
- name: Configure ownCloud's trusted domains
command: >
my_ip=$(hostname -I|cut -f1 -d ' ')
occ config:system:set trusted_domains 1 --value="$my_ip"
occ config:system:set trusted_domains 2 --value="{{ hostname }}"

View File

@@ -0,0 +1,8 @@
---
- name: Adjust OpCache memory setting.
lineinfile:
dest: "/etc/php/7.4/apache2/conf.d/10-opcache.ini"
regexp: "^opcache.memory_consumption"
line: "opcache.memory_consumption = 96"
state: present
notify: restart apache

View File

@@ -0,0 +1,4 @@
#!/bin/bash
cd /var/www/owncloud
sudo -E -u www-data /usr/bin/php /var/www/owncloud/occ "$@"

View File

@@ -0,0 +1,17 @@
<VirtualHost *:80>
ServerName {{ hostname }}
DirectoryIndex index.php index.html
DocumentRoot /var/www/owncloud
<Directory /var/www/owncloud>
Options +FollowSymlinks -Indexes
AllowOverride All
Require all granted
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/owncloud
SetEnv HTTP_HOME /var/www/owncloud
</Directory>
</VirtualHost>

10
run.yml
View File

@@ -20,7 +20,15 @@
become: yes
vars_files:
- "vars/vault.yml"
pre_tasks:
- name: Update apt cache.
apt:
update_cache: true
cache_valid_time: 3600
when: ansible_os_family == 'Debian'
roles:
- role: geerlingguy.security
#- role: geerlingguy.ntp ## NEEDED?
#- role: owncloud
- role: owncloud