Commit 8ddb7e39 authored by Pietsch, Martin's avatar Pietsch, Martin

replaced upgrade commands by upgrade modules

parent 10be01c7
---
- set_fact:
- name: add key jailname to container dictionary
set_fact:
container: >-
{% do container.update({'jailname': container.name | replace('.', '_')}) -%}
{{ container }}
when: container is defined
- set_fact:
fuprm: ""
- name: initialise variable with the root directory for base system update
set_fact:
fubdir: "/"
- set_fact:
puprm: ""
- name: initialise variable of package update for jails
set_fact:
pujail: ""
- block:
- jail:
- name: get running data of jail
jail:
name: "{{ container.jailname }}"
state: state
register: cstate
- set_fact:
fuprm: "{{ '-b %s' | format(cstate.path) }}"
- name: set variable with the root directory of jail for base system update
set_fact:
fubdir: "{{ cstate.path }}"
- set_fact:
puprm: "{{ '-j %s' | format(container.jailname) }}"
- name: set variable of package update for jails
set_fact:
pujail: "{{ container.jailname }}"
when: container is defined
- name: fetch system updates
command: "{{ '/usr/sbin/freebsd-update %s --not-running-from-cron fetch' | format(fuprm) }}"
environment:
PAGER: /bin/cat
register: fuout
- name: install updates
command: "{{ '/usr/sbin/freebsd-update %s install' | format(fuprm) }}"
when: (fuout.stdout_lines | regex_filter_list('^[/]') | length()) > 0
- name: update repository lists
command: "{{ '/usr/sbin/pkg %s update' | format(puprm) }}"
- name: update base system
fbsd_update:
basedir: "{{ fubdir }}"
register: fudata
- name: upgrade packages
command: "{{ '/usr/sbin/pkg %s upgrade' | format(puprm) }}"
environment:
ASSUME_ALWAYS_YES: "yes"
register: puout
- name: cleanup caches
command: "{{ '/usr/sbin/pkg %s clean' | format(puprm) }}"
environment:
ASSUME_ALWAYS_YES: "yes"
pkgng_upgrade:
jail: "{{ pujail }}"
register: pudata
- set_fact:
_upgradestate: "{{ (puout.stdout_lines | regex_filter_list('->') | length()) > 0 or (fuout.stdout_lines | regex_filter_list('^[/]') | length()) > 0 }}"
- name: determinate result of processed updates
set_fact:
_upgradestate: "{{ pudata.changed == True or fudata.changed == True }}"
- set_fact:
- name: set update result of host to return value upgraded
set_fact:
upgraded: "{{ upgraded | combine({ 'host': _upgradestate }) }}"
when: container is not defined
- block:
- set_fact:
- name: set update result of jail to return value upgraded
set_fact:
upgraded: "{{ upgraded | combine({ container.jailname: _upgradestate }) }}"
- jail:
- name: restart jail
jail:
name: "{{ container.jailname }}"
state: restart
when: upgraded[container.jailname] == True and upgraded["host"] == False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment