mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-31 09:01:23 -07:00
New sysrc module for managing rc files on FreeBSD (#1460)
* New sysrc module for managing rc files on FreeBSD * Updated sysrc module, docs and tests per reviews * Refactored the check_mode to be in the methods and not main Also updated tests * Fixed a duplicate "name" key in the sysrc test * Remove debugging output * Add changelog fragment * Remove changelog fragment * Make sure tests actually run in CI. * Update failing test due to bad path to jail * Create and remove testjail for tests * Fix and cleanup tests * Set the correct path to the testjail Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
3e9a6acff7
commit
aa33ac349c
5 changed files with 637 additions and 0 deletions
62
tests/integration/targets/sysrc/tasks/setup-testjail.yml
Normal file
62
tests/integration/targets/sysrc/tasks/setup-testjail.yml
Normal file
|
@ -0,0 +1,62 @@
|
|||
---
|
||||
#
|
||||
# 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: Setup ezjail base
|
||||
when: not ezjail_base_jail.stat.exists
|
||||
shell: "ezjail-admin install >> /tmp/ezjail.log"
|
||||
changed_when: false
|
||||
|
||||
- name: Has testjail
|
||||
register: ezjail_test_jail
|
||||
stat:
|
||||
path: /usr/jails/testjail
|
||||
|
||||
- name: Create testjail
|
||||
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"
|
Loading…
Add table
Add a link
Reference in a new issue