Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use sysrc and service modules instead of lineinfile #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ bastille_zfs_enable: ""
bastille_zfs_zpool: ""
bastille_ext_if: "vtnet0"
bastille_releases:
- 13.0-RELEASE
- 13.1-RELEASE
bastille_timezone: "Etc/UTC"
33 changes: 13 additions & 20 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,21 @@
dest: /usr/local/etc/bastille/bastille.conf

- name: "Enables bastille service"
lineinfile:
path: /etc/rc.conf
regexp: "^bastille_enable.+$"
line: 'bastille_enable="YES"'
service:
name: bastille
enabled: true

# Networking
- name: "Setup cloned interfaces"
lineinfile:
path: /etc/rc.conf
regexp: "^cloned_interfaces.+$"
line: 'cloned_interfaces="lo1"'
community.general.sysrc:
name: cloned_interfaces
state: value_present
value: lo1

- name: "Setup lo1 interface name"
lineinfile:
path: /etc/rc.conf
regexp: "^ifconfig_lo1_name.+$"
line: 'ifconfig_lo1_name="bastille0"'
community.general.sysrc:
name: ifconfig_lo1_name
value: bastille0

- name: "Starts the cloned interface"
command: 'service netif cloneup'
Expand All @@ -64,15 +62,10 @@
dest: /etc/pf.conf
notify: restart pf

- name: "Enables pf service"
lineinfile:
path: /etc/rc.conf
regexp: "^pf_enable.+$"
line: 'pf_enable="YES"'

- name: "Start pf"
service:
- name: Enable pf in rc.conf
ansible.builtin.service:
name: pf
enabled: "YES"
state: started

# After starting pf the first time, the ssh connection is lost.
Expand Down