System configuration for the OpenDev Collaboratory
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

154 lines
3.4 KiB

- name: Ensure docker-compose directory exists
file:
state: directory
path: /etc/refstack-docker
mode: 0700
- name: Write docker-compose file
template:
src: docker-compose.yaml.j2
dest: /etc/refstack-docker/docker-compose.yaml
mode: 0600
- 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: refstack.vhost.j2
dest: /etc/apache2/sites-enabled/000-default.conf
owner: root
group: root
mode: 0644
notify: refstack Reload apache2
- name: Create refstack storage
file:
state: directory
path: /var/lib/refstack/
owner: root
group: root
mode: 0755
- name: Create refstack config storage area
file:
state: directory
path: /var/lib/refstack/etc
owner: root
group: root
mode: 0755
- name: Create refstack data storage area
file:
state: directory
path: /var/lib/refstack/data
owner: root
group: root
mode: 0755
- name: Create refstack www storage area
file:
state: directory
path: /var/lib/refstack/www
owner: root
group: root
mode: 0755
- name: Create refstack db storage area
file:
state: directory
path: /var/lib/refstack/db
owner: root
group: root
mode: 0755
- name: Copy hound robots.txt
copy:
src: robots.txt
dest: /var/lib/refstack/www/robots.txt
- name: Write refstack.conf
template:
src: refstack.conf.j2
dest: /var/lib/refstack/etc/refstack.conf
- name: Write config.json
template:
src: config.json.j2
dest: /var/lib/refstack/etc/config.json
- name: Install distro packages
package:
name:
- docker-compose
state: present
- name: Run docker-compose pull
shell:
cmd: docker-compose pull
chdir: /etc/refstack-docker/
- name: Run docker-compose up
shell:
cmd: docker-compose up -d --timeout 60
chdir: /etc/refstack-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/refstack-mariadb
mode: 0700
owner: root
group: root
- name: Set up cron job to backup the database
cron:
name: refstack-db-backup
state: present
user: root
job: >
/usr/bin/docker-compose -f /etc/refstack-docker/docker-compose.yaml exec -T mariadb
bash -c '/usr/bin/mysqldump --opt --databases refstack --single-transaction -uroot -p"$MYSQL_ROOT_PASSWORD"' |
gzip -9 > /var/backups/refstack-mariadb/refstack-mariadb.sql.gz
minute: "42"
hour: "4"
- name: Rotate db backups
include_role:
name: logrotate
vars:
logrotate_file_name: /var/backups/refstack-mariadb/refstack-mariadb.sql.gz
- name: Setup db backup streaming job
block:
- name: Create backup streaming config dir
file:
path: /etc/borg-streams
state: directory
- name: Create db streaming file
copy:
content: >-
/usr/local/bin/docker-compose -f /etc/refstack-docker/docker-compose.yaml exec -T mariadb
bash -c '/usr/bin/mysqldump --skip-extended-insert --databases refstack --single-transaction -uroot -p"$MYSQL_ROOT_PASSWORD"'
dest: /etc/borg-streams/mysql