Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conform to linter #234

Merged
merged 5 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ exclude_paths:
skip_list:
- role-name
- var-naming
warn_list:
- yaml[line-length]
- no-changed-when
- no-handler
9 changes: 4 additions & 5 deletions .ansible-lint-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
# Ignore rules in specific files as follows:
# playbooks/transferuser.yml yaml[empty-lines]

playbooks/roles/transferuser/molecule/default/verify.yml risky-shell-pipe
playbooks/roles/stata18/molecule/default/prepare.yml command-instead-of-module
playbooks/roles/stata18/molecule/default/prepare.yml inline-env-var # this is a bug in some versions of ansible-lint

molecule/playbook-aptly/molecule.yml yaml[line-length] # molecule test parameters are long
molecule/playbook-reverse_proxy/molecule.yml yaml[line-length] # molecule test parameters are long
molecule/playbook-reverse_proxy/verify.yml yaml[line-length] # URL expectations are too long
playbooks/roles/sshfs_mount/main/tasks.yml yaml[line-length] # fstab options are too long
playbooks/roles/camunda_server/tasks/main.yml yaml[line-length] # XML too long
playbooks/roles/sshfs_mount/tasks/mount.yml yaml[line-length] # mount options too long
playbooks/roles/stata18/molecule/default/prepare.yml command-instead-of-module
2 changes: 1 addition & 1 deletion .github/workflows/ansible_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
- name: Run ansible-lint
uses: ansible/ansible-lint@main
with:
args: "."
args: "playbooks ."
26 changes: 13 additions & 13 deletions playbooks/aptly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@
pre_tasks:
- name: Get Service Status
no_log: true
systemd:
ansible.builtin.systemd:
name: nginx
register: nginx_status

- name: Stop if nginx is not installed
fail:
ansible.builtin.fail:
msg: The nginx service must be installed and active for this component to work.
when: nginx_status.status.ActiveState != 'active'

- name: Parse aptly packages as yaml
set_fact:
ansible.builtin.set_fact:
packages: "{{ packages | d([]) + [item | from_yaml] }}"
loop: "{{ aptly_packages.split('\\n') | list }}"

- name: Parse aptly repositories as yaml
set_fact:
ansible.builtin.set_fact:
repos: "{{ repos | d([]) + [item | from_yaml] }}"
loop: "{{ aptly_repositories.split('\\n') | list }}"

- name: Set aptly user vars
set_fact:
ansible.builtin.set_fact:
aptly_user: "{{ aptly_user | default('aptly') }}"
aptly_home: /srv/aptly

# When the gpg keys were set as a component parameter, '\n' needs to be replaced by true newlines
- name: Set gpg key variables
when: (aptly_gpg_private_key | default('') | length > 0) and (aptly_gpg_public_key | default('') | length > 0)
set_fact:
ansible.builtin.set_fact:
gpg_private_key: "{{ aptly_gpg_private_key.split('\\n') | join('\n') }}"
gpg_public_key: "{{ aptly_gpg_public_key.split('\\n') | join('\n') }}"

Expand All @@ -41,7 +41,7 @@
when: (aptly_gpg_private_key | default('') | length == 0) or (aptly_gpg_public_key | default('') | length == 0)
block:
- name: Generate keys
import_role:
ansible.builtin.import_role:
name: ext/juju4.gpgkey_generate
vars:
gpg_pull: false # Don't pull the created keys to the orchestrator
Expand All @@ -55,18 +55,18 @@
gpg_pubkeyfileexport: aptly.asc
gpg_privkeyfile: aptly.priv
gpg_home: /root
- name: Cat GPG private key

Check failure on line 58 in playbooks/aptly.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

yaml[key-duplicates]

Duplication of key "gpg_user" in mapping
command: cat /root/aptly.priv
ansible.builtin.command: cat /root/aptly.priv
changed_when: false
no_log: true
register: aptly_gpg_private_cat
- name: Cat GPG public key
command: cat /root/aptly.asc
ansible.builtin.command: cat /root/aptly.asc
changed_when: false
no_log: true
register: aptly_gpg_public_cat
- name: Set GPG key vars
set_fact:
ansible.builtin.set_fact:
gpg_private_key: "{{ aptly_gpg_private_cat.stdout }}"
gpg_public_key: "{{ aptly_gpg_public_cat.stdout }}"
no_log: true
Expand All @@ -89,7 +89,7 @@

