Skip to content

Commit

Permalink
Fix various linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
0x46616c6b committed Aug 26, 2023
1 parent 8bc2fe7 commit a6bf887
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 60 deletions.
3 changes: 0 additions & 3 deletions .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@
exclude_paths:
- molecule/
- .github/
skip_list:
- fqcn-builtins
- no-handler
5 changes: 2 additions & 3 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
- name: Restart etherpad-lite
service:
ansible.builtin.service:
name: etherpad-lite
state: restarted

- name: Reload systemd
systemd:
ansible.builtin.systemd:
daemon_reload: true
become: true
3 changes: 1 addition & 2 deletions tasks/abiword.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---

- name: Ensure abiword package is installed
apt:
ansible.builtin.apt:
pkg: abiword
state: present
54 changes: 26 additions & 28 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,38 @@
- name: Preflight checks
ansible.builtin.import_tasks: preflight.yml

- name: Ensure etherpad user is present
user:
- name: Create user
ansible.builtin.user:
name: "{{ etherpad_user }}"
home: "{{ etherpad_home }}"
shell: "/bin/bash"
state: present

- name: Ensure ssh directory is present
- name: Create ssh directory
ansible.builtin.file:
owner: "{{ etherpad_user }}"
group: "{{ etherpad_user }}"
mode: "0700"
path: "{{ etherpad_repository_key_file | dirname }}"
state: directory
when:
- etherpad_repository_key_file | length > 0
when: etherpad_repository_key_file | length > 0

- name: Ensure ssh key file are latest
copy:
- name: Create ssh key file
ansible.builtin.copy:
src: "{{ etherpad_repository_key_file_src }}"
dest: "{{ etherpad_repository_key_file }}"
owner: "{{ etherpad_user }}"
group: "{{ etherpad_user }}"
mode: "0600"
when:
- etherpad_repository_key_file_src | length > 0
when: etherpad_repository_key_file_src | length > 0

- name: Ensure required packages are installed
apt:
- name: Install required packages
ansible.builtin.apt:
pkg: "{{ etherpad_required_packages }}"
state: present

- name: Ensure etherpad is latest
git:
- name: Clone etherpad repository
ansible.builtin.git:
repo: "{{ etherpad_repository }}"
dest: "{{ etherpad_path }}"
version: "{{ etherpad_repository_version }}"
Expand All @@ -46,38 +44,38 @@
register: etherpad_repository
notify: Restart etherpad-lite

- name: Ensure etherpad config is latest
template:
- name: Copy configuration file
ansible.builtin.template:
src: settings.json.j2
dest: "{{ etherpad_path }}/settings.json"
owner: "{{ etherpad_user }}"
group: "{{ etherpad_group }}"
mode: 0640
mode: "0640"
become: true
become_user: "{{ etherpad_user }}"
notify: Restart etherpad-lite
no_log: true

- name: Import mysql tasks
import_tasks: mysql.yml
ansible.builtin.import_tasks: mysql.yml
when: etherpad_db_type == "mysql"

- name: Ensure etherpad systemd unit is latest
template:
- name: Copy systemd service file
ansible.builtin.template:
src: etc/systemd/system/etherpad-lite.service.j2
dest: /etc/systemd/system/etherpad-lite.service
owner: root
group: root
mode: 0644
mode: "0644"
notify: Reload systemd

- name: Ensure etherpad api key is latest
template:
- name: Set api key
ansible.builtin.template:
src: APIKEY.txt.j2
dest: "{{ etherpad_path }}/APIKEY.txt"
owner: "{{ etherpad_user }}"
group: "{{ etherpad_group }}"
mode: 0640
mode: "0640"
become: true
become_user: "{{ etherpad_user }}"
notify: Restart etherpad-lite
Expand Down Expand Up @@ -113,20 +111,20 @@
when: etherpad_repository.changed or etherpad_plugin.changed

- name: Copy custom logo file if configured
copy:
ansible.builtin.copy:
src: "{{ etherpad_custom_logo_src }}"
dest: "{{ etherpad_path }}/src/static/"
owner: "{{ etherpad_user }}"
group: "{{ etherpad_group }}"
mode: 0644
mode: "0644"
when: etherpad_custom_logo_src is defined

- name: Import abiword tasks
import_tasks: abiword.yml
ansible.builtin.import_tasks: abiword.yml
when: etherpad_abiword_enabled

- name: Ensure etherpad will start after system is booted
service:
- name: Activate and start etherpad-lite
ansible.builtin.service:
name: etherpad-lite
state: started
enabled: yes
45 changes: 21 additions & 24 deletions tasks/mysql.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
---
- name: Ensure python mysqldb is installed
apt:
- name: Install python mysqldb package
ansible.builtin.apt:
pkg: "{{ etherpad_python_mysql_package }}"
state: present

- name: Ensure mysql database is present
- name: Create mysql database
community.mysql.mysql_db:
name: "{{ etherpad_mysql_database_name }}"
collation: "{{ etherpad_mysql_database_collation }}"
state: present
login_unix_socket: /run/mysqld/mysqld.sock
register: database

- name: Ensure mysql schema is present
template:
- name: Copy mysqldb schema # noqa no-handler
ansible.builtin.template:
src: schema.sql.j2
dest: /tmp/etherpad_schema.sql
mode: 0755
when: database is changed

- name: Ensure mysql database is present
- name: Import mysqldb schema # noqa no-handler
community.mysql.mysql_db:
name: "{{ etherpad_mysql_database_name }}"
collation: "{{ etherpad_mysql_database_collation }}"
Expand All @@ -28,18 +28,18 @@
login_unix_socket: /run/mysqld/mysqld.sock
when: database is changed

- name: Ensure database schema is absent after import
file:
- name: Remove mysqldb schema file # noqa no-handler
ansible.builtin.file:
path: /tmp/etherpad_schema.sql
state: absent
when: database is changed

- name: Fail if mysql user has no password
fail:
ansible.builtin.fail:
msg: "You need to set a password for mysql user!"
when: etherpad_mysql_database_password is undefined or etherpad_mysql_database_password | length == 0

- name: Ensure mysql user is present
- name: Create mysql user
community.mysql.mysql_user:
name: "{{ etherpad_mysql_database_user }}"
state: present
Expand All @@ -48,34 +48,31 @@
login_unix_socket: /run/mysqld/mysqld.sock

- name: Register systemd version number
shell: |
ansible.builtin.shell: |
set -o pipefail
systemd --version | head -1 | cut -d' ' -f2
args:
executable: /bin/bash
check_mode: False
changed_when: False
check_mode: no
changed_when: false
register: systemd_version
when:
- etherpad_mysql_systemd_dropin_enabled
when: etherpad_mysql_systemd_dropin_enabled

- name: Create directory for etherpads systemd drop-in
file:
ansible.builtin.file:
path: /etc/systemd/system/etherpad-lite.service.d/
state: directory
owner: root
group: root
mode: 0750
when:
- etherpad_mysql_systemd_dropin_enabled
mode: "0750"
when: etherpad_mysql_systemd_dropin_enabled

- name: Create directory for etherpads systemd drop-in
template:
- name: Create systemd drop-in for etherpad
ansible.builtin.template:
src: etc/systemd/system/etherpad-lite.service.d/10-start-limit.conf.j2
dest: /etc/systemd/system/etherpad-lite.service.d/10-start-limit.conf
owner: root
group: root
mode: 0644
mode: "0644"
notify: Reload systemd
when:
- etherpad_mysql_systemd_dropin_enabled
when: etherpad_mysql_systemd_dropin_enabled

0 comments on commit a6bf887

Please sign in to comment.