Skip to content

Commit

Permalink
Added workaround for a bug in ansible
Browse files Browse the repository at this point in the history
  • Loading branch information
dvaerum committed Jul 25, 2021
1 parent fa1d71b commit 12262bb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion install_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@

- name: Initiate variable 'root_zfs_pool'
set_fact:
root_zfs_pool: "{{ ansible_zfs_datasets | json_query(filter) | first | regex_replace('/.+', '') }}"
# the workaround is to added 'to_json | from_json' and when it work (it is magic)
root_zfs_pool: "{{ ansible_zfs_datasets | to_json | from_json | json_query(filter) | first | regex_replace('/.+', '') }}"
vars:
filter: "[?mountpoint=='{{ next_boot_mountpoint }}'].name"

Expand Down
9 changes: 6 additions & 3 deletions roles/os_specific_setup/tasks/os_Archlinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,17 @@
{{ zfs_packages | join(' ') }}
register: _result
failed_when:
- _result | json_query(filter) | count > 0 or _result.rc != 0
# the workaround is to added 'to_json | from_json' and when it work (it is magic)
- _result | to_json | from_json | json_query(filter) | count > 0 or _result.rc != 0
vars:
filter: "result_trizen_zfs_packages.stdout_lines[?contains(@, 'Error! Bad return status for module build on kernel')]"

# TODO: remove this when the filter has been confirmed to work
- name: Install ZFS packages - Trizen (debug)
debug:
var:
- _result | json_query(filter) | count > 0
# the workaround is to added 'to_json | from_json' and when it work (it is magic)
- _result | to_json | from_json | json_query(filter) | count > 0
- _result.rc != 0
vars:
filter: "result_trizen_zfs_packages.stdout_lines[?contains(@, 'Error! Bad return status for module build on kernel')]"
Expand Down Expand Up @@ -124,6 +126,7 @@
- name: Generate initcpio (fail)
fail:
msg: "One or more kernel module was unable to build"
when: _result | json_query(filter) | count > 0 or _result.rc != 0
# the workaround is to added 'to_json | from_json' and when it work (it is magic)
when: _result | to_json | from_json | json_query(filter) | count > 0 or _result.rc != 0
vars:
filter: "result_mkinitcpio.stderr_lines[?contains(@, 'ERROR: module not found')]"
1 change: 1 addition & 0 deletions system_update_checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
zfs:
name: "{{ item }}"
state: absent
# the workaround is to added 'to_json | from_json' and when it work (it is magic)
loop: "{{ (ansible_zfs_datasets | to_json | from_json | json_query(filter_1) | sort(reverse=True))[number_of_snapshots_to_keep:] }}"
vars:
filter_1: "[?type=='snapshot' && starts_with(name, '{{ distro_filesystem_path }}@')].name"
Expand Down

0 comments on commit 12262bb

Please sign in to comment.