diff --git a/.ansible-lint b/.ansible-lint index 83c22d0..cfe50ce 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -2,6 +2,3 @@ exclude_paths: - molecule/ - .github/ -skip_list: - - fqcn-builtins - - no-handler diff --git a/handlers/main.yml b/handlers/main.yml index e506411..ffa5b85 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -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 diff --git a/tasks/abiword.yml b/tasks/abiword.yml index 310ef13..cc135f8 100644 --- a/tasks/abiword.yml +++ b/tasks/abiword.yml @@ -1,6 +1,5 @@ --- - - name: Ensure abiword package is installed - apt: + ansible.builtin.apt: pkg: abiword state: present diff --git a/tasks/main.yml b/tasks/main.yml index a0d9ab2..3b49bab 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 }}" @@ -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 @@ -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 diff --git a/tasks/mysql.yml b/tasks/mysql.yml index 4272627..8c16714 100644 --- a/tasks/mysql.yml +++ b/tasks/mysql.yml @@ -1,10 +1,10 @@ --- -- 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 }}" @@ -12,14 +12,14 @@ 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 }}" @@ -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 + 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 @@ -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