ansible-role-nextcloud/tasks/base.yml
2022-06-07 19:25:22 +02:00

115 lines
3.2 KiB
YAML

- name: pin nextcloud version
template:
src: apt-preferences.j2
dest: /etc/apt/preferences.d/nextcloud
mode: '0644'
- name: setup cccv repo key
apt_key:
url: "https://packages.cccv.de/docs/cccv-archive-key.gpg"
- name: add cccv infrapackages-nextcloud repo
apt_repository:
repo: "deb https://packages.cccv.de/infrapackages-nextcloud/ {{ ansible_distribution_release|lower }} main"
- name: install nextcloud
apt:
pkg:
- nextcloud
- name: create nextcloud datadir
file:
path: "{{ nextcloud.datadir }}"
owner: www-data
group: www-data
mode: 0770
state: directory
- name: ensure apc is used on the cli as well
copy:
dest: "/etc/php/{{ php_version }}/cli/conf.d/enable-apc-cli.ini"
owner: root
group: root
mode: 0644
content: |
apc.enable_cli = 1
- name: check nextcloud install status
check_mode: no
shell: "nextcloud-occ status"
register: nextcloud_status_check
changed_when: false
- name: setup nextcloud
when: "'installed: false' in nextcloud_status_check.stdout"
command:
argv:
- nextcloud-occ
- maintenance:install
- -n
- --database
- mysql
- --database-name
- '{{ nextcloud.db.name }}'
- --database-user
- '{{ nextcloud.db.user }}'
- --database-pass
- '{{ nextcloud.db.pw }}'
- --admin-user
- '{{ nextcloud.admin.name }}'
- --admin-pass
- '{{ nextcloud.admin.pw }}'
- --data-dir
- '{{ nextcloud.datadir }}'
- name: set nextcloud trusted domains
command: # noqa no-changed-when
argv:
- nextcloud-occ
- config:system:set
- trusted_domains
- 1
- --value
- "{{ nextcloud.externalurl }}"
- name: set other nextcloud config values
command: # noqa no-changed-when
argv:
- nextcloud-occ
- config:system:set
- "{{ item.key }}"
- --value
- "{{ item.value }}"
with_items:
- { key: "mail_from_address", value: "{{ nextcloud.mail.from }}" }
- { key: "mail_domain", value: "{{ nextcloud.mail.domain }}" }
- { key: "mail_smtpmode", value: "{{ nextcloud.mail.mode }}" }
- { key: "mail_smtpauthtype", value: "PLAIN" }
- { key: "mail_smtphost", value: "{{ nextcloud.mail.server|d('') }}" }
- { key: "mail_smtpport", value: "25" }
- { key: "mail_smtppassword", value: "{{ nextcloud.mail.password|d('') }}" }
- { key: "mail_smtpname", value: "{{ nextcloud.mail.user|d('') }}" }
- { key: "memcache.local", value: '{{ "\OC\Memcache\APCu" }}' }
- { key: "datadirectory", value: "{{ nextcloud.datadir }}" }
- { key: "defaultapp", value: "files" }
- { key: "default_phone_region", value: "DE" }
- { key: "overwrite.cli.url", value: "https://{{ nextcloud.externalurl }}"}
- { key: "profile.enabled", value: "false"}
- name: copy nextcloud nginx config
template:
src: nginx.j2
dest: /etc/nginx/sites-available/nextcloud
owner: root
group: root
mode: 0644
notify:
- restart nginx
- name: enable nextcloud for nginx
file:
src: /etc/nginx/sites-available/nextcloud
dest: /etc/nginx/sites-enabled/nextcloud
state: link
notify:
- restart nginx