2017-03-09 17:17:13 +01:00
|
|
|
- name: Looking up if the {{ jail_name }} jail needs to be replaced, setting up variables
|
|
|
|
set_fact:
|
|
|
|
jail_{{ jail_name }}_must_replace: >-
|
|
|
|
{{
|
|
|
|
lookup(
|
|
|
|
'pipe', '/usr/sbin/chroot ' +
|
|
|
|
dynamic_jails_path + '/' +
|
|
|
|
vars['jail_' + jail_name + '_existing_dirs'][0] +
|
|
|
|
' /bin/freebsd-version -u'
|
|
|
|
) != latest_snapshot
|
|
|
|
}}
|
|
|
|
jail_{{ jail_name }}_newest_id: >-
|
|
|
|
{{
|
|
|
|
vars['jail_' + jail_name + '_existing_dirs'][0]
|
|
|
|
}}
|
|
|
|
|
2017-03-13 19:09:03 +01:00
|
|
|
# ---
|
|
|
|
# UPDATING the existing jail when the base system is not outdated
|
|
|
|
# ---
|
2017-03-09 17:17:13 +01:00
|
|
|
- block:
|
|
|
|
|
|
|
|
- name: Check if packages have to be upgraded
|
|
|
|
command:
|
|
|
|
/usr/sbin/pkg
|
|
|
|
-j {{ vars['jail_' + jail_name + '_newest_id'] }}
|
|
|
|
upgrade --dry-run -y
|
|
|
|
register: jail_pkgs
|
|
|
|
ignore_errors: true
|
|
|
|
changed_when: jail_pkgs.rc != 0
|
|
|
|
|
|
|
|
- name: Namespacing task return value
|
|
|
|
set_fact:
|
|
|
|
jail_{{ jail_name }}_pkgs: '{{ jail_pkgs }}'
|
|
|
|
|
|
|
|
- name: Upgrade packages when necessary
|
|
|
|
command:
|
|
|
|
/usr/sbin/pkg
|
|
|
|
-j {{ vars['jail_' + jail_name + '_newest_id'] }}
|
|
|
|
upgrade -y
|
|
|
|
when: '{{ vars["jail_" + jail_name + "_pkgs"] | changed }}'
|
|
|
|
|
|
|
|
when: '{{ not vars["jail_" + jail_name + "_must_replace"] }}'
|
|
|
|
|
|
|
|
|
2017-03-13 19:09:03 +01:00
|
|
|
|
|
|
|
# ---
|
|
|
|
# CREATING a new jail when the base system is outdated
|
|
|
|
# ---
|
2017-03-09 17:17:13 +01:00
|
|
|
- block:
|
|
|
|
|
|
|
|
- include: '{{ vars["jail_" + jail_name + "_include_update_precreate"] | default(jail_include_noop) }}'
|
|
|
|
vars:
|
|
|
|
include_type: '{{ "jail_" + jail_name + "_include_update_precreate" }}'
|
|
|
|
|
|
|
|
- name: Creating a new {{ jail_name }} jail
|
2017-03-09 17:58:42 +01:00
|
|
|
include: '{{ ansible_roles_path }}/karolyi.ansible-freebsd-jailhost-tools/tasks/jail/create.yml'
|
2017-03-09 17:17:13 +01:00
|
|
|
|
|
|
|
- include: '{{ vars["jail_" + jail_name + "_include_update_prestart"] | default(jail_include_noop) }}'
|
|
|
|
vars:
|
|
|
|
include_type: '{{ "jail_" + jail_name + "_include_update_prestart" }}'
|
|
|
|
|
2017-03-13 19:09:03 +01:00
|
|
|
- name: Starting the new {{ jail_name }} jail
|
2017-03-09 17:58:42 +01:00
|
|
|
include: '{{ ansible_roles_path }}/karolyi.ansible-freebsd-jailhost-tools/tasks/jail/start.yml'
|
2017-03-09 17:17:13 +01:00
|
|
|
|
|
|
|
- include: '{{ vars["jail_" + jail_name + "_include_update_poststart"] | default(jail_include_noop) }}'
|
|
|
|
vars:
|
|
|
|
include_type: '{{ "jail_" + jail_name + "_include_update_poststart" }}'
|
|
|
|
|
|
|
|
when: '{{ vars["jail_" + jail_name + "_must_replace"] }}'
|
|
|
|
|
|
|
|
|
|
|
|
|