tasks:
- name: Copy pubkey to repo
copy:
ansible.builtin.copy:
content: "{{ gpg_public_key }}"
dest: "{{ aptly_home }}/.aptly/public/aptly_pubkey.asc"
owner: aptly
Expand All @@ -98,7 +98,7 @@

# NB: aptly homedir is hardcoded because copy does not support templating
- name: Create nginx location block
copy:
ansible.builtin.copy:
content: |
location /apt {
alias /srv/aptly/.aptly/public;
Expand All @@ -111,6 +111,6 @@

handlers:
- name: Restart nginx
service:
ansible.builtin.service:
name: nginx
state: restarted
22 changes: 11 additions & 11 deletions playbooks/flask_app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
ansible.builtin.service_facts:

- name: Stop if nginx is not installed
fail:
ansible.builtin.fail:
msg: Nginx must be installed and active for this component to work.
when: services['nginx.service'].state != 'running'

- name: Check for presence of SRC Nginx SRAM authentication config
lineinfile:
ansible.builtin.lineinfile:
line: "{{ item }}"
dest: /etc/nginx/app-location-conf.d/authentication.conf
check_mode: true
Expand All @@ -46,24 +46,24 @@
- location = /oauth2_callback {
- location = /validate {

- name: Stop if SRC nginx config is not present

Check warning on line 49 in playbooks/flask_app.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

no-handler

Tasks that run when changed should likely be handlers.
fail:
ansible.builtin.fail:
msg: The SRC-Nginx component must be run before this component
when: src_nginx_config.changed

- name: Resolve 'omit' in variables
block:
- name: Set uwsgi_config
set_fact:
ansible.builtin.set_fact:
uwsgi_config: "{{ _uwsgi_config }}"

- name: Set uwsgi_proxy_config
set_fact:
ansible.builtin.set_fact:
uwsgi_proxy_config: "{{ _uwsgi_proxy_config }}"

- name: Set auth info variable if auth basic is set
when: flask_app_auth == 'basic'
set_fact:
ansible.builtin.set_fact:
_flask_app_auth_info:
- name: "{{ flask_app_name }}"
username: "{{ flask_app_username | default('') }}"
Expand All @@ -72,14 +72,14 @@

- name: Clone repo
tags: molecule-idempotence-notest
git:
ansible.builtin.git:
repo: "{{ flask_app_repo }}"
version: "{{ flask_app_version | default(omit, true) }}"
dest: "{{ uwsgi_app_dir }}"
depth: 1

- name: Create venv with uv
include_role:
ansible.builtin.include_role:
name: uv
vars:
uv_venvs:
Expand All @@ -88,13 +88,13 @@

- name: Ensure build requirements for uwsgi present
when: ansible_os_family == 'Debian'
package:
ansible.builtin.package:
name:
- build-essential
- python3-dev

- name: Install uwsgi
pip:
ansible.builtin.pip:
executable: uv_pip
name:
- wheel
Expand All @@ -106,7 +106,7 @@

- name: Install requirements
when: flask_app_requirements | length > 0
pip:
ansible.builtin.pip:
executable: uv_pip
requirements: "{{ uwsgi_app_dir }}/{{ item | trim }}"
environment:
Expand Down
7 changes: 3 additions & 4 deletions playbooks/irods_server.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
- name: install iRODS server (provider role) in researchcloud workspace
- name: Install iRODS server (provider role) in researchcloud workspace
hosts: localhost
gather_facts: true

# irods server will use a local postgresql database
# irods server will use a local postgresql database

roles:
- irods_server

4 changes: 2 additions & 2 deletions playbooks/keycloak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
pre_tasks:
- name: Get Service Status
no_log: true
systemd:
ansible.builtin.systemd:
name: nginx
register: nginx_status

- name: Stop if nginx is not installed
fail:
ansible.builtin.fail:
msg: The SRC-Nginx component must be installed and active for this component to work.
when: nginx_status.status.ActiveState != 'active'

Expand Down
4 changes: 2 additions & 2 deletions playbooks/r-workbench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
tasks:
- name: Parse optional packages as yaml
when: r_workbench_packages is defined and r_workbench_packages | length > 0
set_fact:
ansible.builtin.set_fact:
_r_packages: "{{ r_workbench_packages.split('\\n') | join('\n') | from_yaml }}"

- name: Include ansible-r role
include_role:
ansible.builtin.include_role:
name: ansible-r
vars:
r_version: "{{ r_workbench_version | default('40', true) }}"
Expand Down
10 changes: 5 additions & 5 deletions playbooks/reverse_proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
ansible.builtin.service_facts:

- name: Stop if nginx is not installed
fail:
ansible.builtin.fail:
msg: Nginx must be installed and active for this component to work.
when: services['nginx.service'].state != 'running'

- name: Check for presence of SRC Nginx SRAM authentication config
lineinfile:
ansible.builtin.lineinfile:
line: "{{ item }}"
dest: /etc/nginx/app-location-conf.d/authentication.conf
check_mode: true
Expand All @@ -26,18 +26,18 @@
- location = /oauth2_callback {
- location = /validate {

- name: Stop if SRC nginx config is not present

Check warning on line 29 in playbooks/reverse_proxy.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

no-handler

Tasks that run when changed should likely be handlers.
fail:
ansible.builtin.fail:
msg: The SRC-Nginx component must be run before this component
when: src_nginx_config.changed

- name: Parse reverse proxy locations variable as yaml
set_fact:
ansible.builtin.set_fact:
locations: "{{ reverse_proxy_locations.split('\\n') | join('\n') | from_yaml }}"

- name: Parse auth info variable as yaml
when: reverse_proxy_auth_info is defined and reverse_proxy_auth_info | length > 0
set_fact:
ansible.builtin.set_fact:
auth_info: "{{ reverse_proxy_auth_info.split('\\n') | join('\n') | from_yaml }}"
no_log: true

Expand Down
3 changes: 1 addition & 2 deletions playbooks/robot-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
vars:
robotuser_generate_ssh_key: true
- role: fact_workspace_info

tasks:

tasks:
- name: Restrict permissions on data volumes
ansible.builtin.file:
path: "{{ item }}"
Expand Down
12 changes: 7 additions & 5 deletions playbooks/roles/agisoft/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,32 @@
# The get_url ansible module in the task below does not create a directory

- name: Ensure download dir exists
file:
ansible.builtin.file:
path: "{{ agisoft_download_dest }}"
state: directory
mode: "0755"

- name: Download agisoft installation files
get_url:
ansible.builtin.get_url:
url: "{{ agisoft_url }}"
dest: "{{ agisoft_download_dest }}"
mode: "0774"

- name: Extract agisoft to opt for multiple user
unarchive:
ansible.builtin.unarchive:
remote_src: true
src: "{{ agisoft_download_dest }}/{{ agisoft_file }}"
dest: /opt
mode: "0755"

- name: Create license file
copy:
ansible.builtin.copy:
dest: "{{ agisoft_install_dir }}/license.lic"
content: "{{ license }}"
mode: "0644"

- name: Install desktop file menu item through role
include_role:
ansible.builtin.include_role:
name: desktop_file
vars:
desktopfile_app_name: agisoft
Expand Down
2 changes: 1 addition & 1 deletion playbooks/roles/anaconda/tasks/dependencies_apt.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Install dependencies
apt:
ansible.builtin.apt:
pkg:
- libgl1-mesa-glx
- libegl1-mesa
Expand Down
2 changes: 1 addition & 1 deletion playbooks/roles/anaconda/tasks/dependencies_yum.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Install dependencies
yum:
ansible.builtin.dnf:
name:
- libXcomposite
- libXcursor
Expand Down
Loading
Loading