Skip to content

Instantly share code, notes, and snippets.

@dlundgren
Last active Jan 11, 2021
Embed
What would you like to do?
Sets up ezjail for molecule testing
---
- name: install python
raw: test -e /usr/local/bin/python || (pkg install -y python)
changed_when: False
- name: reload facts
setup:
#
# Instructions for setting up a jail
# https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/jails-ezjail.html
#
- name: Setup cloned interfaces
lineinfile:
dest: /etc/rc.conf
regexp: ^cloned_interfaces=lo1
line: cloned_interfaces=lo1
- name: Activate cloned interfaces
command: "service netif cloneup"
changed_when: false
- name: install ezjail
pkgng:
name: ezjail
- name: Configure ezjail to use archive for old freebsd releases
when: ansible_distribution_version is version('11.01', '<=')
lineinfile:
dest: /usr/local/etc/ezjail.conf
regexp: ^ezjail_ftphost
line: ezjail_ftphost=ftp-archive.freebsd.org
- name: start ezjail
ignore_errors: yes
service:
name: ezjail
state: started
enabled: yes
- name: has ezjail
register: ezjail_base_jail
stat:
path: /usr/jails/basejail
- name: ezjail base
when: not ezjail_base_jail.stat.exists
shell: "ezjail-admin install >> /tmp/ezjail.log"
changed_when: false
- name: has ezjail testjail
register: ezjail_test_jail
stat:
path: /usr/jails/testjail
- name: testjail commands
when: not ezjail_test_jail.stat.exists
shell: "ezjail-admin create testjail 'lo1|127.0.1.1' >> /tmp/ezjail.log"
changed_when: false
- name: is testjail running
shell: "jls | grep testjail"
changed_when: false
failed_when: false
register: is_testjail_up
- name: start testjail
when: is_testjail_up.rc == 1
command: "ezjail-admin start testjail"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment