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

Fix usage of bare variables in assert conditions #260

Merged
merged 1 commit into from
Jan 24, 2024
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
17 changes: 12 additions & 5 deletions roles/jws/tasks/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,18 @@
- name: "Check main zipfile"
ansible.builtin.assert:
that:
- "'{{ jws_archive_repository }}/{{ zipfile_name }}' is exists"
fail_msg: "An offline install was requested but the zipfile {{ jws_archive_repository }}/{{ zipfile_name }} was not found"
- filename is exists
fail_msg: "An offline install was requested but the zipfile {{ filename }} was not found"
vars:
filename: "{{ jws_archive_repository }}/{{ zipfile_name }}"
- name: "Check native zipfile exists"
ansible.builtin.assert:
that:
- "'{{ jws_archive_repository }}/{{ jws_native_zipfile }}' is exists"
fail_msg: "An offline install was requested but the zipfile {{ jws_archive_repository }}/{{ jws_native_zipfile }} was not found"
- filename is exists
fail_msg: "An offline install was requested but the zipfile {{ filename }} was not found"
when: jws_native
vars:
filename: "{{ jws_archive_repository }}/{{ jws_native_zipfile }}"
- name: "Check patch zipfile exists"
ansible.builtin.assert:
that:
Expand All @@ -82,4 +86,7 @@
fail_msg: "An offline install was requested but the zipfile {{ filename }} was not found"
when: jws_apply_patches and jws_native
vars:
filename: "{{ jws_archive_repository + '/jws-' + jws_patch_version + (jws_version.startswith('6') | ternary('-optional-native-components-RHEL', '-application-server-RHEL')) + (jws_native_rhel_version | default(ansible_facts['distribution_major_version'])) + '-' + jws_patch_native_arch + '.zip' }}"
filename: "{{ jws_archive_repository + '/jws-' + jws_patch_version + \

Check warning on line 89 in roles/jws/tasks/defaults.yml

View workflow job for this annotation

GitHub Actions / ci / linter (3.11, 2.15)

jinja[spacing]

Jinja2 spacing could be improved: {{ jws_archive_repository + '/jws-' + jws_patch_version + (jws_version.startswith('6') | ternary('-optional-native-components-RHEL', '-application-server-RHEL')) + (jws_native_rhel_version | default(ansible_facts['distribution_major_version'])) + '-' + jws_patch_native_arch + '.zip' }} -> {{ jws_archive_repository + '/jws-' + jws_patch_version + (jws_version.startswith('6') | ternary('-optional-native-components-RHEL', '-application-server-RHEL')) + (jws_native_rhel_version | default(ansible_facts['distribution_major_version'])) + '-' + jws_patch_native_arch + '.zip' }}
(jws_version.startswith('6') | ternary('-optional-native-components-RHEL', '-application-server-RHEL')) + \
(jws_native_rhel_version | default(ansible_facts['distribution_major_version'])) + \
'-' + jws_patch_native_arch + '.zip' }}"
8 changes: 4 additions & 4 deletions roles/jws/tasks/install/force_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
ps --no-headers -u {{ jws.user }} | grep -v grep | awk '{print $1}'
args:
executable: /bin/bash
become: yes
become: True
register: running_processes
changed_when: False

- name: "Terminate foreign processes"
ansible.builtin.command: "kill -15 {{ running_processes.stdout_lines | join(' ') }}"
become: yes
become: True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guidograzioli I think we should have a variable (defaulting to True) instead of a hardcoded, we may run into issue with system where sudo have not all the priviliges (and ps, for instance, does not need to be run by root if there is a jws user).
WYDT?

when:
- jws_force_install
- running_processes.stdout_lines | length > 0
Expand All @@ -23,14 +23,14 @@
ps --no-headers -u {{ jws.user }} | grep -v grep | awk '{print $1}'
args:
executable: /bin/bash
become: yes
become: True
failed_when: running_processes.stderr_lines | length > 0
changed_when: False
register: running_processes

- name: "Kill foreign processes"
ansible.builtin.command: "kill -9 {{ running_processes.stdout_lines | join(' ') }}"
become: yes
become: True
when:
- jws_force_install
- running_processes.stdout_lines | length > 0
Expand Down
Loading