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

120 lines
2.3 KiB
YAML

---
- 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:
- '{{ s6_etc_dir }}'
- '{{ s6_etc_dir }}/service'
- '{{ s6_etc_dir }}/service/enabled'
- name: Define enabled services bundle
copy:
dest: '{{ s6_etc_dir }}/service/enabled/type'
content: bundle
owner: root
group: wheel
mode: 0444
- name: Default to an empty set of enabled servics
file:
path: '{{ s6_etc_dir }}/service/enabled/contents'
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:
creates: '{{ s6_etc_dir }}/compiled'
chdir: '{{ s6_etc_dir }}'
- name: Link to the latest service database
command: >
env ln -shf .compiled.{{ s6_uuid }} compiled
args:
creates: '{{ s6_etc_dir }}/compiled'
chdir: '{{ s6_etc_dir }}'
- 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:
dest: '{{ s6_etc_dir }}/scan'
src: scan.j2
owner: root
group: wheel
mode: 0555
- name: Start s6-svscan from /etc/ttys
lineinfile:
path: /etc/ttys
regexp: '^null'
line: 'null "{{ s6_etc_dir }}/scan" vt100 on secure'
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