Clark Boylan 8eb981b47f Install docker-compose from pypi
We want to use stop_grace_period to manage gerrit service stops. This
feature was added in docker-compose 1.10 but the distro provides 1.5.
Work around this by installing docker-compose from pypi.

This seems like a useful feature and we want to manage docker-compose
the same way globally so move docker-compose installation into the
install-docker role.

New docker-compose has slightly different output that we must check for
in the gitea start/stop machinery. We also need to check for different
container name formatting in our test cases. We should pause here and
consider if this has any upgrade implications for our existing services.

Change-Id: Ia8249a2b84a2ef167ee4ffd66d7a7e7cff8e21fb
2020-04-16 12:08:00 -07:00

129 lines
2.7 KiB
YAML

- name: Ensure docker-compose directory exists
file:
state: directory
path: /etc/etherpad-docker
- name: Write settings file
template:
src: docker-compose.yaml.j2
dest: /etc/etherpad-docker/docker-compose.yaml
- name: Ensure database volume exists
file:
state: directory
path: /var/etherpad/db
- name: Ensure config directory exists
file:
state: directory
path: /etc/etherpad
- name: Ensure db config directory exists
file:
state: directory
path: /etc/etherpad/mysql
- name: Install database config settings
copy:
src: my.cnf
dest: /etc/etherpad/mysql/my.cnf
- name: Install robots.txt
copy:
src: robots.txt
dest: /var/etherpad/robots.txt
- name: Install apache2
apt:
name:
- apache2
- apache2-utils
state: present
- name: Apache modules
apache2_module:
state: present
name: "{{ item }}"
loop:
- rewrite
- proxy
- proxy_http
- ssl
- headers
- proxy_wstunnel
- name: Copy apache config
template:
src: etherpad.vhost.j2
dest: /etc/apache2/sites-enabled/000-default.conf
owner: root
group: root
mode: 0644
notify: etherpad Reload apache2
- name: Copy redirect config
template:
src: redirect.vhost.j2
dest: "/etc/apache2/sites-enabled/010-{{ etherpad_redirect_vhost }}.conf"
owner: root
group: root
mode: 0644
when: etherpad_redirect_vhost is defined
notify: etherpad Reload apache2
- name: Write settings file
template:
src: settings.json.j2
dest: /etc/etherpad/settings.json
- name: Clean up from old ep_headings hack
file:
path: /etc/etherpad/node_modules
state: absent
- name: Remove npm
package:
name:
- npm
state: absent
- name: Run docker-compose pull
shell:
cmd: docker-compose pull
chdir: /etc/etherpad-docker/
- name: Run docker-compose up
shell:
cmd: docker-compose up -d
chdir: /etc/etherpad-docker/
- name: Run docker prune to cleanup unneeded images
shell:
cmd: docker image prune -f
- name: Create db backup dest
file:
state: directory
path: /var/backups/etherpad-mariadb
mode: 0700
owner: root
group: root
- name: Set up cron job to backup the database
cron:
name: etherpad-db-backup
state: present
user: root
job: >
/usr/bin/docker-compose -f /etc/etherpad-docker/docker-compose.yaml exec -T mariadb
bash -c '/usr/bin/mysqldump --opt --databases etherpad-lite --single-transaction -uroot -p"$MYSQL_ROOT_PASSWORD"' |
gzip -9 > /var/backups/etherpad-mariadb/etherpad-mariadb.sql.gz
minute: 42
hour: 4
- name: Rotate db backups
include_role:
name: logrotate
vars:
logrotate_file_name: /var/backups/etherpad-mariadb/etherpad-mariadb.sql.gz