diff --git a/inventory/group_vars/k8s-cluster.yml b/inventory/group_vars/k8s-cluster.yml index bd7a3dc8b..df34f2c45 100644 --- a/inventory/group_vars/k8s-cluster.yml +++ b/inventory/group_vars/k8s-cluster.yml @@ -1,6 +1,9 @@ # Valid bootstrap options (required): ubuntu, coreos, centos, none bootstrap_os: none +#Directory where etcd data stored +etcd_data_dir: /var/lib/etcd + # Directory where the binaries will be installed bin_dir: /usr/local/bin diff --git a/roles/adduser/defaults/main.yml b/roles/adduser/defaults/main.yml index ab24b6cf4..af83b6842 100644 --- a/roles/adduser/defaults/main.yml +++ b/roles/adduser/defaults/main.yml @@ -1,12 +1,13 @@ --- kube_cert_group: kube-cert +etcd_data_dir: "/var/lib/etcd" addusers: etcd: name: etcd comment: "Etcd user" createhome: yes - home: "/var/lib/etcd" + home: "{{ etcd_data_dir }}" system: yes shell: /bin/nologin kube: diff --git a/roles/adduser/vars/debian.yml b/roles/adduser/vars/debian.yml index 16b39f656..925d11d4d 100644 --- a/roles/adduser/vars/debian.yml +++ b/roles/adduser/vars/debian.yml @@ -3,7 +3,7 @@ addusers: - name: etcd comment: "Etcd user" createhome: yes - home: "/var/lib/etcd" + home: "{{ etcd_data_dir }}" system: yes shell: /bin/nologin diff --git a/roles/adduser/vars/redhat.yml b/roles/adduser/vars/redhat.yml index 16b39f656..925d11d4d 100644 --- a/roles/adduser/vars/redhat.yml +++ b/roles/adduser/vars/redhat.yml @@ -3,7 +3,7 @@ addusers: - name: etcd comment: "Etcd user" createhome: yes - home: "/var/lib/etcd" + home: "{{ etcd_data_dir }}" system: yes shell: /bin/nologin diff --git a/roles/etcd/defaults/main.yml b/roles/etcd/defaults/main.yml index a81670fd3..228228020 100644 --- a/roles/etcd/defaults/main.yml +++ b/roles/etcd/defaults/main.yml @@ -1,5 +1,6 @@ --- etcd_bin_dir: "{{ local_release_dir }}/etcd/etcd-{{ etcd_version }}-linux-amd64/" +etcd_data_dir: "/var/lib/etcd" etcd_config_dir: /etc/ssl/etcd etcd_cert_dir: "{{ etcd_config_dir }}/ssl" diff --git a/roles/etcd/templates/etcd-docker.service.j2 b/roles/etcd/templates/etcd-docker.service.j2 index 09bd8aacc..24f768dd7 100644 --- a/roles/etcd/templates/etcd-docker.service.j2 +++ b/roles/etcd/templates/etcd-docker.service.j2 @@ -13,7 +13,7 @@ ExecStart={{ docker_bin_dir }}/docker run --restart=on-failure:5 \ --net=host \ -v /etc/ssl/certs:/etc/ssl/certs:ro \ -v {{ etcd_cert_dir }}:{{ etcd_cert_dir }}:ro \ --v /var/lib/etcd:/var/lib/etcd:rw \ +-v {{ etcd_data_dir }}:/var/lib/etcd:rw \ {% if etcd_memory_limit is defined %} --memory={{ etcd_memory_limit|regex_replace('Mi', 'M') }} \ {% endif %} diff --git a/roles/etcd/templates/etcd-rkt.service.j2 b/roles/etcd/templates/etcd-rkt.service.j2 index eb26bc473..4c7fd5be9 100644 --- a/roles/etcd/templates/etcd-rkt.service.j2 +++ b/roles/etcd/templates/etcd-rkt.service.j2 @@ -15,7 +15,7 @@ ExecStart=/usr/bin/rkt run \ --mount=volume=etc-ssl-certs,target=/etc/ssl/certs \ --volume=etcd-cert-dir,kind=host,source={{ etcd_cert_dir }},readOnly=true \ --mount=volume=etcd-cert-dir,target={{ etcd_cert_dir }} \ ---volume=var-lib-etcd,kind=host,source=/var/lib/etcd,readOnly=false \ +--volume=var-lib-etcd,kind=host,source={{ etcd_data_dir }},readOnly=false \ --mount=volume=var-lib-etcd,target=/var/lib/etcd \ --set-env-file=/etc/etcd.env \ --stage1-from-dir=stage1-fly.aci \ diff --git a/roles/etcd/templates/etcd.j2 b/roles/etcd/templates/etcd.j2 index a4bb8d36a..07e200e03 100644 --- a/roles/etcd/templates/etcd.j2 +++ b/roles/etcd/templates/etcd.j2 @@ -1,4 +1,4 @@ -ETCD_DATA_DIR=/var/lib/etcd +ETCD_DATA_DIR={{ etcd_data_dir }} ETCD_ADVERTISE_CLIENT_URLS={{ etcd_client_url }} ETCD_INITIAL_ADVERTISE_PEER_URLS={{ etcd_peer_url }} ETCD_INITIAL_CLUSTER_STATE={% if etcd_cluster_is_healthy.rc != 0 | bool %}new{% else %}existing{% endif %} diff --git a/roles/reset/tasks/main.yml b/roles/reset/tasks/main.yml index 5b17a094b..4df86ea2a 100644 --- a/roles/reset/tasks/main.yml +++ b/roles/reset/tasks/main.yml @@ -56,7 +56,7 @@ with_items: - "{{kube_config_dir}}" - /var/lib/kubelet - - /var/lib/etcd + - "{{ etcd_data_dir }}" - /etc/ssl/etcd - /var/log/calico - /etc/cni