ansible/roles/s6-rc/tasks/main.yml

120 lines
2.3 KiB
YAML
Raw Permalink Normal View History

2020-09-14 00:38:41 +02:00
---
- name: Install packages
package:
name: s6-rc
- name: Create s6-rc directories
file:
path: '{{ item }}'
state: directory
owner: root
group: wheel
mode: 0755
with_items:
2022-07-04 02:41:15 +02:00
- '{{ s6_etc_dir }}'
- '{{ s6_etc_dir }}/service'
- '{{ s6_etc_dir }}/service/enabled'
2020-09-14 00:38:41 +02:00
- name: Define enabled services bundle
copy:
2022-07-04 02:41:15 +02:00
dest: '{{ s6_etc_dir }}/service/enabled/type'
2020-09-14 00:38:41 +02:00
content: bundle
owner: root
group: wheel
mode: 0444
- name: Default to an empty set of enabled servics
file:
2022-07-04 02:41:15 +02:00
path: '{{ s6_etc_dir }}/service/enabled/contents'
2020-09-14 00:38:41 +02:00
state: touch
owner: root
group: wheel
mode: 0644
changed_when: false
- name: Pick a UUID
command: uuidgen
register: uuidgen
changed_when: false
- name: Expose the UUID as fact
set_fact:
s6_uuid: '{{ uuidgen.stdout }}'
changed_when: false
- name: Compile the s6 service definitions
command: >
s6-rc-compile -v 2 .compiled.{{ s6_uuid }} service
args:
2022-07-04 02:41:15 +02:00
creates: '{{ s6_etc_dir }}/compiled'
chdir: '{{ s6_etc_dir }}'
2020-09-14 00:38:41 +02:00
- name: Link to the latest service database
command: >
env ln -shf .compiled.{{ s6_uuid }} compiled
args:
2022-07-04 02:41:15 +02:00
creates: '{{ s6_etc_dir }}/compiled'
chdir: '{{ s6_etc_dir }}'
2020-09-14 00:38:41 +02:00
- name: Make sure that tmpfs support is loaded early
lineinfile:
path: /boot/loader.conf
regexp: '^tmpfs_load='
line: 'tmpfs_load="YES"'
- name: Add /run to fstab
mount:
path: /run
src: tmpfs
fstype: tmpfs
opts: rw,size=128m,mode=755
state: mounted
- name: Generate s6-svscan startup script
template:
2022-07-04 02:41:15 +02:00
dest: '{{ s6_etc_dir }}/scan'
2020-09-14 00:38:41 +02:00
src: scan.j2
owner: root
group: wheel
mode: 0555
- name: Start s6-svscan from /etc/ttys
lineinfile:
path: /etc/ttys
regexp: '^null'
2022-07-04 02:41:15 +02:00
line: 'null "{{ s6_etc_dir }}/scan" vt100 on secure'
2020-09-14 00:38:41 +02:00
notify:
- Reload /etc/ttys
- name: Install s6-rc rc.d script
template:
dest: /usr/local/etc/rc.d/s6-rc
src: s6-rc.j2
owner: root
group: wheel
mode: 0555
- name: Flush handlers
meta: flush_handlers
- name: Starting s6-rc
service:
name: s6-rc
state: started
enabled: yes
- name: Create s6-log group
group:
name: s6-log
gid: 20000
- name: Create s6-log user
user:
name: s6-log
uid: 20000
group: s6-log
create_home: no
home: /var/empty
shell: /bin/sh