fix runit install

This commit is contained in:
Yann Autissier
2022-06-22 10:02:09 +02:00
parent 14a4f86524
commit a75d5b4645
33 changed files with 200 additions and 71 deletions
+5
View File
@@ -27,5 +27,10 @@
name: "{{item.name}}"
state: "{{item.state}}"
enabled: "{{item.enabled}}"
runlevels:
- 2
- 3
- 4
- 5
become: yes
+8 -2
View File
@@ -24,10 +24,16 @@ docker_daemon_config_directory: '/etc/docker'
docker_daemon_config_file: "{{docker_daemon_config_directory}}/daemon.json"
```
* `docker_daemon_config_file` - Docker daemon configuration file
* `docker_daemon_config_data_root` - Docker daemon data root directory
``` yaml
docker_daemon_config_storage: 'overlay2'
docker_daemon_config_data_root: '/var/lib/docker'
```
* `docker_daemon_config_storage_driver` - Docker daemon storage driver
``` yaml
docker_daemon_config_storage_driver: 'overlay2'
```
* `docker_daemon_config` - docker daemon yaml config
+7 -4
View File
@@ -5,16 +5,19 @@
docker_check_kernel: '3.10'
# location of configuration files of docker daemon
docker_daemon_config_directory: "/etc/docker"
# docker_daemon_config_directory: "/etc/docker"
# configuration files of docker daemon
docker_daemon_config_file: "{{docker_daemon_config_directory}}/daemon.json"
# docker_daemon_config_file: "{{docker_daemon_config_directory}}/daemon.json"
# configure docker daemon data root directory
# docker_daemon_config_data_root: "/var/lib/docker"
# configure docker daemon storage driver
docker_daemon_config_storage: "overlay2"
# docker_daemon_config_storage: "overlay2"
# docker daemon configuration
docker_daemon_config: {}
# docker_daemon_config: {}
# docker package name
docker_package: docker
+19 -19
View File
@@ -1,27 +1,27 @@
---
# file: tasks/config.yml
- name: config - add docker storage setup
when: docker_package|length > 0 and ansible_service_mgr == "systemd" and ansible_os_family|lower == "redhat"
lineinfile: dest="{{docker_init_config_directory}}/{{docker_package}}-storage-setup" state="present" line="STORAGE_DRIVER=\"\""
become: yes
notify: restart docker
# - name: config - add docker storage setup
# when: docker_package|length > 0 and ansible_service_mgr == "systemd" and ansible_os_family|lower == "redhat"
# lineinfile: dest="{{docker_init_config_directory}}/{{docker_package}}-storage-setup" state="present" line="STORAGE_DRIVER=\"\""
# become: yes
# notify: restart docker
- name: config - register docker_daemon_config
set_fact:
docker_daemon_config: "{{ lookup('file',docker_daemon_config_file)|default('{}')|from_json}}"
ignore_errors: true
# - name: config - register docker_daemon_config
# set_fact:
# docker_daemon_config: "{{ lookup('file',docker_daemon_config_file)|default('{}')|from_json}}"
# ignore_errors: true
- name: config - add docker daemon storage configuration
when: docker_package|length > 0
template:
src: daemon.json.j2
dest: "{{docker_daemon_config_file}}"
owner: root
group: docker
mode: "0640"
become: yes
notify: restart docker
# - name: config - add docker daemon storage configuration
# when: docker_package|length > 0
# template:
# src: daemon.json.j2
# dest: "{{docker_daemon_config_file}}"
# owner: root
# group: docker
# mode: "0640"
# become: yes
# notify: restart docker
# - name: config - disable docker iptables setup
# when: docker_package|length > 0 and ansible_service_mgr == "systemd"
+5
View File
@@ -33,6 +33,11 @@
name: "{{item.name}}"
state: "{{item.state}}"
enabled: "{{item.enabled}}"
runlevels:
- 2
- 3
- 4
- 5
become: yes
- name: services - force service restart - openrc
+1
View File
@@ -105,6 +105,7 @@ hosts_packages_distro: []
# services to enable/disable
hosts_services:
- { "name": "ansible", "state": "stopped", "enabled": "no" }
- { "name": "myos", "state": "stopped", "enabled": "no" }
- { "name": "zram", "state": "stopped", "enabled": "no" }
# list of urls to get public keys to add to ~/.ssh/authorized_keys
+2 -2
View File
@@ -1,8 +1,6 @@
# shellcheck shell=bash source=/dev/null
# ~/.bash_profile: executed by the command interpreter for bash login shell.
[ -f ~/.sh_profile ] && . ~/.sh_profile
# bash-completion
if ! shopt -oq posix && [ -z "${BASH_COMPLETION_VERSINFO-}" ]; then
if [ "${BASH_VERSINFO[0]}" -gt 4 ] \
@@ -17,3 +15,5 @@ if ! shopt -oq posix && [ -z "${BASH_COMPLETION_VERSINFO-}" ]; then
. "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion"
fi
fi
[ -f ~/.sh_profile ] && . ~/.sh_profile
+2 -1
View File
@@ -1,6 +1,5 @@
# shellcheck shell=sh source=/dev/null
# ~/.sh_profile: executed by the command interpreter for login shells.
# set -x
# source ~/.*aliases and ~/.*functions files
for source in aliases functions; do
@@ -36,3 +35,5 @@ for path in /*/local/sbin /*/local/bin /*/local/*/bin "${HOME}"/.*/bin; do
*) export PATH="${path}:$PATH" ;;
esac
done
[ -f ~/.profile ] && . ~/.profile
+42 -2
View File
@@ -9,11 +9,51 @@
# Description: MYOS system calls
### END INIT INFO
NAME="$(basename "$0")"
# check system config
[ -r /etc/default/myos ] && . /etc/default/myos 2>/dev/null
type make >/dev/null 2>&1 && [ -d "${MYOS}" ] || exit 1
type make >/dev/null 2>&1 && [ -d "${MYOS}" ] && cd "${MYOS}" || exit 1
case "$1" in
force-stop)
HOOK="stop stack-node-stop"
shift
;;
force-reload)
HOOK="recreate stack-node-recreate"
shift
;;
force-restart)
HOOK="restart stack-node-restart"
shift
;;
force-shutdown)
HOOK="down stack-node-down"
shift
;;
reload)
HOOK="recreate"
shift
;;
shutdown)
HOOK="down"
shift
;;
start)
echo "Starting $NAME..."
HOOK="up"
shift
;;
status)
HOOK="ps"
shift
;;
stop)
echo "Stopping $NAME..."
;;
*)
IFS=$'\n'; cd "${MYOS}"; exec env $(cat /etc/default/myos ~/.myos 2>/dev/null) make "$@"
;;
esac
IFS=$'\n'; exec env $(cat /etc/default/myos ~/.myos 2>/dev/null) make ${HOOK:-} "${@}"
@@ -10,7 +10,7 @@ start() {
}
status() {
/etc/init.d/myos ps
/etc/init.d/myos status
}
stop() {
@@ -9,10 +9,10 @@ start() {
/etc/init.d/zram start
}
stop() {
/etc/init.d/zram stop
}
status() {
/etc/init.d/zram status
}
stop() {
/etc/init.d/zram stop
}
@@ -2,7 +2,7 @@
# file rc_functions.sh: Define shell functions
## author: Yann "aya" Autissier
## license: GPL
## version: 20210714
## version: 20220620
# function force: Run a command sine die
force() {
@@ -135,8 +135,8 @@ ps1_set() {
fi
)"
PS1_GIT="${COLOR_CYAN}${PS1_GIT}${COLOR_RESET}"
PS1_HOSTNAME_COLOR="\`case \"\${ENV}\" in
[Pp][Rr][0Oo][Dd]*)
PS1_HOSTNAME_COLOR="\`case \"\${ENV}${HOSTNAME%%.*}\" in
*[Pp][Rr][0Oo][Dd]*|*[Pp][Rr][Dd]*)
printf \"${COLOR_RED}\";;
*)
if [ -n \"\${ENV}\" ]; then
+13
View File
@@ -0,0 +1,13 @@
#!/bin/sh
set -e
NAME="$(basename "$(pwd)")"
[ "$1" = -1 ] && echo "ERROR: unexpected error"
[ "$1" = 1 ] && echo "ERROR: $NAME config error" \
&& sv d "$NAME" && exit 0
[ "$1" = 2 ] && echo "ERROR: $NAME exit error" \
&& sv d "$NAME" && exit 0
exec /etc/init.d/"$NAME" stop 2>&1
+15
View File
@@ -0,0 +1,15 @@
#!/bin/sh
set -e
NAME="$(basename "$(dirname "$(pwd)")")"
LOG_DIR="/var/log/runit/$NAME"
LOG_GROUP=adm
LOG_USER=nobody
SUPERVISE_DIR="/var/run/runit/supervise/${NAME}.log"
mkdir -p "$SUPERVISE_DIR" && chmod 700 "$SUPERVISE_DIR"
[ ! -h supervise ] && rm -rf supervise && ln -s "$SUPERVISE_DIR" supervise
mkdir -p "$LOG_DIR" && chmod 750 "$LOG_DIR"
chown -R "$LOG_USER":"$LOG_GROUP" "$LOG_DIR"
exec chpst -u "$LOG_USER" svlogd -tt "$LOG_DIR"
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env /lib/runit/invoke-run
# shellcheck shell=sh
set -e
NAME="$(basename "$(dirname "$0")")"
SUPERVISE_DIR="/var/run/runit/supervise/$NAME"
mkdir -p "$SUPERVISE_DIR" && chmod 700 "$SUPERVISE_DIR"
[ ! -h supervise ] && rm -rf supervise && ln -s "$SUPERVISE_DIR" supervise
sv once "$NAME"
exec /etc/init.d/"$NAME" start 2>&1
+1
View File
@@ -3,6 +3,7 @@
- name: config - set MYOS config in /etc/default/myos
with_items:
- APP_NAME={{ lookup('env','ANSIBLE_APP_NAME') }}
- APP_TYPE={{ lookup('env','ANSIBLE_APP_TYPE') }}
- MYOS={{ lookup('env','ANSIBLE_MYOS') }}
lineinfile:
+5
View File
@@ -27,5 +27,10 @@
name: "{{item.name}}"
state: "{{item.state}}"
enabled: "{{item.enabled}}"
runlevels:
- 2
- 3
- 4
- 5
become: yes
-5
View File
@@ -46,11 +46,6 @@
- unset user_count process_count
lineinfile: dest=~/.bashrc create=yes line='{{item}}'
- name: user - update ~/.profile
with_items:
- source ~/.sh_profile
lineinfile: dest=~/.profile create=yes line='{{item}}'
- name: user - update ~/.config/git/ignore
with_items:
- '.nfs*'
+5
View File
@@ -27,5 +27,10 @@
name: "{{item.name}}"
state: "{{item.state}}"
enabled: "{{item.enabled}}"
runlevels:
- 2
- 3
- 4
- 5
become: yes