Move tasks into separate file
This commit is contained in:
parent
da97a553e0
commit
7eccd4b713
2 changed files with 148 additions and 145 deletions
|
@ -1,146 +1,3 @@
|
|||
---
|
||||
- name: Install system packages
|
||||
apt:
|
||||
name:
|
||||
- build-essential
|
||||
- libffi-dev
|
||||
- libjpeg-dev
|
||||
- libssl-dev
|
||||
- libxml2-dev
|
||||
- libxslt1-dev
|
||||
- python3-dev
|
||||
- python3-pip
|
||||
- python3-setuptools
|
||||
- sqlite3
|
||||
- virtualenv
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Create Matrix Synapse system group
|
||||
group:
|
||||
name: '{{ matrix__synapse__group }}'
|
||||
system: true
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Create Matrix Synapse system user
|
||||
user:
|
||||
name: '{{ matrix__synapse__user }}'
|
||||
group: '{{ matrix__synapse__group }}'
|
||||
system: true
|
||||
create_home: false
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Create Matrix directories
|
||||
file:
|
||||
state: directory
|
||||
path: '{{ item }}'
|
||||
mode: 'u=rwx,g=rwx,o=rx'
|
||||
owner: root
|
||||
group: root
|
||||
with_items:
|
||||
- '{{ matrix__conf_dir }}'
|
||||
- '{{ matrix__opt_dir }}'
|
||||
- '{{ matrix__lib_dir }}'
|
||||
- '{{ matrix__log_dir }}'
|
||||
- '{{ matrix__run_dir }}'
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Create Matrix Synapse directories
|
||||
file:
|
||||
state: directory
|
||||
path: '{{ item }}'
|
||||
mode: 'u=rwx,g=rwx,o=rx'
|
||||
owner: '{{ matrix__synapse__user }}'
|
||||
group: '{{ matrix__synapse__group }}'
|
||||
with_items:
|
||||
- '{{ matrix__synapse__conf_dir }}'
|
||||
- '{{ matrix__synapse__opt_dir }}'
|
||||
- '{{ matrix__synapse__lib_dir }}'
|
||||
- '{{ matrix__synapse__log_dir }}'
|
||||
- '{{ matrix__synapse__run_dir }}'
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Create Matrix Synapse config
|
||||
template:
|
||||
src: '../templates/matrix/synapse/config.yml'
|
||||
dest: '{{ matrix__synapse__conf_file }}'
|
||||
mode: 'u=rw,g=rw,o='
|
||||
owner: '{{ matrix__synapse__user }}'
|
||||
group: '{{ matrix__synapse__group }}'
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Create Matrix Synapse log config
|
||||
template:
|
||||
src: '../templates/matrix/synapse/log_config.yml'
|
||||
dest: '{{ matrix__synapse__log_conf_file }}'
|
||||
mode: 'u=rw,g=rw,o=r'
|
||||
owner: '{{ matrix__synapse__user }}'
|
||||
group: '{{ matrix__synapse__group }}'
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Create Matrix Synapse signing key
|
||||
copy:
|
||||
content: "{{ matrix__synapse__signing_key }}\n"
|
||||
dest: '{{ matrix__synapse__key_file }}'
|
||||
mode: 'u=rw,g=rw,o='
|
||||
owner: '{{ matrix__synapse__user }}'
|
||||
group: '{{ matrix__synapse__group }}'
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Create Python virtual env
|
||||
become_user: '{{ matrix__synapse__user }}'
|
||||
command:
|
||||
argv:
|
||||
- 'virtualenv'
|
||||
- '{{ matrix__synapse__venv_dir }}'
|
||||
- '-p'
|
||||
- 'python3'
|
||||
creates: '{{ matrix__synapse__venv_dir }}'
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Check Python packages
|
||||
command:
|
||||
argv:
|
||||
- '{{ matrix__synapse__venv_dir }}/bin/pip'
|
||||
- 'check'
|
||||
- '{{ item }}'
|
||||
with_items:
|
||||
- 'matrix-synapse'
|
||||
- 'lxml'
|
||||
- 'netaddr'
|
||||
- 'pip'
|
||||
- 'setuptools'
|
||||
changed_when: false
|
||||
register: packages_info
|
||||
|
||||
- name: Upgrade Python packages
|
||||
become_user: '{{ matrix__synapse__user }}'
|
||||
command:
|
||||
argv:
|
||||
- '{{ matrix__synapse__venv_dir }}/bin/pip'
|
||||
- 'install'
|
||||
- '--upgrade'
|
||||
- 'pip'
|
||||
- 'setuptools'
|
||||
when: packages_info | json_query('results[*].rc') | difference([0]) != []
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Install Python packages
|
||||
become_user: '{{ matrix__synapse__user }}'
|
||||
command:
|
||||
argv:
|
||||
- '{{ matrix__synapse__venv_dir }}/bin/pip'
|
||||
- 'install'
|
||||
- 'matrix-synapse'
|
||||
- 'lxml'
|
||||
- 'netaddr'
|
||||
when: packages_info | json_query('results[*].rc') | difference([0]) != []
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Create systemd service
|
||||
template:
|
||||
src: '../templates/matrix/synapse/matrix-synapse.service'
|
||||
dest: '{{ matrix__synapse__service_file }}'
|
||||
mode: 'u=rw,g=rw,o=r'
|
||||
owner: root
|
||||
group: root
|
||||
notify: Load, enable and [re]start systemd service
|
||||
- include_tasks: synapse.yml
|
||||
- meta: flush_handlers
|
||||
|
|
146
roles/matrix/tasks/synapse.yml
Normal file
146
roles/matrix/tasks/synapse.yml
Normal file
|
@ -0,0 +1,146 @@
|
|||
---
|
||||
- name: Install system packages
|
||||
apt:
|
||||
name:
|
||||
- build-essential
|
||||
- libffi-dev
|
||||
- libjpeg-dev
|
||||
- libssl-dev
|
||||
- libxml2-dev
|
||||
- libxslt1-dev
|
||||
- python3-dev
|
||||
- python3-pip
|
||||
- python3-setuptools
|
||||
- sqlite3
|
||||
- virtualenv
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Create Matrix Synapse system group
|
||||
group:
|
||||
name: '{{ matrix__synapse__group }}'
|
||||
system: true
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Create Matrix Synapse system user
|
||||
user:
|
||||
name: '{{ matrix__synapse__user }}'
|
||||
group: '{{ matrix__synapse__group }}'
|
||||
system: true
|
||||
create_home: false
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Create Matrix directories
|
||||
file:
|
||||
state: directory
|
||||
path: '{{ item }}'
|
||||
mode: 'u=rwx,g=rwx,o=rx'
|
||||
owner: root
|
||||
group: root
|
||||
with_items:
|
||||
- '{{ matrix__conf_dir }}'
|
||||
- '{{ matrix__opt_dir }}'
|
||||
- '{{ matrix__lib_dir }}'
|
||||
- '{{ matrix__log_dir }}'
|
||||
- '{{ matrix__run_dir }}'
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Create Matrix Synapse directories
|
||||
file:
|
||||
state: directory
|
||||
path: '{{ item }}'
|
||||
mode: 'u=rwx,g=rwx,o=rx'
|
||||
owner: '{{ matrix__synapse__user }}'
|
||||
group: '{{ matrix__synapse__group }}'
|
||||
with_items:
|
||||
- '{{ matrix__synapse__conf_dir }}'
|
||||
- '{{ matrix__synapse__opt_dir }}'
|
||||
- '{{ matrix__synapse__lib_dir }}'
|
||||
- '{{ matrix__synapse__log_dir }}'
|
||||
- '{{ matrix__synapse__run_dir }}'
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Create Matrix Synapse config
|
||||
template:
|
||||
src: '../templates/matrix/synapse/config.yml'
|
||||
dest: '{{ matrix__synapse__conf_file }}'
|
||||
mode: 'u=rw,g=rw,o='
|
||||
owner: '{{ matrix__synapse__user }}'
|
||||
group: '{{ matrix__synapse__group }}'
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Create Matrix Synapse log config
|
||||
template:
|
||||
src: '../templates/matrix/synapse/log_config.yml'
|
||||
dest: '{{ matrix__synapse__log_conf_file }}'
|
||||
mode: 'u=rw,g=rw,o=r'
|
||||
owner: '{{ matrix__synapse__user }}'
|
||||
group: '{{ matrix__synapse__group }}'
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Create Matrix Synapse signing key
|
||||
copy:
|
||||
content: "{{ matrix__synapse__signing_key }}\n"
|
||||
dest: '{{ matrix__synapse__key_file }}'
|
||||
mode: 'u=rw,g=rw,o='
|
||||
owner: '{{ matrix__synapse__user }}'
|
||||
group: '{{ matrix__synapse__group }}'
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Create Python virtual env
|
||||
become_user: '{{ matrix__synapse__user }}'
|
||||
command:
|
||||
argv:
|
||||
- 'virtualenv'
|
||||
- '{{ matrix__synapse__venv_dir }}'
|
||||
- '-p'
|
||||
- 'python3'
|
||||
creates: '{{ matrix__synapse__venv_dir }}'
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Check Python packages
|
||||
command:
|
||||
argv:
|
||||
- '{{ matrix__synapse__venv_dir }}/bin/pip'
|
||||
- 'check'
|
||||
- '{{ item }}'
|
||||
with_items:
|
||||
- 'matrix-synapse'
|
||||
- 'lxml'
|
||||
- 'netaddr'
|
||||
- 'pip'
|
||||
- 'setuptools'
|
||||
changed_when: false
|
||||
register: packages_info
|
||||
|
||||
- name: Upgrade Python packages
|
||||
become_user: '{{ matrix__synapse__user }}'
|
||||
command:
|
||||
argv:
|
||||
- '{{ matrix__synapse__venv_dir }}/bin/pip'
|
||||
- 'install'
|
||||
- '--upgrade'
|
||||
- 'pip'
|
||||
- 'setuptools'
|
||||
when: packages_info | json_query('results[*].rc') | difference([0]) != []
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Install Python packages
|
||||
become_user: '{{ matrix__synapse__user }}'
|
||||
command:
|
||||
argv:
|
||||
- '{{ matrix__synapse__venv_dir }}/bin/pip'
|
||||
- 'install'
|
||||
- 'matrix-synapse'
|
||||
- 'lxml'
|
||||
- 'netaddr'
|
||||
when: packages_info | json_query('results[*].rc') | difference([0]) != []
|
||||
notify: Load, enable and [re]start systemd service
|
||||
|
||||
- name: Create systemd service
|
||||
template:
|
||||
src: '../templates/matrix/synapse/matrix-synapse.service'
|
||||
dest: '{{ matrix__synapse__service_file }}'
|
||||
mode: 'u=rw,g=rw,o=r'
|
||||
owner: root
|
||||
group: root
|
||||
notify: Load, enable and [re]start systemd service
|
Reference in a new issue