Skip to content

Commit

Permalink
fix openrc integration
Browse files Browse the repository at this point in the history
  • Loading branch information
bodsch committed Aug 23, 2022
1 parent 3a8e30e commit ef1ffc8
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 32 deletions.
21 changes: 21 additions & 0 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@
NETRC: ''

pre_tasks:
- name: arch- / artixlinux
block:
- name: update pacman system
command: |
pacman --refresh --sync --sysupgrade --noconfirm
- name: create depends service
copy:
mode: 0755
dest: /etc/init.d/net
content: |
#!/usr/bin/openrc-run
true
when:
- ansible_os_family | lower == 'artix linux'

when:
- ansible_distribution | lower == 'archlinux' or
ansible_os_family | lower == 'artix linux'

- debug:
msg:
- "os family : {{ ansible_distribution }} ({{ ansible_os_family }})"
Expand All @@ -15,6 +35,7 @@
- "python version : {{ ansible_python.version.major }}.{{ ansible_python.version.minor }}"

roles:
- role: syslog-ng
- role: snakeoil

...
6 changes: 4 additions & 2 deletions molecule/default/requirements.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---

- name: snakeoil
src: https://github.com/bodsch/ansible-snakeoil.git
scm: git
src: bodsch.snakeoil
version: 1.2.4

- name: syslog-ng
src: bodsch.syslog_ng

...
6 changes: 3 additions & 3 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
state: directory
owner: root
group: "{{ glauth_system_group }}"
mode: 0770
mode: 0775

- name: create certificate directory
file:
Expand All @@ -16,14 +16,14 @@
group: "{{ glauth_system_group }}"
mode: 0770

- name: create glauth.yml
- name: create glauth.conf
template:
src: "glauth/glauth.conf.j2"
dest: "{{ glauth_config_dir }}/glauth.conf"
force: true
owner: root
group: "{{ glauth_system_group }}"
mode: 0640
mode: 0664
notify:
- validate config
- reload glauth
Expand Down
2 changes: 1 addition & 1 deletion tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
file:
state: directory
path: "{{ glauth_install_path }}/plugins"
mode: 0750
mode: 0755
owner: "{{ glauth_system_user }}"
group: "{{ glauth_system_group }}"

Expand Down
62 changes: 36 additions & 26 deletions templates/init/openrc/init.d/glauth.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@ user=${user:-${SVCNAME}}
group=${group:-${SVCNAME}}

command="/usr/bin/glauth"
command_args="${command_args:--config=/etc/glauth/glauth.yml}"
supervisor="supervise-daemon"

command_args="${command_args:--config=/etc/glauth/glauth.conf}"
command_user="${user}:${group}"

command_args_background="--background"
required_files="/etc/glauth/glauth.conf"

output_log="/var/log/${RC_SVCNAME}/${RC_SVCNAME}.log"
error_log="${output_log}"
extra_started_commands="reload"

depend() {
after net
# need localmount net
# use dns
after sysfs net
}

start_pre() {
Expand All @@ -25,31 +33,33 @@ start_pre() {
chown -R ${command_user} /var/lib/glauth/
}

start() {
ebegin "Starting ${SVCNAME}"

start-stop-daemon --start \
--background \
--exec "${command}" \
--stdout ${output_log} \
--stderr ${error_log} \
--pidfile ${pidfile} \
--user ${command_user} \
-- ${command_args}

pidof glauth > "${pidfile}"

eend $? "Failed to start ${SVCNAME}"
}

stop() {
ebegin "Stopping ${SVCNAME}"
start-stop-daemon --stop \
--pidfile "${pidfile}"

eend $? "Failed to stop ${SVCNAME}"
}
# start() {
# ebegin "Starting ${SVCNAME}"
#
# start-stop-daemon \
# --start \
# --background \
# --exec "${command}" \
# --stdout ${output_log} \
# --stderr ${error_log} \
# --make-pidfile \
# --pidfile ${pidfile} \
# --user ${command_user} \
# -- ${command_args}
#
# pidof glauth > "${pidfile}"
#
# eend $? "Failed to start ${SVCNAME}"
# }

# stop() {
# ebegin "Stopping ${SVCNAME}"
# start-stop-daemon \
# --stop \
# --pidfile "${pidfile}"
#
# eend $? "Failed to stop ${SVCNAME}"
# }

reload() {
ebegin "Reloading ${SVCNAME}"
Expand Down

0 comments on commit ef1ffc8

Please sign in to comment.