Browse Source
Drop non systemd OS types support
Drop non systemd OS types support
Signed-off-by: Bogdan Dobrelya <bogdando@mail.ru>pull/846/head
28 changed files with 13 additions and 923 deletions
Split View
Diff Options
-
3inventory/group_vars/all.yml
-
1roles/docker/handlers/main.yml
-
5roles/docker/tasks/main.yml
-
66roles/docker/tasks/non-systemd.yml
-
1roles/etcd/handlers/main.yml
-
11roles/etcd/tasks/configure.yml
-
120roles/etcd/templates/deb-etcd-docker.initd.j2
-
109roles/etcd/templates/deb-etcd-host.initd.j2
-
1roles/kubernetes/master/handlers/main.yml
-
1roles/kubernetes/node/handlers/main.yml
-
11roles/kubernetes/node/tasks/install.yml
-
121roles/kubernetes/node/templates/deb-kubelet.initd.j2
-
10roles/kubernetes/node/templates/kubelet.j2
-
129roles/kubernetes/node/templates/rh-kubelet.initd.j2
-
13roles/kubernetes/preinstall/tasks/main.yml
-
4roles/kubernetes/preinstall/tasks/pre-upgrade.yml
-
1roles/network_plugin/calico/handlers/main.yml
-
1roles/network_plugin/calico/rr/handlers/main.yml
-
2roles/network_plugin/calico/rr/tasks/main.yml
-
20roles/network_plugin/calico/tasks/main.yml
-
124roles/network_plugin/calico/templates/deb-calico.initd.j2
-
12roles/network_plugin/calico/templates/network-environment.j2
-
140roles/network_plugin/calico/templates/rh-calico.initd.j2
-
1roles/network_plugin/flannel/handlers/main.yml
-
23roles/network_plugin/flannel/tasks/main.yml
-
1roles/network_plugin/weave/handlers/main.yml
-
3roles/network_plugin/weave/tasks/main.yml
-
2roles/reset/tasks/main.yml
@ -1,66 +0,0 @@ |
|||
--- |
|||
# This uses lineinfile instead of templates for idempotency in files that may be modified by different roles |
|||
- name: Set docker options config file path |
|||
set_fact: |
|||
docker_options_file: >- |
|||
{%- if ansible_os_family == "Debian" -%}/etc/default/docker{%- elif ansible_os_family == "RedHat" -%}/etc/sysconfig/docker{%- endif -%} |
|||
tags: facts |
|||
|
|||
- name: Set docker options config variable name |
|||
set_fact: |
|||
docker_options_name: >- |
|||
{%- if ansible_os_family == "Debian" -%}DOCKER_OPTS{%- elif ansible_os_family == "RedHat" -%}other_args{%- endif -%} |
|||
tags: facts |
|||
|
|||
- name: Set docker options config value to be written |
|||
set_fact: |
|||
docker_options_value: '"{{ docker_options }} $DOCKER_NETWORK_OPTIONS $DOCKER_STORAGE_OPTIONS $INSECURE_REGISTRY"' |
|||
tags: facts |
|||
|
|||
- name: Set docker options config line to be written |
|||
set_fact: |
|||
docker_options_line: "{{ docker_options_name }}={{ docker_options_value }}" |
|||
tags: facts |
|||
|
|||
- name: Set docker proxy lines to be written |
|||
set_fact: |
|||
docker_proxy_lines: |
|||
- { name: "HTTP_PROXY", value: '"{{ http_proxy }}"' } |
|||
- { name: "HTTPS_PROXY", value: '"{{ https_proxy }}"' } |
|||
- { name: "NO_PROXY", value: '"{{ no_proxy }}"' } |
|||
tags: facts |
|||
|
|||
- name: Remove docker daemon proxy config lines that don't match desired lines |
|||
lineinfile: |
|||
dest: "{{ docker_options_file }}" |
|||
regexp: "^{{ item.name }}=(?!{{ item.value|regex_escape() }})" |
|||
state: absent |
|||
with_items: "{{ docker_proxy_lines|default([]) }}" |
|||
when: item.value is defined and (item.value | trim != '') |
|||
|
|||
- name: Write docker daemon proxy config lines |
|||
lineinfile: |
|||
dest: "{{ docker_options_file }}" |
|||
line: "{{ item.name }}={{ item.value }}" |
|||
owner: root |
|||
group: root |
|||
mode: 0644 |
|||
with_items: "{{ docker_proxy_lines|default([]) }}" |
|||
when: item.value is defined and (item.value | trim != '') |
|||
|
|||
- name: Remove docker daemon options lines that don't match desired line |
|||
lineinfile: |
|||
dest: "{{ docker_options_file }}" |
|||
regexp: "^(DOCKER_OPTS|OPTIONS|other_args)=(?!{{ docker_options_value|regex_escape() }})" |
|||
state: absent |
|||
|
|||
- name: Write docker daemon options line |
|||
lineinfile: |
|||
dest: "{{ docker_options_file }}" |
|||
line: "{{ docker_options_line }}" |
|||
owner: root |
|||
group: root |
|||
mode: 0644 |
|||
notify: restart docker |
|||
|
|||
- meta: flush_handlers |
@ -1,120 +0,0 @@ |
|||
#!/bin/sh |
|||
set -a |
|||
|
|||
### BEGIN INIT INFO |
|||
# Provides: etcd |
|||
# Required-Start: $local_fs $network $syslog |
|||
# Required-Stop: |
|||
# Default-Start: 2 3 4 5 |
|||
# Default-Stop: 0 1 6 |
|||
# Short-Description: etcd distributed k/v store |
|||
# Description: |
|||
# etcd is a distributed, consistent key-value store for shared configuration and service discovery |
|||
### END INIT INFO |
|||
|
|||
PATH=/sbin:/usr/sbin:/bin/:/usr/bin |
|||
DESC="etcd k/v store" |
|||
NAME=etcd |
|||
DAEMON={{ docker_bin_dir }}/docker |
|||
DAEMON_EXEC=`basename $DAEMON` |
|||
DAEMON_ARGS="run --restart=on-failure:5 --env-file=/etc/etcd.env \ |
|||
--net=host \ |
|||
-v /etc/ssl/certs:/etc/ssl/certs:ro \ |
|||
-v /var/lib/etcd:/var/lib/etcd:rw \ |
|||
-v {{ etcd_cert_dir }}:{{ etcd_cert_dir }}:ro \ |
|||
--name={{ etcd_member_name | default("etcd") }} \ |
|||
{{ etcd_image_repo }}:{{ etcd_image_tag }} \ |
|||
{% if etcd_after_v3 %} |
|||
{{ etcd_container_bin_dir }}etcd |
|||
{% endif %}" |
|||
|
|||
SCRIPTNAME=/etc/init.d/$NAME |
|||
DAEMON_USER=root |
|||
STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/5/KILL/5}" |
|||
PID=/var/run/etcd.pid |
|||
|
|||
# Exit if the binary is not present |
|||
[ -x "$DAEMON" ] || exit 0 |
|||
|
|||
# Define LSB log_* functions. |
|||
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present |
|||
# and status_of_proc is working. |
|||
. /lib/lsb/init-functions |
|||
|
|||
do_status() |
|||
{ |
|||
status_of_proc -p $PID "$DAEMON" "$NAME" && exit 0 || exit $? |
|||
} |
|||
|
|||
# Function that starts the daemon/service |
|||
# |
|||
do_start() |
|||
{ |
|||
{{ docker_bin_dir }}/docker rm -f {{ etcd_member_name | default("etcd") }} &>/dev/null || true |
|||
sleep 1 |
|||
start-stop-daemon --background --start --quiet --make-pidfile --pidfile $PID --user $DAEMON_USER --exec $DAEMON -- \ |
|||
$DAEMON_ARGS \ |
|||
|| return 2 |
|||
} |
|||
|
|||
# |
|||
# Function that stops the daemon/service |
|||
# |
|||
do_stop() |
|||
{ |
|||
start-stop-daemon --stop --quiet --retry=$STOP_SCHEDULE --pidfile $PID --name $DAEMON_EXEC |
|||
RETVAL="$?" |
|||
|
|||
sleep 1 |
|||
return "$RETVAL" |
|||
} |
|||
|
|||
|
|||
case "$1" in |
|||
start) |
|||
log_daemon_msg "Starting $DESC" "$NAME" |
|||
do_start |
|||
case "$?" in |
|||
0|1) log_end_msg 0 || exit 0 ;; |
|||
2) log_end_msg 1 || exit 1 ;; |
|||
esac |
|||
;; |
|||
stop) |
|||
log_daemon_msg "Stopping $DESC" "$NAME" |
|||
if do_stop; then |
|||
log_end_msg 0 |
|||
else |
|||
log_failure_msg "Can't stop etcd" |
|||
log_end_msg 1 |
|||
fi |
|||
;; |
|||
status) |
|||
if do_status; then |
|||
log_end_msg 0 |
|||
else |
|||
log_failure_msg "etcd is not running" |
|||
log_end_msg 1 |
|||
fi |
|||
;; |
|||
|
|||
restart|force-reload) |
|||
log_daemon_msg "Restarting $DESC" "$NAME" |
|||
if do_stop; then |
|||
if do_start; then |
|||
log_end_msg 0 |
|||
exit 0 |
|||
else |
|||
rc="$?" |
|||
fi |
|||
else |
|||
rc="$?" |
|||
fi |
|||
log_failure_msg "Can't restart etcd" |
|||
log_end_msg ${rc} |
|||
;; |
|||
*) |
|||
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 |
|||
exit 3 |
|||
;; |
|||
esac |
|||
|
@ -1,109 +0,0 @@ |
|||
#!/bin/sh |
|||
set -a |
|||
|
|||
### BEGIN INIT INFO |
|||
# Provides: etcd |
|||
# Required-Start: $local_fs $network $syslog |
|||
# Required-Stop: |
|||
# Default-Start: 2 3 4 5 |
|||
# Default-Stop: 0 1 6 |
|||
# Short-Description: etcd distributed k/v store |
|||
# Description: |
|||
# etcd is a distributed, consistent key-value store for shared configuration and service discovery |
|||
### END INIT INFO |
|||
|
|||
PATH=/sbin:/usr/sbin:/bin:/usr/bin |
|||
DESC="etcd k/v store" |
|||
NAME=etcd |
|||
DAEMON={{ bin_dir }}/etcd |
|||
SCRIPTNAME=/etc/init.d/$NAME |
|||
DAEMON_USER=etcd |
|||
STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/5/KILL/5}" |
|||
PID=/var/run/etcd.pid |
|||
|
|||
# Exit if the binary is not present |
|||
[ -x "$DAEMON" ] || exit 0 |
|||
|
|||
# Read configuration variable file if it is present |
|||
[ -f /etc/etcd.env ] && . /etc/etcd.env |
|||
|
|||
# Define LSB log_* functions. |
|||
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present |
|||
# and status_of_proc is working. |
|||
. /lib/lsb/init-functions |
|||
|
|||
do_status() |
|||
{ |
|||
status_of_proc -p $PID "$DAEMON" "$NAME" && exit 0 || exit $? |
|||
} |
|||
|
|||
# Function that starts the daemon/service |
|||
# |
|||
do_start() |
|||
{ |
|||
start-stop-daemon --background --start --quiet --make-pidfile --pidfile $PID --user $DAEMON_USER --exec $DAEMON -- \ |
|||
$DAEMON_ARGS \ |
|||
|| return 2 |
|||
} |
|||
|
|||
# |
|||
# Function that stops the daemon/service |
|||
# |
|||
do_stop() |
|||
{ |
|||
start-stop-daemon --stop --quiet --retry=$STOP_SCHEDULE --pidfile $PID --name $NAME |
|||
RETVAL="$?" |
|||
|
|||
sleep 1 |
|||
return "$RETVAL" |
|||
} |
|||
|
|||
|
|||
case "$1" in |
|||
start) |
|||
log_daemon_msg "Starting $DESC" "$NAME" |
|||
do_start |
|||
case "$?" in |
|||
0|1) log_end_msg 0 || exit 0 ;; |
|||
2) log_end_msg 1 || exit 1 ;; |
|||
esac |
|||
;; |
|||
stop) |
|||
log_daemon_msg "Stopping $DESC" "$NAME" |
|||
if do_stop; then |
|||
log_end_msg 0 |
|||
else |
|||
log_failure_msg "Can't stop etcd" |
|||
log_end_msg 1 |
|||
fi |
|||
;; |
|||
status) |
|||
if do_status; then |
|||
log_end_msg 0 |
|||
else |
|||
log_failure_msg "etcd is not running" |
|||
log_end_msg 1 |
|||
fi |
|||
;; |
|||
|
|||
restart|force-reload) |
|||
log_daemon_msg "Restarting $DESC" "$NAME" |
|||
if do_stop; then |
|||
if do_start; then |
|||
log_end_msg 0 |
|||
exit 0 |
|||
else |
|||
rc="$?" |
|||
fi |
|||
else |
|||
rc="$?" |
|||
fi |
|||
log_failure_msg "Can't restart etcd" |
|||
log_end_msg ${rc} |
|||
;; |
|||
*) |
|||
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 |
|||
exit 3 |
|||
;; |
|||
esac |
|||
|
@ -1,121 +0,0 @@ |
|||
#!/bin/bash |
|||
# |
|||
### BEGIN INIT INFO |
|||
# Provides: kubelet |
|||
# Required-Start: $local_fs $network $syslog |
|||
# Required-Stop: |
|||
# Default-Start: 2 3 4 5 |
|||
# Default-Stop: 0 1 6 |
|||
# Short-Description: The Kubernetes node container manager |
|||
# Description: |
|||
# The Kubernetes container manager maintains docker state against a state file. |
|||
### END INIT INFO |
|||
|
|||
|
|||
# PATH should only include /usr/* if it runs after the mountnfs.sh script |
|||
PATH=/sbin:/usr/sbin:/bin:/usr/bin |
|||
DESC="The Kubernetes container manager" |
|||
NAME=kubelet |
|||
DAEMON={{ bin_dir }}/kubelet |
|||
DAEMON_ARGS="" |
|||
DAEMON_LOG_FILE=/var/log/$NAME.log |
|||
PIDFILE=/var/run/$NAME.pid |
|||
SCRIPTNAME=/etc/init.d/$NAME |
|||
DAEMON_USER=root |
|||
|
|||
# Exit if the package is not installed |
|||
[ -x "$DAEMON" ] || exit 0 |
|||
|
|||
# Read configuration variable file if it is present |
|||
[ -r {{kube_config_dir}}/$NAME.env ] && . {{kube_config_dir}}/$NAME.env |
|||
|
|||
# Define LSB log_* functions. |
|||
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present |
|||
# and status_of_proc is working. |
|||
. /lib/lsb/init-functions |
|||
|
|||
# |
|||
# Function that starts the daemon/service |
|||
# |
|||
do_start() |
|||
{ |
|||
{{ docker_bin_dir }}/docker rm -f kubelet &>/dev/null || true |
|||
sleep 1 |
|||
# Return |
|||
# 0 if daemon has been started |
|||
# 1 if daemon was already running |
|||
# 2 if daemon could not be started |
|||
start-stop-daemon --start --quiet --background --no-close \ |
|||
--make-pidfile --pidfile $PIDFILE \ |
|||
--exec $DAEMON -c $DAEMON_USER --test > /dev/null \ |
|||
|| return 1 |
|||
start-stop-daemon --start --quiet --background --no-close \ |
|||
--make-pidfile --pidfile $PIDFILE \ |
|||
--exec $DAEMON -c $DAEMON_USER -- \ |
|||
$DAEMON_ARGS >> $DAEMON_LOG_FILE 2>&1 \ |
|||
|| return 2 |
|||
} |
|||
|
|||
# |
|||
# Function that stops the daemon/service |
|||
# |
|||
do_stop() |
|||
{ |
|||
# Return |
|||
# 0 if daemon has been stopped |
|||
# 1 if daemon was already stopped |
|||
# 2 if daemon could not be stopped |
|||
# other if a failure occurred |
|||
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME |
|||
RETVAL="$?" |
|||
[ "$RETVAL" = 2 ] && return 2 |
|||
# Many daemons don't delete their pidfiles when they exit. |
|||
rm -f $PIDFILE |
|||
return "$RETVAL" |
|||
} |
|||
|
|||
|
|||
case "$1" in |
|||
start) |
|||
log_daemon_msg "Starting $DESC" "$NAME" |
|||
do_start |
|||
case "$?" in |
|||
0|1) log_end_msg 0 || exit 0 ;; |
|||
2) log_end_msg 1 || exit 1 ;; |
|||
esac |
|||
;; |
|||
stop) |
|||
log_daemon_msg "Stopping $DESC" "$NAME" |
|||
do_stop |
|||
case "$?" in |
|||
0|1) log_end_msg 0 ;; |
|||
2) exit 1 ;; |
|||
esac |
|||
;; |
|||
status) |
|||
status_of_proc -p $PIDFILE "$DAEMON" "$NAME" && exit 0 || exit $? |
|||
;; |
|||
|
|||
restart|force-reload) |
|||
log_daemon_msg "Restarting $DESC" "$NAME" |
|||
do_stop |
|||
case "$?" in |
|||
0|1) |
|||
do_start |
|||
case "$?" in |
|||
0) log_end_msg 0 ;; |
|||
1) log_end_msg 1 ;; # Old process is still running |
|||
*) log_end_msg 1 ;; # Failed to start |
|||
esac |
|||
;; |
|||
*) |
|||
# Failed to stop |
|||
log_end_msg 1 |
|||
;; |
|||
esac |
|||
;; |
|||
*) |
|||
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 |
|||
exit 3 |
|||
;; |
|||
esac |
@ -1,129 +0,0 @@ |
|||
#!/bin/bash |
|||
# |
|||
# /etc/rc.d/init.d/kubelet |
|||
# |
|||
# chkconfig: 2345 95 95 |
|||
# description: Daemon for kubelet (kubernetes.io) |
|||
|
|||
### BEGIN INIT INFO |
|||
# Provides: kubelet |
|||
# Required-Start: $local_fs $network $syslog cgconfig |
|||
# Required-Stop: |
|||
# Should-Start: |
|||
# Should-Stop: |
|||
# Default-Start: 2 3 4 5 |
|||
# Default-Stop: 0 1 6 |
|||
# Short-Description: start and stop kubelet |
|||
# Description: |
|||
# The Kubernetes container manager maintains docker state against a state file. |
|||
### END INIT INFO |
|||
|
|||
# Source function library. |
|||
. /etc/rc.d/init.d/functions |
|||
|
|||
prog="kubelet" |
|||
exec="{{ bin_dir }}/$prog" |
|||
pidfile="/var/run/$prog.pid" |
|||
lockfile="/var/lock/subsys/$prog" |
|||
logfile="/var/log/$prog" |
|||
|
|||
[ -e {{kube_config_dir}}/$prog.env ] && . {{kube_config_dir}}/$prog.env |
|||
|
|||
start() { |
|||
if [ ! -x $exec ]; then |
|||
if [ ! -e $exec ]; then |
|||
echo "Docker executable $exec not found" |
|||
else |
|||
echo "You do not have permission to execute the Docker executable $exec" |
|||
fi |
|||
exit 5 |
|||
fi |
|||
|
|||
check_for_cleanup |
|||
|
|||
if ! [ -f $pidfile ]; then |
|||
printf "Starting $prog:\t" |
|||
echo "\n$(date)\n" >> $logfile |
|||
$exec $DAEMON_ARGS &>> $logfile & |
|||
pid=$! |
|||
echo $pid >> $pidfile |
|||
touch $lockfile |
|||
success |
|||
echo |
|||
else |
|||
failure |
|||
echo |
|||
printf "$pidfile still exists...\n" |
|||
exit 7 |
|||
fi |
|||
} |
|||
|
|||
stop() { |
|||
echo -n $"Stopping $prog: " |
|||
killproc -p $pidfile -d 300 $prog |
|||
retval=$? |
|||
echo |
|||
[ $retval -eq 0 ] && rm -f $lockfile |
|||
return $retval |
|||
} |
|||
|
|||
restart() { |
|||
stop |
|||
start |
|||
} |
|||
|
|||
reload() { |
|||
restart |
|||
} |
|||
|
|||
force_reload() { |
|||
restart |
|||
} |
|||
|
|||
rh_status() { |
|||
status -p $pidfile $prog |
|||
} |
|||
|
|||
rh_status_q() { |
|||
rh_status >/dev/null 2>&1 |
|||
} |
|||
|
|||
|
|||
check_for_cleanup() { |
|||
if [ -f ${pidfile} ]; then |
|||
/bin/ps -fp $(cat ${pidfile}) > /dev/null || rm ${pidfile} |
|||
fi |
|||
} |
|||
|
|||
case "$1" in |
|||
start) |
|||
rh_status_q && exit 0 |
|||
$1 |
|||
;; |
|||
stop) |
|||
rh_status_q || exit 0 |
|||
$1 |
|||
;; |
|||
restart) |
|||
$1 |
|||
;; |
|||
reload) |
|||
rh_status_q || exit 7 |
|||
$1 |
|||
;; |
|||
force-reload) |
|||
force_reload |
|||
;; |
|||
status) |
|||
rh_status |
|||
;; |
|||
condrestart|try-restart) |
|||
rh_status_q || exit 0 |
|||
restart |
|||
;; |
|||
*) |
|||
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" |
|||
exit 2 |
|||
esac |
|||
|
|||
exit $? |
@ -0,0 +1,4 @@ |
|||
--- |
|||
- name: Stop if non systemd OS type |
|||
assert: |
|||
that: ansible_service_mgr == "systemd" |
@ -1,124 +0,0 @@ |
|||
#!/bin/bash |
|||
# |
|||
### BEGIN INIT INFO |
|||
# Provides: calico-node |
|||
# Required-Start: $local_fs $network $syslog |
|||
# Required-Stop: |
|||
# Default-Start: 2 3 4 5 |
|||
# Default-Stop: 0 1 6 |
|||
# Short-Description: Calico docker container |
|||
# Description: |
|||
# Runs calico as a docker container |
|||
### END INIT INFO |
|||
set -a |
|||
|
|||
PATH=/sbin:/usr/sbin:/bin:/usr/bin |
|||
DESC="Calico-node Docker" |
|||
NAME=calico-node |
|||
DAEMON={{ bin_dir }}/calicoctl |
|||
DAEMON_ARGS="" |
|||
DOCKER=$(which docker) |
|||
SCRIPTNAME=/etc/init.d/$NAME |
|||
DAEMON_USER=root |
|||
|
|||
# Exit if the binary is not present |
|||
[ -x "$DAEMON" ] || exit 0 |
|||
|
|||
# Exit if the docker package is not installed |
|||
[ -x "$DOCKER" ] || exit 0 |
|||
|
|||
# Read configuration variable file if it is present |
|||
[ -r /etc/network-environment ] && . /etc/network-environment |
|||
|
|||
# Define LSB log_* functions. |
|||
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present |
|||
# and status_of_proc is working. |
|||
. /lib/lsb/init-functions |
|||
|
|||
do_status() |
|||
{ |
|||
if [ $($DOCKER ps --format "{{.Image}}" | grep -cw 'calico/node') -eq 1 ]; then |
|||
return 0 |
|||
else |
|||
return 1 |
|||
fi |
|||
} |
|||
|
|||
# Function that starts the daemon/service |
|||
# |
|||
do_start() |
|||
{ |
|||
do_status |
|||
retval=$? |
|||
if [ $retval -ne 0 ]; then |
|||
{% if legacy_calicoctl %} |
|||
${DAEMON} node --ip=${DEFAULT_IPV4} >>/dev/null && return 0 || return 2 |
|||
{% else %} |
|||
${DAEMON} node run --ip=${DEFAULT_IPV4} >>/dev/null && return 0 || return 2 |
|||
{% endif %} |
|||
else |
|||
return 1 |
|||
fi |
|||
} |
|||
|
|||
# |
|||
# Function that stops the daemon/service |
|||
# |
|||
do_stop() |
|||
{ |
|||
{% if legacy_calicoctl %} |
|||
${DAEMON} node stop >> /dev/null || ${DAEMON} node stop --force >> /dev/null |
|||
{% else %} |
|||
echo "Current version of ${DAEMON} doesn't support 'node stop' command!" |
|||
return 1 |
|||
{% endif %} |
|||
} |
|||
|
|||
|
|||
case "$1" in |
|||
start) |
|||
log_daemon_msg "Starting $DESC" "$NAME" |
|||
do_start |
|||
case "$?" in |
|||
0|1) log_end_msg 0 || exit 0 ;; |
|||
2) log_end_msg 1 || exit 1 ;; |
|||
esac |
|||
;; |
|||
stop) |
|||
log_daemon_msg "Stopping $DESC" "$NAME" |
|||
if do_stop; then |
|||
log_end_msg 0 |
|||
else |
|||
log_failure_msg "Can't stop calico-node" |
|||
log_end_msg 1 |
|||
fi |
|||
;; |
|||
status) |
|||
if do_status; then |
|||
log_end_msg 0 |
|||
else |
|||
log_failure_msg "Calico-node is not running" |
|||
log_end_msg 1 |
|||
fi |
|||
;; |
|||
|
|||
restart|force-reload) |
|||
log_daemon_msg "Restarting $DESC" "$NAME" |
|||
if do_stop; then |
|||
if do_start; then |
|||
log_end_msg 0 |
|||
exit 0 |
|||
else |
|||
rc="$?" |
|||
fi |
|||
else |
|||
rc="$?" |
|||
fi |
|||
log_failure_msg "Can't restart Calico-node" |
|||
log_end_msg ${rc} |
|||
;; |
|||
*) |
|||
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 |
|||
exit 3 |
|||
;; |
|||
esac |
@ -1,12 +0,0 @@ |
|||
# This host's IPv4 address (the source IP address used to reach other nodes |
|||
# in the Kubernetes cluster). |
|||
DEFAULT_IPV4={{ip | default(ansible_default_ipv4.address) }} |
|||
|
|||
# The Kubernetes master IP |
|||
KUBERNETES_MASTER={{ kube_apiserver_endpoint }} |
|||
|
|||
# IP and port of etcd instance used by Calico |
|||
ETCD_ENDPOINTS={{ etcd_access_endpoint }} |
|||
ETCD_CA_CERT_FILE=/etc/calico/certs/ca_cert.crt |
|||
ETCD_CERT_FILE=/etc/calico/certs/cert.crt |
|||
ETCD_KEY_FILE=/etc/calico/certs/key.pem |
@ -1,140 +0,0 @@ |
|||
#!/bin/bash |
|||
# |
|||
# /etc/rc.d/init.d/calico-node |
|||
# |
|||
# chkconfig: 2345 95 95 |
|||
# description: Daemon for calico-node (http://www.projectcalico.org/) |
|||
set -a |
|||
|
|||
### BEGIN INIT INFO |
|||
# Provides: calico-node |
|||
# Required-Start: $local_fs $network $syslog cgconfig |
|||
# Required-Stop: |
|||
# Should-Start: |
|||
# Should-Stop: |
|||
# Default-Start: 2 3 4 5 |
|||
# Default-Stop: 0 1 6 |
|||
# Short-Description: start and stop calico-node |
|||
# Description: |
|||
# Manage calico-docker container |
|||
### END INIT INFO |
|||
|
|||
# Source function library. |
|||
. /etc/rc.d/init.d/functions |
|||
|
|||
prog="calicoctl" |
|||
exec="{{ bin_dir }}/$prog" |
|||
dockerexec="$(which docker)" |
|||
logfile="/var/log/$prog" |
|||
|
|||
[ -e /etc/network-environment ] && for i in $(cat /etc/network-environment | egrep '(^$|^#)'); do export $i; done |
|||
|
|||
do_status() |
|||
{ |
|||
if [ $($dockerexec ps --format "{{.Image}}" | grep -cw 'calico/node') -ne 1 ]; then |
|||
return 1 |
|||
fi |
|||
} |
|||
|
|||
do_start() { |
|||
if [ ! -x $exec ]; then |
|||
if [ ! -e $exec ]; then |
|||
echo "calico-node executable $exec not found" |
|||
else |
|||
echo "You do not have permission to execute the calico-node executable $exec" |
|||
fi |
|||
exit 5 |
|||
fi |
|||
|
|||
[ -x "$dockerexec" ] || exit 0 |
|||
|
|||
do_status |
|||
retval=$? |
|||
if [ $retval -ne 0 ]; then |
|||
printf "Starting $prog:\t" |
|||
echo "\n$(date)\n" >> $logfile |
|||
{% if legacy_calicoctl %} |
|||
$exec node --ip=${DEFAULT_IPV4} &>>$logfile |
|||
{% else %} |
|||
$exec node run --ip=${DEFAULT_IPV4} &>>$logfile |
|||
{% endif %} |
|||
success |
|||
echo |
|||
else |
|||
echo -n "calico-node's already running" |
|||
success |
|||
exit 0 |
|||
fi |
|||
} |
|||
|
|||
do_stop() { |
|||
echo -n $"Stopping $prog: " |
|||
{% if legacy_calicoctl %} |
|||
$exec node stop >> /dev/null || $exec node stop --force >> /dev/null |
|||
{% else %} |
|||
echo "Current version of ${exec} doesn't support 'node stop' command!" |
|||
return 1 |
|||
{% endif %} |
|||
retval=$? |
|||
echo |
|||
return $retval |
|||
} |
|||
|
|||
restart() { |
|||
do_stop |
|||
do_start |
|||
} |
|||
|
|||
reload() { |
|||
restart |
|||
} |
|||
|
|||
force_reload() { |
|||
restart |
|||
} |
|||
|
|||
case "$1" in |
|||
start) |
|||
do_start |
|||
case "$?" in |
|||
0|1) success || exit 0 ;; |
|||
2) failure || exit 1 ;; |
|||
esac |
|||
;; |
|||
stop) |
|||
echo -n "Stopping $DESC" "$NAME" |
|||
if do_stop; then |
|||
success |
|||
echo |
|||
else |
|||
echo -n "Can't stop calico-node" |
|||
failure |
|||
echo |
|||
fi |
|||
;; |
|||
restart) |
|||
$1 |
|||
;; |
|||
reload) |
|||
$1 |
|||
;; |
|||
force-reload) |
|||
force_reload |
|||
;; |
|||
status) |
|||
if do_status; then |
|||
echo -n "Calico-node is running" |
|||
success |
|||
echo |
|||
else |
|||
echo -n "Calico-node is not running" |
|||
failure |
|||
echo |
|||
fi |
|||
;; |
|||
*) |
|||
echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}" |
|||
exit 2 |
|||
esac |
|||
|
|||
exit $? |
Write
Preview
Loading…
Cancel
Save