Beginne Nextcloud-Rolle
This commit is contained in:
commit
db196d0567
15 changed files with 316 additions and 0 deletions
17
tasks/database.yml
Normal file
17
tasks/database.yml
Normal file
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
- name: "Ensure nextcloud database exists"
|
||||
mysql_db:
|
||||
name: '{{ nextcloud_mysql_db }}'
|
||||
state: present
|
||||
config_file: /etc/mysql/debian.cnf
|
||||
delegate_to: "{{ nextcloud_database_host }}"
|
||||
|
||||
# Todo: Formatierung des Nutzernamens und Zuordnung des hosts schlaegt fehl
|
||||
- name: "Ensure database user exists and has all privileges"
|
||||
mysql_user:
|
||||
name: "{{ nextcloud_mysql_user }}"
|
||||
password: "{{ lookup('password', '/tmp/passwordfile chars=ascii_letters') }}"
|
||||
priv: "{{ nextcloud_mysql_db }}.{{ inventory_hostname }}:ALL"
|
||||
state: present
|
||||
config_file: /etc/mysql/debian.cnf
|
||||
delegate_to: "{{ nextcloud_database_host }}"
|
29
tasks/gateway.yml
Normal file
29
tasks/gateway.yml
Normal file
|
@ -0,0 +1,29 @@
|
|||
---
|
||||
- name: "Add domain to cerificate list"
|
||||
lineinfile:
|
||||
path: /etc/dehydrated/domains.txt
|
||||
insertafter: "^# nextcloud"
|
||||
line: "{{ nextcloud_domain }}"
|
||||
# when: dehydrated_installiert
|
||||
delegate_to: "{{ nextcloud_gateway }}"
|
||||
|
||||
- name: "Obtain certificate"
|
||||
command: dehydrated --cron -g
|
||||
delegate_to: "{{ nextcloud_gateway }}"
|
||||
|
||||
- name: "Copy webserver site configuration"
|
||||
template:
|
||||
src: nginx_site.j2
|
||||
dest: "/etc/nginx/sites-available/{{ nextcloud_domain }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
delegate_to: "{{ nextcloud_gateway }}"
|
||||
|
||||
- name: "Enable site configuration"
|
||||
file:
|
||||
src: "/etc/nginx/sites-available/{{ nextcloud_domain }}"
|
||||
dest: "/etc/nginx/sites-enabled/{{ nextcloud_domain }}"
|
||||
state: link
|
||||
notify: reload nginx
|
||||
delegate_to: "{{ nextcloud_gateway }}"
|
7
tasks/main.yml
Normal file
7
tasks/main.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
- import_tasks: gateway.yml
|
||||
- import_tasks: database.yml
|
||||
tags: database
|
||||
- import_tasks: nextcloud.yml
|
||||
tags: nextcloud
|
||||
- import_tasks: php.yml
|
50
tasks/nextcloud.yml
Normal file
50
tasks/nextcloud.yml
Normal file
|
@ -0,0 +1,50 @@
|
|||
---
|
||||
|
||||
- name: "Ensure install dir is present"
|
||||
file:
|
||||
path: "{{ nextcloud_install_path }}"
|
||||
mode: 0755
|
||||
state: directory
|
||||
|
||||
- name: "Download und unarchive Nextcloud"
|
||||
unarchive:
|
||||
src: "{{ nextcloud_dl_url }}/{{ nextcloud_version }}.tar.bz2"
|
||||
remote_src: true
|
||||
extra_opts:
|
||||
- "--strip-components=1"
|
||||
dest: "{{ nextcloud_install_path }}"
|
||||
owner: "{{ common_name }}"
|
||||
group: "{{ common_name }}"
|
||||
mode: 0755
|
||||
|
||||
- name: "Install Nextcloud"
|
||||
command: >
|
||||
php "{{ nextcloud_install_path }}"/occ maintenance:install --database "mysql"
|
||||
--database-name "{{ nextcloud_mysql_db }}" --database-user "{{ nextcloud_mysql_user }}"
|
||||
--database-pass 2CHbJwLpXTgHQkiUnFCgoowfT7vQdt85BX7VfRBCtb --database-host "{{ nextcloud_database_host }}"
|
||||
--admin-user "{{ nextcloud_admin_user }}" --admin-pass "{{ nextcloud_admin_pw }}"
|
||||
become: true
|
||||
become_user: "{{ common_name }}"
|
||||
changed_when: true
|
||||
|
||||
- name: "Ensure trusted domains are set"
|
||||
command: 'php {{ nextcloud_install_path }}/occ config:system:set trusted_domains {{ item.0 }} --value "{{ item.1 }}"'
|
||||
become: true
|
||||
become_user: "{{ common_name }}"
|
||||
changed_when: true
|
||||
with_indexed_items:
|
||||
- '{{ nextcloud_trusted_domains }}'
|
||||
|
||||
- name: "Ensure Apache marco module is loaded"
|
||||
apache2_module:
|
||||
state: present
|
||||
name: macro
|
||||
notify: restart apache
|
||||
|
||||
- name: "Setup Apache site config"
|
||||
lineinfile:
|
||||
path: /etc/apache2/conf-available/nextcloud_sites.conf
|
||||
insertafter: "^Ansbile"
|
||||
line: "Use NCSite {{ nextcloud_domain }} {{ common_name }}"
|
||||
state: present
|
||||
notify: reload apache
|
18
tasks/php.yml
Normal file
18
tasks/php.yml
Normal file
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
|
||||
- name: "Create PHP-FPM-User"
|
||||
user:
|
||||
name: "{{ common_name }}"
|
||||
create_home: no
|
||||
password: "!"
|
||||
shell: /bin/false
|
||||
state: present
|
||||
|
||||
- name: "Copy PHP-FPM configuration"
|
||||
template:
|
||||
src: php_fpm_pool.j2
|
||||
dest: "/etc/php/{{ php_version }}/fpm/pool.d/{{ common_name }}.conf"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify: restart phpfpm
|
Loading…
Add table
Add a link
Reference in a new issue