Merge pull request #142 from kubespray/use_ansible_service_mgr
use ansible_service_mgr to detect init systempull/143/head
commit
60d6195a9e
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
- name: reload systemd
|
- name: reload systemd
|
||||||
command: systemctl daemon-reload
|
command: systemctl daemon-reload
|
||||||
when: init_system == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
|
|
||||||
- name: reload etcd
|
- name: reload etcd
|
||||||
service:
|
service:
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
src: etcd.service.j2
|
src: etcd.service.j2
|
||||||
dest: /lib/systemd/system/etcd.service
|
dest: /lib/systemd/system/etcd.service
|
||||||
backup: yes
|
backup: yes
|
||||||
when: init_system == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
notify: restart etcd
|
notify: restart etcd
|
||||||
|
|
||||||
- name: Configure | Write etcd initd script
|
- name: Configure | Write etcd initd script
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
dest: /etc/init.d/etcd
|
dest: /etc/init.d/etcd
|
||||||
owner: root
|
owner: root
|
||||||
mode: 0755
|
mode: 0755
|
||||||
when: init_system == "sysvinit" and ansible_os_family == "Debian"
|
when: ansible_service_mgr in ["sysvinit","upstart"] and ansible_os_family == "Debian"
|
||||||
notify: restart etcd
|
notify: restart etcd
|
||||||
|
|
||||||
- name: Configure | Create etcd config file
|
- name: Configure | Create etcd config file
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
src: "kube-apiserver.service.j2"
|
src: "kube-apiserver.service.j2"
|
||||||
dest: "/etc/systemd/system/kube-apiserver.service"
|
dest: "/etc/systemd/system/kube-apiserver.service"
|
||||||
backup: yes
|
backup: yes
|
||||||
when: init_system == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
notify: restart kube-apiserver
|
notify: restart kube-apiserver
|
||||||
|
|
||||||
- name: install | Write kube-apiserver initd script
|
- name: install | Write kube-apiserver initd script
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
owner: root
|
owner: root
|
||||||
mode: 0755
|
mode: 0755
|
||||||
backup: yes
|
backup: yes
|
||||||
when: init_system == "sysvinit" and ansible_os_family == "Debian"
|
when: ansible_service_mgr in ["sysvinit","upstart"] and ansible_os_family == "Debian"
|
||||||
|
|
||||||
- name: Write kube-apiserver config file
|
- name: Write kube-apiserver config file
|
||||||
template:
|
template:
|
||||||
|
@ -91,9 +91,3 @@
|
||||||
name: kubelet
|
name: kubelet
|
||||||
state: restarted
|
state: restarted
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: restart kube-apiserver
|
|
||||||
service:
|
|
||||||
name: kube-apiserver
|
|
||||||
state: restarted
|
|
||||||
when: secret_changed | default(false)
|
|
||||||
|
|
|
@ -4,18 +4,19 @@
|
||||||
|
|
||||||
- name: reload systemd
|
- name: reload systemd
|
||||||
command: systemctl daemon-reload
|
command: systemctl daemon-reload
|
||||||
when: init_system == "systemd" and restart_apimaster is defined and restart_apimaster == True
|
when: ansible_service_mgr == "systemd" and restart_apimaster is defined and restart_apimaster == True
|
||||||
|
|
||||||
- name: reload kube-apiserver
|
- name: reload kube-apiserver
|
||||||
service:
|
service:
|
||||||
name: kube-apiserver
|
name: kube-apiserver
|
||||||
state: restarted
|
state: restarted
|
||||||
enabled: yes
|
enabled: yes
|
||||||
when: restart_apimaster is defined and restart_apimaster == True
|
when: ( restart_apimaster is defined and restart_apimaster == True) or
|
||||||
|
secret_changed | default(false)
|
||||||
|
|
||||||
- name: Enable apiserver
|
- name: Enable apiserver
|
||||||
service:
|
service:
|
||||||
name: kube-apiserver
|
name: kube-apiserver
|
||||||
enabled: yes
|
enabled: yes
|
||||||
state: started
|
state: started
|
||||||
when: restart_apimaster is not defined or restart_apimaster == False
|
when: restart_apimaster is not defined or restart_apimaster == False
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
# The following values are used to configure the kube-apiserver
|
# The following values are used to configure the kube-apiserver
|
||||||
|
|
||||||
{% if init_system == "sysvinit" %}
|
{% if ansible_service_mgr in ["sysvinit","upstart"] %}
|
||||||
# Logging directory
|
# Logging directory
|
||||||
KUBE_LOGGING="--log-dir={{ kube_log_dir }} --logtostderr=true"
|
KUBE_LOGGING="--log-dir={{ kube_log_dir }} --logtostderr=true"
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -38,7 +38,7 @@ KUBE_TLS_CONFIG="--tls_cert_file={{ kube_cert_dir }}/apiserver.pem --tls_private
|
||||||
# Add you own!
|
# Add you own!
|
||||||
KUBE_API_ARGS="--token_auth_file={{ kube_token_dir }}/known_tokens.csv --basic-auth-file={{ kube_users_dir }}/known_users.csv --service_account_key_file={{ kube_cert_dir }}/apiserver-key.pem"
|
KUBE_API_ARGS="--token_auth_file={{ kube_token_dir }}/known_tokens.csv --basic-auth-file={{ kube_users_dir }}/known_users.csv --service_account_key_file={{ kube_cert_dir }}/apiserver-key.pem"
|
||||||
|
|
||||||
{% if init_system == "sysvinit" %}
|
{% if ansible_service_mgr in ["sysvinit","upstart"] %}
|
||||||
DAEMON_ARGS="$KUBE_LOGGING $KUBE_LOG_LEVEL $KUBE_ALLOW_PRIV $KUBE_API_PORT $KUBE_SERVICE_ADDRESSES \
|
DAEMON_ARGS="$KUBE_LOGGING $KUBE_LOG_LEVEL $KUBE_ALLOW_PRIV $KUBE_API_PORT $KUBE_SERVICE_ADDRESSES \
|
||||||
$KUBE_ETCD_SERVERS $KUBE_ADMISSION_CONTROL $KUBE_RUNTIME_CONFIG $KUBE_TLS_CONFIG $KUBE_API_ARGS"
|
$KUBE_ETCD_SERVERS $KUBE_ADMISSION_CONTROL $KUBE_RUNTIME_CONFIG $KUBE_TLS_CONFIG $KUBE_API_ARGS"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
- name: reload systemd
|
- name: reload systemd
|
||||||
command: systemctl daemon-reload
|
command: systemctl daemon-reload
|
||||||
when: init_system == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
|
|
||||||
- name: restart kubelet
|
- name: restart kubelet
|
||||||
command: /bin/true
|
command: /bin/true
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
---
|
---
|
||||||
- name: install | Write kubelet systemd init file
|
- name: install | Write kubelet systemd init file
|
||||||
template: src=kubelet.service.j2 dest=/etc/systemd/system/kubelet.service backup=yes
|
template: src=kubelet.service.j2 dest=/etc/systemd/system/kubelet.service backup=yes
|
||||||
when: init_system == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
notify: restart kubelet
|
notify: restart kubelet
|
||||||
|
|
||||||
- name: install | Write kubelet initd script
|
- name: install | Write kubelet initd script
|
||||||
template: src=deb-kubelet.initd.j2 dest=/etc/init.d/kubelet owner=root mode=0755 backup=yes
|
template: src=deb-kubelet.initd.j2 dest=/etc/init.d/kubelet owner=root mode=0755 backup=yes
|
||||||
when: init_system == "sysvinit" and ansible_os_family == "Debian"
|
when: ansible_service_mgr in ["sysvinit","upstart"] and ansible_os_family == "Debian"
|
||||||
notify: restart kubelet
|
notify: restart kubelet
|
||||||
|
|
||||||
- name: install | Write kubelet initd script
|
- name: install | Write kubelet initd script
|
||||||
template: src=rh-kubelet.initd.j2 dest=/etc/init.d/kubelet owner=root mode=0755 backup=yes
|
template: src=rh-kubelet.initd.j2 dest=/etc/init.d/kubelet owner=root mode=0755 backup=yes
|
||||||
when: init_system == "sysvinit" and ansible_os_family == "RedHat"
|
when: ansible_service_mgr in ["sysvinit","upstart"] and ansible_os_family == "RedHat"
|
||||||
notify: restart kubelet
|
notify: restart kubelet
|
||||||
|
|
||||||
- name: install | Install kubelet binary
|
- name: install | Install kubelet binary
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% if init_system == "sysvinit" %}
|
{% if ansible_service_mgr in ["sysvinit","upstart"] %}
|
||||||
# Logging directory
|
# Logging directory
|
||||||
KUBE_LOGGING="--log-dir={{ kube_log_dir }} --logtostderr=true"
|
KUBE_LOGGING="--log-dir={{ kube_log_dir }} --logtostderr=true"
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -30,7 +30,7 @@ DOCKER_SOCKET="--docker-endpoint=unix:/var/run/weave/weave.sock"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
# Should this cluster be allowed to run privileged docker containers
|
# Should this cluster be allowed to run privileged docker containers
|
||||||
KUBE_ALLOW_PRIV="--allow_privileged=true"
|
KUBE_ALLOW_PRIV="--allow_privileged=true"
|
||||||
{% if init_system == "sysvinit" %}
|
{% if ansible_service_mgr in ["sysvinit","upstart"] %}
|
||||||
DAEMON_ARGS="$KUBE_LOGGING $KUBE_LOG_LEVEL $KUBE_ALLOW_PRIV $KUBELET_API_SERVER $KUBELET_ADDRESS \
|
DAEMON_ARGS="$KUBE_LOGGING $KUBE_LOG_LEVEL $KUBE_ALLOW_PRIV $KUBELET_API_SERVER $KUBELET_ADDRESS \
|
||||||
$KUBELET_HOSTNAME $KUBELET_REGISTER_NODE $KUBELET_ARGS $DOCKER_SOCKET $KUBELET_ARGS $KUBELET_NETWORK_PLUGIN"
|
$KUBELET_HOSTNAME $KUBELET_REGISTER_NODE $KUBELET_ARGS $DOCKER_SOCKET $KUBELET_ARGS $KUBELET_NETWORK_PLUGIN"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -15,24 +15,6 @@
|
||||||
paths:
|
paths:
|
||||||
- ../vars
|
- ../vars
|
||||||
|
|
||||||
- name: "Identify init system"
|
|
||||||
shell: >
|
|
||||||
$(pgrep systemd > /dev/null && systemctl status network.target > /dev/null);
|
|
||||||
if [ $? -eq 0 ] ; then
|
|
||||||
echo systemd;
|
|
||||||
else
|
|
||||||
echo sysvinit;
|
|
||||||
fi
|
|
||||||
always_run: True
|
|
||||||
register: init_system_output
|
|
||||||
changed_when: False
|
|
||||||
tags: always
|
|
||||||
|
|
||||||
- set_fact:
|
|
||||||
init_system: "{{ init_system_output.stdout }}"
|
|
||||||
always_run: True
|
|
||||||
tags: always
|
|
||||||
|
|
||||||
- name: Create kubernetes config directory
|
- name: Create kubernetes config directory
|
||||||
file:
|
file:
|
||||||
path: "{{ kube_config_dir }}"
|
path: "{{ kube_config_dir }}"
|
||||||
|
@ -56,7 +38,7 @@
|
||||||
path: "{{ kube_log_dir }}"
|
path: "{{ kube_log_dir }}"
|
||||||
state: directory
|
state: directory
|
||||||
owner: kube
|
owner: kube
|
||||||
when: init_system == "sysvinit"
|
when: ansible_service_mgr in ["sysvinit","upstart"]
|
||||||
|
|
||||||
- name: Create cni directories
|
- name: Create cni directories
|
||||||
file:
|
file:
|
||||||
|
@ -77,23 +59,26 @@
|
||||||
when: ansible_pkg_mgr == 'yum'
|
when: ansible_pkg_mgr == 'yum'
|
||||||
|
|
||||||
- name: Install python-apt for Debian distribs
|
- name: Install python-apt for Debian distribs
|
||||||
shell: apt-get install -y python-apt
|
command: apt-get install -y python-apt
|
||||||
when: ansible_os_family == "Debian"
|
when: ansible_os_family == "Debian"
|
||||||
changed_when: False
|
changed_when: False
|
||||||
|
|
||||||
- name: Install python-dnf for latest RedHat versions
|
- name: Install python-dnf for latest RedHat versions
|
||||||
shell: dnf install -y python-dnf yum
|
command: dnf install -y python-dnf yum
|
||||||
when: ansible_distribution == "Fedora" and
|
when: ansible_distribution == "Fedora" and
|
||||||
ansible_distribution_major_version > 21
|
ansible_distribution_major_version > 21
|
||||||
changed_when: False
|
changed_when: False
|
||||||
|
|
||||||
- name: Install epel-release for RedHat and CentOS distribs
|
- name: Install epel-release on RHEL
|
||||||
|
command: rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
|
||||||
|
when: ansible_distribution == "RedHat"
|
||||||
|
|
||||||
|
- name: Install epel-release on CentOS
|
||||||
action:
|
action:
|
||||||
module: "{{ ansible_pkg_mgr }}"
|
module: "{{ ansible_pkg_mgr }}"
|
||||||
name: "epel-release"
|
name: "epel-release"
|
||||||
state: latest
|
state: latest
|
||||||
when: ansible_distribution == "RedHat" or
|
when: ansible_distribution == "CentOS"
|
||||||
ansible_distribution == "CentOS"
|
|
||||||
|
|
||||||
- name: Install packages requirements
|
- name: Install packages requirements
|
||||||
action:
|
action:
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
- name : reload systemd
|
- name : reload systemd
|
||||||
shell: systemctl daemon-reload
|
shell: systemctl daemon-reload
|
||||||
when: init_system == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
|
|
||||||
- name: reload calico-node
|
- name: reload calico-node
|
||||||
service:
|
service:
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
src: systemd-docker.service
|
src: systemd-docker.service
|
||||||
dest: /lib/systemd/system/docker.service
|
dest: /lib/systemd/system/docker.service
|
||||||
notify: restart docker
|
notify: restart docker
|
||||||
when: init_system == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
|
|
||||||
- meta: flush_handlers
|
- meta: flush_handlers
|
||||||
|
|
||||||
|
@ -80,21 +80,21 @@
|
||||||
|
|
||||||
- name: Calico | Write /etc/network-environment
|
- name: Calico | Write /etc/network-environment
|
||||||
template: src=network-environment.j2 dest=/etc/network-environment
|
template: src=network-environment.j2 dest=/etc/network-environment
|
||||||
when: init_system == "sysvinit"
|
when: ansible_service_mgr in ["sysvinit","upstart"]
|
||||||
|
|
||||||
- name: Calico | Write calico-node systemd init file
|
- name: Calico | Write calico-node systemd init file
|
||||||
template: src=calico-node.service.j2 dest=/etc/systemd/system/calico-node.service
|
template: src=calico-node.service.j2 dest=/etc/systemd/system/calico-node.service
|
||||||
when: init_system == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
notify: restart calico-node
|
notify: restart calico-node
|
||||||
|
|
||||||
- name: Calico | Write calico-node initd script
|
- name: Calico | Write calico-node initd script
|
||||||
template: src=deb-calico.initd.j2 dest=/etc/init.d/calico-node owner=root mode=0755
|
template: src=deb-calico.initd.j2 dest=/etc/init.d/calico-node owner=root mode=0755
|
||||||
when: init_system == "sysvinit" and ansible_os_family == "Debian"
|
when: ansible_service_mgr in ["sysvinit","upstart"] and ansible_os_family == "Debian"
|
||||||
notify: restart calico-node
|
notify: restart calico-node
|
||||||
|
|
||||||
- name: Calico | Write calico-node initd script
|
- name: Calico | Write calico-node initd script
|
||||||
template: src=rh-calico.initd.j2 dest=/etc/init.d/calico-node owner=root mode=0755
|
template: src=rh-calico.initd.j2 dest=/etc/init.d/calico-node owner=root mode=0755
|
||||||
when: init_system == "sysvinit" and ansible_os_family == "RedHat"
|
when: ansible_service_mgr in ["sysvinit","upstart"] and ansible_os_family == "RedHat"
|
||||||
notify: restart calico-node
|
notify: restart calico-node
|
||||||
|
|
||||||
- meta: flush_handlers
|
- meta: flush_handlers
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Deployed by Ansible
|
# Deployed by Ansible
|
||||||
{% if init_system == "sysvinit" and kube_network_plugin == "flannel" and ansible_os_family == "Debian" %}
|
{% if ansible_service_mgr in ["sysvinit","upstart"] and kube_network_plugin == "flannel" and ansible_os_family == "Debian" %}
|
||||||
DOCKER_OPTS="--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}"
|
DOCKER_OPTS="--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}"
|
||||||
{% elif kube_network_plugin == "flannel" and ansible_os_family == "RedHat" %}
|
{% elif kube_network_plugin == "flannel" and ansible_os_family == "RedHat" %}
|
||||||
DOCKER_NETWORK_OPTIONS="--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}"
|
DOCKER_NETWORK_OPTIONS="--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}"
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
- name : reload systemd
|
- name : reload systemd
|
||||||
shell: systemctl daemon-reload
|
shell: systemctl daemon-reload
|
||||||
when: init_system == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
|
|
||||||
- name: reload docker
|
- name: reload docker
|
||||||
service:
|
service:
|
||||||
|
|
|
@ -47,6 +47,6 @@
|
||||||
src: systemd-docker.service
|
src: systemd-docker.service
|
||||||
dest: /lib/systemd/system/docker.service
|
dest: /lib/systemd/system/docker.service
|
||||||
notify: restart docker
|
notify: restart docker
|
||||||
when: init_system == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
|
|
||||||
- meta: flush_handlers
|
- meta: flush_handlers
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Deployed by Ansible
|
# Deployed by Ansible
|
||||||
{% if init_system == "sysvinit" and kube_network_plugin == "flannel" and ansible_os_family == "Debian" %}
|
{% if ansible_service_mgr in ["sysvinit","upstart"] and kube_network_plugin == "flannel" and ansible_os_family == "Debian" %}
|
||||||
DOCKER_OPTS="--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}"
|
DOCKER_OPTS="--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}"
|
||||||
{% elif kube_network_plugin == "flannel" %}
|
{% elif kube_network_plugin == "flannel" %}
|
||||||
OPTIONS="--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}"
|
OPTIONS="--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}"
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
- name : reload systemd
|
- name : reload systemd
|
||||||
shell: systemctl daemon-reload
|
shell: systemctl daemon-reload
|
||||||
when: init_system == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
|
|
||||||
- name: restart weave
|
- name: restart weave
|
||||||
command: /bin/true
|
command: /bin/true
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
src: systemd-docker.service
|
src: systemd-docker.service
|
||||||
dest: /lib/systemd/system/docker.service
|
dest: /lib/systemd/system/docker.service
|
||||||
notify: restart docker
|
notify: restart docker
|
||||||
when: init_system == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
|
|
||||||
- meta: flush_handlers
|
- meta: flush_handlers
|
||||||
|
|
||||||
|
@ -41,17 +41,17 @@
|
||||||
|
|
||||||
- name: Weave | Write weave systemd init file
|
- name: Weave | Write weave systemd init file
|
||||||
template: src=weave.service.j2 dest=/etc/systemd/system/weave.service
|
template: src=weave.service.j2 dest=/etc/systemd/system/weave.service
|
||||||
when: init_system == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
notify: restart systemd-weave
|
notify: restart systemd-weave
|
||||||
|
|
||||||
- name: Weave | Write weaveproxy systemd init file
|
- name: Weave | Write weaveproxy systemd init file
|
||||||
template: src=weaveproxy.service.j2 dest=/etc/systemd/system/weaveproxy.service
|
template: src=weaveproxy.service.j2 dest=/etc/systemd/system/weaveproxy.service
|
||||||
when: init_system == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
notify: restart systemd-weaveproxy
|
notify: restart systemd-weaveproxy
|
||||||
|
|
||||||
- name: Weave | Write weaveexpose systemd init file
|
- name: Weave | Write weaveexpose systemd init file
|
||||||
template: src=weaveexpose.service.j2 dest=/etc/systemd/system/weaveexpose.service
|
template: src=weaveexpose.service.j2 dest=/etc/systemd/system/weaveexpose.service
|
||||||
when: init_system == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
notify: restart systemd-weaveexpose
|
notify: restart systemd-weaveexpose
|
||||||
|
|
||||||
- name: Weave | Enable weave
|
- name: Weave | Enable weave
|
||||||
|
|
Loading…
Reference in New Issue