Using var file for etcd service
parent
6e91b6f47c
commit
3a349b8519
|
@ -7,13 +7,10 @@
|
||||||
notify:
|
notify:
|
||||||
- restart etcd2
|
- restart etcd2
|
||||||
|
|
||||||
- name: Create etcd2 environment vars dir
|
- name: Create etcd2 environment vars file
|
||||||
file: path=/etc/systemd/system/etcd2.service.d state=directory
|
template:
|
||||||
|
src: etcd2-environment.j2
|
||||||
- name: Write etcd2 config file
|
dest: /etc/etcd2-environment
|
||||||
template: src=etcd2.j2 dest=/etc/systemd/system/etcd2.service.d/10-etcd2.conf backup=yes
|
|
||||||
notify:
|
|
||||||
- restart etcd2
|
|
||||||
|
|
||||||
- name: Ensure etcd2 is running
|
- name: Ensure etcd2 is running
|
||||||
service: name=etcd2 state=started enabled=yes
|
service: name=etcd2 state=started enabled=yes
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
ETCD_DATA_DIR="/var/lib/etcd2"
|
||||||
|
{% if inventory_hostname in groups['etcd'] %}
|
||||||
|
{% set etcd = {} %}
|
||||||
|
{% for srv in groups['etcd'] %}
|
||||||
|
{% if inventory_hostname == srv %}
|
||||||
|
{% set _dummy = etcd.update({'name':"master"+loop.index|string}) %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
ETCD_ADVERTISE_CLIENT_URLS="http://{{ hostvars[inventory_hostname]['ip'] | default( ansible_default_ipv4.address) }}:2379"
|
||||||
|
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://{{ hostvars[inventory_hostname]['ip'] | default( ansible_default_ipv4.address) }}:2380"
|
||||||
|
ETCD_INITIAL_CLUSTER="{% for srv in groups['etcd'] %}master{{ loop.index|string }}=http://{{ srv }}:2380{% if not loop.last %},{% endif %}{% endfor %}"
|
||||||
|
ETCD_INITIAL_CLUSTER_STATE="new"
|
||||||
|
ETCD_INITIAL_CLUSTER_TOKEN="k8s_etcd"
|
||||||
|
ETCD_LISTEN_CLIENT_URLS="http://{{ hostvars[inventory_hostname]['ip'] | default( ansible_default_ipv4.address) }}:2379,http://127.0.0.1:2379"
|
||||||
|
ETCD_LISTEN_PEER_URLS="http://{{ hostvars[inventory_hostname]['ip'] | default( ansible_default_ipv4.address) }}:2380"
|
||||||
|
ETCD_NAME="{{ etcd.name }}"
|
||||||
|
{% else %}
|
||||||
|
ETCD_INITIAL_CLUSTER="{% for srv in groups['etcd'] %}master{{ loop.index|string }}=http://{{ srv }}:2380{% if not loop.last %},{% endif %}{% endfor %}"
|
||||||
|
ETCD_LISTEN_CLIENT_URLS="http://127.0.0.1:23799"
|
||||||
|
{% endif %}
|
|
@ -1,21 +0,0 @@
|
||||||
# etcd2.0
|
|
||||||
[Service]
|
|
||||||
{% if inventory_hostname in groups['etcd'] %}
|
|
||||||
{% set etcd = {} %}
|
|
||||||
{% for srv in groups['etcd'] %}
|
|
||||||
{% if inventory_hostname == srv %}
|
|
||||||
{% set _dummy = etcd.update({'name':"master"+loop.index|string}) %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
Environment="ETCD_ADVERTISE_CLIENT_URLS=http://{{ hostvars[inventory_hostname]['ip'] | default( ansible_default_ipv4.address) }}:2379"
|
|
||||||
Environment="ETCD_INITIAL_ADVERTISE_PEER_URLS=http://{{ hostvars[inventory_hostname]['ip'] | default( ansible_default_ipv4.address) }}:2380"
|
|
||||||
Environment="ETCD_INITIAL_CLUSTER={% for srv in groups['etcd'] %}master{{ loop.index|string }}=http://{{ srv }}:2380{% if not loop.last %},{% endif %}{% endfor %}"
|
|
||||||
Environment="ETCD_INITIAL_CLUSTER_STATE=new"
|
|
||||||
Environment="ETCD_INITIAL_CLUSTER_TOKEN=k8s_etcd"
|
|
||||||
Environment="ETCD_LISTEN_CLIENT_URLS=http://{{ hostvars[inventory_hostname]['ip'] | default( ansible_default_ipv4.address) }}:2379,http://127.0.0.1:2379"
|
|
||||||
Environment="ETCD_LISTEN_PEER_URLS=http://{{ hostvars[inventory_hostname]['ip'] | default( ansible_default_ipv4.address) }}:2380"
|
|
||||||
Environment="ETCD_NAME={{ etcd.name }}"
|
|
||||||
{% else %}
|
|
||||||
Environment="ETCD_INITIAL_CLUSTER={% for srv in groups['etcd'] %}master{{ loop.index|string }}=http://{{ srv }}:2380{% if not loop.last %},{% endif %}{% endfor %}"
|
|
||||||
Environment="ETCD_LISTEN_CLIENT_URLS=http://127.0.0.1:23799"
|
|
||||||
{% endif %}
|
|
|
@ -4,8 +4,7 @@ Conflicts=etcd.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=etcd
|
User=etcd
|
||||||
Environment=ETCD_DATA_DIR=/var/lib/etcd2
|
EnvironmentFile=/etc/etcd2-environment
|
||||||
Environment=ETCD_NAME=%m
|
|
||||||
{% if inventory_hostname in groups['etcd'] %}
|
{% if inventory_hostname in groups['etcd'] %}
|
||||||
ExecStart={{ bin_dir }}/etcd2
|
ExecStart={{ bin_dir }}/etcd2
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
Loading…
Reference in New Issue