Make the role fully idempotent by pinning the version and also use a variable for setting the repository.
102 lines
4 KiB
YAML
102 lines
4 KiB
YAML
---
|
|
|
|
- name: create ssl cert
|
|
command: certbot certonly --email webmaster@archlinux.org --agree-tos --rsa-key-size 4096 --renew-by-default --webroot -w {{ letsencrypt_validation_dir }} -d '{{ archwiki_domain }}' creates='/etc/letsencrypt/live/{{ archwiki_domain }}/fullchain.pem'
|
|
when: 'archwiki_domain is defined'
|
|
|
|
- name: install packages
|
|
pacman: name=git,php-intl state=present
|
|
|
|
- name: make archwiki user
|
|
user: name="{{ archwiki_user }}" shell=/bin/false home="{{ archwiki_dir }}" createhome=no
|
|
register: user_created
|
|
|
|
- name: fix home permissions
|
|
file: state=directory owner="{{ archwiki_user }}" group="{{ archwiki_user }}" path="{{ archwiki_dir }}"
|
|
|
|
- name: set up nginx
|
|
template: src=nginx.d.conf.j2 dest=/etc/nginx/nginx.d/archwiki.conf owner=root group=root mode=644
|
|
notify:
|
|
- reload nginx
|
|
tags: ['nginx']
|
|
|
|
- name: make nginx log dir
|
|
file: path=/var/log/nginx/{{ archwiki_domain }} state=directory owner=root group=root mode=0755
|
|
|
|
- name: clone archwiki repo
|
|
git: repo={{ archwiki_repository }} dest="{{ archwiki_dir }}/public" version={{ archwiki_version }}
|
|
become: true
|
|
become_user: "{{ archwiki_user }}"
|
|
register: release
|
|
|
|
- name: fix home permissions
|
|
file: state=directory owner="{{ archwiki_user }}" group="{{ archwiki_user }}" path="{{ archwiki_dir }}"
|
|
|
|
- name: fix cache permissions
|
|
file: state=directory owner="{{ archwiki_user }}" group="{{ archwiki_user }}" path="{{ archwiki_dir }}/cache"
|
|
|
|
- name: fix sessions permissions
|
|
file: state=directory owner="{{ archwiki_user }}" group="{{ archwiki_user }}" path="{{ archwiki_dir }}/sessions"
|
|
|
|
- name: fix uploads permissions
|
|
file: state=directory owner="{{ archwiki_user }}" group="{{ archwiki_user }}" path="{{ archwiki_dir }}/uploads"
|
|
|
|
- name: configure archwiki
|
|
template: src=LocalSettings.php.j2 dest="{{ archwiki_dir }}/public/LocalSettings.php" owner="{{ archwiki_user }}" group="{{ archwiki_user }}" mode=0640
|
|
register: config
|
|
no_log: true
|
|
|
|
- name: create archwiki db
|
|
mysql_db: name="{{ archwiki_db }}" login_host="{{ archwiki_db_host }}" login_password="{{ mariadb_users.root }}"
|
|
register: db_created
|
|
|
|
- name: create archwiki db user
|
|
mysql_user: name={{ archwiki_db_user }} password={{ archwiki_db_password }}
|
|
login_host="{{ archwiki_db_host }}" login_password="{{ mariadb_users.root }}"
|
|
priv="{{ archwiki_db }}.*:ALL"
|
|
no_log: true
|
|
|
|
- name: configure php-fpm
|
|
template:
|
|
src=php-fpm.conf.j2 dest="/etc/php/php-fpm.d/{{ archwiki_user }}.conf"
|
|
owner=root group=root mode=0644
|
|
notify:
|
|
- restart php-fpm@{{ archwiki_user }}
|
|
|
|
- name: start and enable systemd socket
|
|
service: name=php-fpm@{{ archwiki_user }}.socket state=started enabled=true
|
|
|
|
- name: install runjobs service
|
|
template: src="archwiki-runjobs.service.j2" dest="/etc/systemd/system/archwiki-runjobs.service" owner=root group=root mode=0644
|
|
notify:
|
|
- daemon reload
|
|
|
|
- name: install runjobs timer
|
|
template: src="archwiki-runjobs.timer.j2" dest="/etc/systemd/system/archwiki-runjobs.timer" owner=root group=root mode=0644
|
|
notify:
|
|
- daemon reload
|
|
|
|
- name: install prune cache service
|
|
template: src="archwiki-prune-cache.service.j2" dest="/etc/systemd/system/archwiki-prune-cache.service" owner=root group=root mode=0644
|
|
notify:
|
|
- daemon reload
|
|
|
|
- name: install prune cache timer
|
|
template: src="archwiki-prune-cache.timer.j2" dest="/etc/systemd/system/archwiki-prune-cache.timer" owner=root group=root mode=0644
|
|
notify:
|
|
- daemon reload
|
|
|
|
- name: install runjobs wait service
|
|
template: src="archwiki-runjobs-wait.service.j2" dest="/etc/systemd/system/archwiki-runjobs-wait.service" owner=root group=root mode=0644
|
|
notify:
|
|
- daemon reload
|
|
|
|
- name: start and enable archwiki runjobs timer
|
|
service: name="archwiki-runjobs.timer" enabled=yes state=started
|
|
|
|
- name: start and enable archwiki prune cache timer
|
|
service: name="archwiki-prune-cache.timer" enabled=yes state=started
|
|
|
|
- name: start and enable archwiki runjobs wait service
|
|
service: name="archwiki-runjobs-wait.service" enabled=yes state=started
|