2017-03-09 17:17:13 +01:00
|
|
|
- name: Setting new {{ jail_name }} jail name
|
|
|
|
set_fact:
|
|
|
|
jail_{{ jail_name }}_newest_id: "\
|
|
|
|
{{ jail_prefix }}\
|
|
|
|
{{ ansible_date_time.year }}\
|
|
|
|
{{ ansible_date_time.month }}\
|
|
|
|
{{ ansible_date_time.day }}-\
|
|
|
|
{{ ansible_date_time.hour }}\
|
|
|
|
{{ ansible_date_time.minute }}\
|
|
|
|
{{ ansible_date_time.second }}"
|
|
|
|
|
|
|
|
- name: Set other variables for the create
|
|
|
|
set_fact:
|
|
|
|
jail_{{ jail_name }}_is_new_created: true
|
|
|
|
jail_{{ jail_name }}_new_dataset_name:
|
|
|
|
'{{ dynamic_jails_dataset_name }}/{{ vars["jail_" + jail_name + "_newest_id"] }}'
|
|
|
|
jail_{{ jail_name }}_new_path:
|
|
|
|
'{{ dynamic_jails_path }}/{{ vars["jail_" + jail_name + "_newest_id"] }}'
|
|
|
|
jail_{{ jail_name }}_new_ip: '{{ available_jail_ip }}'
|
|
|
|
|
|
|
|
- name: Clone a new ZFS filesystem for the jail
|
|
|
|
zfs:
|
|
|
|
origin: '{{ template_dataset_root_name }}@{{ latest_snapshot }}'
|
|
|
|
name: '{{ vars["jail_" + jail_name + "_new_dataset_name"] }}'
|
|
|
|
mountpoint: '{{ vars["jail_" + jail_name + "_new_path"] }}'
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Copy rc.conf over to the new jail
|
|
|
|
copy:
|
|
|
|
src: rc.conf
|
|
|
|
dest: '{{ vars["jail_" + jail_name + "_new_path"] }}/etc'
|
|
|
|
|
|
|
|
- name: Copy resolv.conf over to the new jail
|
|
|
|
copy:
|
|
|
|
src: /etc/resolv.conf
|
|
|
|
dest: '{{ vars["jail_" + jail_name + "_new_path"] }}/etc'
|
|
|
|
|
|
|
|
- name: Setup timezone in jail
|
|
|
|
command:
|
|
|
|
/usr/sbin/tzsetup
|
|
|
|
-C {{ vars['jail_' + jail_name + '_new_path'] }}
|
2017-03-10 01:16:38 +01:00
|
|
|
{{ vars['jail_' + jail_name + '_timezone'|default(vars['default_timezone'])] }}
|
|
|
|
|
|
|
|
- name: Create config dir for jail
|
|
|
|
file:
|
|
|
|
path: '{{ dynamic_jails_path }}/configs/{{ vars["jail_" + jail_name + "_newest_id"] }}'
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
- name: Templating fstab for jail
|
|
|
|
template:
|
|
|
|
src: fstab.j2
|
|
|
|
dest: '{{ dynamic_jails_path }}/configs/{{ vars["jail_" + jail_name + "_newest_id"] }}/fstab'
|
|
|
|
register: fstab_init_result
|
|
|
|
failed_when: false
|
|
|
|
ignore_errors: yes
|
|
|
|
changed_when: fstab_init_result|succeeded
|
|
|
|
|
|
|
|
- name: Adding fstab to jail startup
|
|
|
|
set_fact:
|
|
|
|
'jail_{{ jail_name }}_config_opts': >-
|
|
|
|
{{ vars["jail_" + jail_name + "_config_opts"]|default({})|combine(
|
|
|
|
{'mount.fstab':
|
|
|
|
dynamic_jails_path + '/configs/' + vars['jail_' + jail_name + '_newest_id'] + '/fstab'}
|
|
|
|
)}}
|
|
|
|
when: fstab_init_result|changed
|