Skip to content

Commit

Permalink
Merge pull request #31 from roles-ansible/lint
Browse files Browse the repository at this point in the history
improve linting and cleanup
  • Loading branch information
DO1JLR authored Oct 29, 2023
2 parents e6428f4 + 41973e1 commit 0e34a87
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ansible-linting-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: 'checkout git repo'
- name: Checkout git repo
uses: actions/checkout@v4
with:
submodules: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
build:
name: Jinja2 Linting
name: Galaxy Role Importer
runs-on: ubuntu-latest

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/j2lint-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: 'checkout git repo'
- name: Checkout git repo
uses: actions/checkout@v4
with:
submodules: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/yamllint-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: 'checkout git repo'
- name: Checkout git repo
uses: actions/checkout@v4
with:
submodules: true
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ By the way, this role requires that the Ansible user be allowed to execute comma
submodules_versioncheck: true
```
## Requirements
The ``community.general`` collection is required for some parts of this ansible role.
You can install it with this command:
```bash
ansible-galaxy collection install -r requirements.yml --upgrade
```


Contributing
--------------
Don't hesitate to open a issue or *(even better)* create a pull request.
4 changes: 4 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
collections:
- name: 'community.general'
version: ">=7.5.0,<=8.0.0"
6 changes: 3 additions & 3 deletions tasks/backup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
recurse: true
group: "{{ etebase__group }}"
owner: "{{ etebase__user }}"
with_items:
loop:
- "{{ etebase__backup_destionation }}"
- "{{ etebase__current_backup_destination }}"

Expand All @@ -59,7 +59,7 @@
recurse: true
group: "{{ etebase__group }}"
owner: "{{ etebase__user }}"
with_items:
loop:
- "{{ etebase__current_backup_destination }}"

- name: Backup static root dir
Expand All @@ -84,7 +84,7 @@
dest: "{{ etebase__current_backup_destination }}"
remote_src: true

- name: Create bz2 archive of backup
- name: Create bz2 archive of backup # noqa: H1901
become: true
community.general.archive:
mode: 0640
Expand Down
4 changes: 2 additions & 2 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
owner: "{{ etebase__user }}"
recurse: true
mode: 'u=rwX,g=rX,o=rX'
with_items:
loop:
- "{{ etebase__global_static_root }}"

- name: "Create media data directorys"
Expand All @@ -30,7 +30,7 @@
owner: "{{ etebase__user }}"
recurse: true
mode: 'u=rwX,g=rX,o='
with_items:
loop:
- "{{ etebase__global_media_root }}"
- "{{ etebase__secrets_dir }}"

Expand Down
2 changes: 1 addition & 1 deletion tasks/download.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Set git configuration for safe.directory
- name: Set git configuration for safe.directory # noqa: H1901
community.general.git_config:
scope: global
name: safe.directory
Expand Down
4 changes: 2 additions & 2 deletions tasks/filepermissions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
owner: "{{ etebase__user }}"
recurse: true
mode: 'u=rwX,g=rX,o=rX'
with_items:
loop:
- "{{ etebase__global_static_root }}"
notify:
- "Systemctl restart etebase.service"
Expand All @@ -23,7 +23,7 @@
owner: "{{ etebase__user }}"
recurse: true
mode: 'u=rwX,g=rX,o='
with_items:
loop:
- "{{ etebase__global_media_root }}"
- "{{ etebase__secrets_dir }}"
- "{{ etebase__venv }}"
Expand Down
30 changes: 20 additions & 10 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,43 @@
---
- name: Run optional versionscheck
ansible.builtin.include_tasks: versioncheck.yml
ansible.builtin.include_tasks:
file: 'versioncheck.yml'
when: submodules_versioncheck | bool

- name: Create Etebase User/Group
ansible.builtin.include_tasks: create_user.yml
ansible.builtin.include_tasks:
file: 'create_user.yml'

- name: Define Etebase Version
ansible.builtin.include_tasks: set_version.yml
ansible.builtin.include_tasks:
file: 'set_version.yml'

- name: Run optional etebase backup
ansible.builtin.include_tasks: backup.yml
ansible.builtin.include_tasks:
file: 'backup.yml'
when: etebase__create_backup | bool

- name: Download Etebase Repo
ansible.builtin.include_tasks: download.yml
ansible.builtin.include_tasks:
file: 'download.yml'

- name: Setup Virtualenv and install Requirements
ansible.builtin.include_tasks: python_venv.yml
ansible.builtin.include_tasks:
file: 'python_venv.yml'

- name: Create Etebase Config
ansible.builtin.include_tasks: configure.yml
ansible.builtin.include_tasks:
file: 'configure.yml'

- name: Run ./manage.py migrate
ansible.builtin.include_tasks: migrate.yml
ansible.builtin.include_tasks:
file: 'migrate.yml'

- name: Setup Systemd Service
ansible.builtin.include_tasks: systemd.yml
ansible.builtin.include_tasks:
file: 'systemd.yml'
when: etebase__systemd_setup | bool

- name: Cleanup file permissions
ansible.builtin.include_tasks: filepermissions.yml
ansible.builtin.include_tasks:
file: 'filepermissions.yml'
10 changes: 5 additions & 5 deletions tasks/migrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
changed_when: _etebase_download.changed or _etebase_config.changed
register: _etebase_migrate

- name: Print output of python3 manage.py migrate
- name: Print output of python3 manage.py migrate # noqa: H500
ansible.builtin.debug:
verbosity: 1
msg: "{{ _etebase_migrate.stdout }}"
Expand All @@ -23,7 +23,7 @@
- "Systemctl restart etebase.service"
- "Systemctl restart webserver"

- name: Print output of python3 manage.py collectstatic
- name: Print output of python3 manage.py collectstatic # noqa: H500
ansible.builtin.debug:
verbosity: 1
msg: "{{ _etebase_collectstatic.stdout }}"
Expand All @@ -37,7 +37,7 @@
owner: "{{ etebase__user }}"
recurse: true
mode: 'u=rwX,g=rX,o='
with_items:
loop:
- "{{ etebase__secrets_dir }}"

- name: "Fix File Permissions for static data directory"
Expand All @@ -49,10 +49,10 @@
owner: "{{ etebase__user }}"
recurse: true
mode: 'u=rwX,g=rX,o=rX'
with_items:
loop:
- "{{ etebase__global_static_root }}"

- name: Print hint how to create admin User
- name: Print hint how to create admin User # noqa: H500
ansible.builtin.debug:
# yamllint disable-line rule:line-length
msg: "To create a admin user, run 'cd {{ etebase__user_home }}/etebase_{{ etebase_version_target }}; source {{ etebase__venv }}/bin/activate; python3 ./manage.py createsuperuser' as priviledged user."
2 changes: 1 addition & 1 deletion tasks/set_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
etebase_version_target: "{{ etebase__version }}"
when: etebase__version != "latest"

- name: Print Etebase Version
- name: Print Etebase Version # noqa: H500
ansible.builtin.debug:
verbosity: 1
msg: "etebase version is set to {{ etebase_version_target }}"
7 changes: 3 additions & 4 deletions tasks/versioncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ansible.builtin.file:
path: '/etc/.ansible-version'
state: directory
mode: "0755"
mode: '0755'
when: submodules_versioncheck | bool

- name: Check playbook version
Expand All @@ -16,15 +16,14 @@
src: "/etc/.ansible-version/{{ playbook_version_path }}"
register: playbook_version
when: submodules_versioncheck | bool
ignore_errors: true
failed_when: false

- name: Print remote role version
- name: Print remote role version # noqa: H500
ansible.builtin.debug:
msg: "Remote role version: {{ playbook_version.content | default('Y3VycmVudGx5IG5vdCBkZXBsb3llZAo=') | b64decode | string }}"
when: submodules_versioncheck | bool

- name: Print locale role version
- name: Print locale role version # noqa: H500
ansible.builtin.debug:
msg: "Local role version: '{{ playbook_version_number | string }}'."
when: submodules_versioncheck | bool
Expand Down

0 comments on commit 0e34a87

Please sign in to comment.