---
- name: SciStor update
hosts: all
tasks:
- name: SciStor update - compose URL
set_fact:
scst_freebsdupdate_cmd: "freebsd-update --not-running-from-cron fetch"
tags: freebsd-update
- name: SciStor update - add proxy part to URL
set_fact:
scst_freebsdupdate_cmd: "HTTP_PROXY='http://{{ scst_proxy_host }}:{{ scst_proxy_port }}' {{ scst_freebsdupdate_cmd }}"
when: scst_freebsdupdate_proxy_enable == True
tags: freebsd-update
- name: SciStor update - fetch updates from server
shell: "{{ scst_freebsdupdate_cmd }}"
register: result_freebsd_update_fetch
become: True
changed_when: "'No updates needed to update system to ' not in result_freebsd_update_fetch.stdout"
tags: freebsd-update
- name: SciStor update - print 'freebsd-update fetch' output
debug:
msg: "{{ result_freebsd_update_fetch.stdout }}"
when: "'No updates needed to update system to ' not in result_freebsd_update_fetch.stdout"
tags: freebsd-update
- name: SciStor update - install updates
command: freebsd-update --not-running-from-cron install
register: result_freebsd_update_install
become: True
changed_when: "'No updates are available to install.' not in result_freebsd_update_install.stdout"
when: "'No updates needed to update system to ' not in result_freebsd_update_fetch.stdout"
tags: freebsd-update
# Compare output of uname -r and freebsd-version -k.
# If they differ, a reboot is needed.
- name: SciStor update - get running kernel version
command: uname -r
register: result_uname_r
changed_when: False
ignore_errors: True
tags: freebsd-update
- name: SciStor update - get installed kernel version
command: freebsd-version -k
register: result_freebsd_version_k
changed_when: False
ignore_errors: True
tags: freebsd-update
- name: SciStor update - reboot host to enable new kernel
shell: "sleep 5 && reboot"
async: 1
poll: 0
become: True
when: result_uname_r.stdout != result_freebsd_version_k.stdout
tags: freebsd-update
- name: SciStor update - wait for host after reboot (max. 600s)
wait_for_connection:
connect_timeout: 20
sleep: 20
delay: 60
timeout: 600
when: result_uname_r.stdout != result_freebsd_version_k.stdout
tags: freebsd-update
- name: SciStor update - update available remote repos
command: pkg update
register: result_pkg_update
become: True
changed_when: "'FreeBSD repository is up to date.' not in result_pkg_update.stdout"
tags: pkg-update
- name: SciStor update - update packages to latest version
command: pkg upgrade -y
register: result_pkg_upgrade
become: True
changed_when: "'Your packages are up to date.' not in result_pkg_upgrade.stdout"
tags: pkg-update
- name: SciStor update - print 'pkg upgrade' output
debug:
msg: "{{ result_pkg_upgrade.stdout }}"
when: "'Your packages are up to date.' not in result_pkg_upgrade.stdout"
tags: pkg-update
- name: SciStor update - clean local package cache
command: pkg clean -y
register: result_pkg_clean
become: True
changed_when: "'Nothing to do.' not in result_pkg_clean.stdout"
tags: pkg-update
- name: SciStor update - autoremove packages
command: pkg autoremove -y
register: result_pkg_autoremove
become: True
changed_when: "'Nothing to do.' not in result_pkg_clean.stdout"
tags: pkg-update
- name: SciStor update - print 'pkg autoremove' output
debug:
msg: "{{ result_pkg_autoremove.stdout }}"
changed_when: "'Nothing to do.' not in result_pkg_autoremove.stdout"
tags: pkg-update
...