DEV Community

César M. Cristóbal for CallePuzzle Dev

Posted on • Originally published at dev.callepuzzle.com

2 2

Desplegar Nextcloud en Docker usando Ansible

Nextcloud nos permite tener nuestro propio servidor de archivos a lo Dropbox. Pero a mí lo que más me gusta es poder tener mi calendario y mis contactos independiente del todopoderoso Google.

Vamos a ver como podemos desplegar Nextcloud en una Debian usando Docker y todo ello automatizado con Ansible.

El esquema que vamos a tener es una máquina Debian con tres contenedores dentro:

  • haproxy
  • nextcloud
  • mariadb

Nextcloud containerized

Requisitos

  • Tener acceso root a la máquina Debian.
  • Tener instalado Ansible.

A mí personalmente me gusta instalar Ansible en un virtualenv de python:

$ virtualenv3 venv/py3
$ source venv/py3/bin/activate
(py3)$ pip install ansible
Enter fullscreen mode Exit fullscreen mode

Instalamos los roles necesarios:

(py3)$ ansible-galaxy install jilgue.ansible_role_docker_nextcloud
(py3)$ ansible-galaxy install jilgue.ansible_role_docker_haproxy
Enter fullscreen mode Exit fullscreen mode

Playbook

A continuación vamos a generar la configuración de Ansible.

Necesitamos generar el inventario:

nextcloud ansible_ssh_host=192.168.56.20
Enter fullscreen mode Exit fullscreen mode

También la configuracion del haproxy:

global
    daemon
    maxconn 256

defaults
    mode http
    timeout connect 5000ms
    timeout client 50000ms
    timeout server 50000ms

frontend http-in
    bind *:80
    mode http
    default_backend servers

backend servers
    server server1 nextcloud:80 maxconn 32
Enter fullscreen mode Exit fullscreen mode

Y por último el playbook:

---
- hosts: all
  become: true
  become_method: sudo

  vars:
    nextcloud_trusted_domains: 192.168.56.20
    nextcloud_ports: []
    haproxy_cfg_template_path: "{{ playbook_dir }}/"
    haproxy_links:
      - nextcloud
    haproxy_ports:
      - 80:80

  roles:
    - { role: nextcloud, tags: [ 'nextcloud' ] }
    - { role: haproxy, tags: [ 'haproxy' ] }
Enter fullscreen mode Exit fullscreen mode

Y con esto tendríamos todo, al aplicar el playbook y entrar en la url http://192.168.56.20/ podremos ver nuestro nextcloud instalado.

El usuario y contraseña por defecto son admin / admin.

Nextcloud welcome

Podéis ver la configuración de mi propio servidor en github.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more