Skip to content

Commit

Permalink
Use patroni_etcd_protocol variable
Browse files Browse the repository at this point in the history
  • Loading branch information
vitabaks committed Dec 23, 2024
1 parent f60b26b commit 2901a02
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion automation/molecule/tests/etcd/etcd.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Check etcd health
ansible.builtin.uri:
url: "{% if tls_cert_generate | bool %}https{% else %}http{% endif %}://{{ inventory_hostname }}:2379/health"
url: "{{ patroni_etcd_protocol }}://{{ inventory_hostname }}:2379/health"
method: GET
return_content: true
validate_certs: "{% if tls_cert_generate | bool %}true{% else %}false{% endif %}"
Expand Down
4 changes: 2 additions & 2 deletions automation/roles/confd/templates/confd.toml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ watch = true
nodes = [
{% if not dcs_exists|bool and dcs_type == 'etcd' %}
{% for host in groups['etcd_cluster'] %}
"{% if tls_cert_generate | bool %}https{% else %}http{% endif %}://{{ hostvars[host]['inventory_hostname'] }}:2379",
"{{ patroni_etcd_protocol }}://{{ hostvars[host]['inventory_hostname'] }}:2379",
{% endfor %}
{% endif %}
{% if dcs_exists|bool and dcs_type == 'etcd' %}
{% for etcd_hosts in patroni_etcd_hosts %}
"{% if tls_cert_generate | bool %}https{% else %}http{% endif %}://{{etcd_hosts.host}}:{{etcd_hosts.port}}",
"{{ patroni_etcd_protocol }}://{{etcd_hosts.host}}:{{etcd_hosts.port}}",
{% endfor %}
{% endif %}
]
Expand Down
2 changes: 1 addition & 1 deletion automation/roles/etcd/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
- name: Wait until the etcd cluster is healthy
ansible.builtin.command: >
/usr/local/bin/etcdctl endpoint health
--endpoints={% if tls_cert_generate | bool %}https{% else %}http{% endif %}://{{ inventory_hostname }}:2379
--endpoints={{ patroni_etcd_protocol }}://{{ inventory_hostname }}:2379
{% if tls_cert_generate | bool %}
--cacert=/etc/etcd/ca.crt
--cert=/etc/etcd/server.crt
Expand Down
10 changes: 5 additions & 5 deletions automation/roles/etcd/templates/etcd.conf.j2
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
ETCD_NAME="{{ ansible_hostname }}"
ETCD_LISTEN_CLIENT_URLS="{% if tls_cert_generate | bool %}https{% else %}http{% endif %}://{{ inventory_hostname }}:2379,{% if tls_cert_generate | bool %}https{% else %}http{% endif %}://127.0.0.1:2379"
ETCD_ADVERTISE_CLIENT_URLS="{% if tls_cert_generate | bool %}https{% else %}http{% endif %}://{{ inventory_hostname }}:2379"
ETCD_LISTEN_PEER_URLS="{% if tls_cert_generate | bool %}https{% else %}http{% endif %}://{{ inventory_hostname }}:2380"
ETCD_INITIAL_ADVERTISE_PEER_URLS="{% if tls_cert_generate | bool %}https{% else %}http{% endif %}://{{ inventory_hostname }}:2380"
ETCD_LISTEN_CLIENT_URLS="{{ patroni_etcd_protocol }}://{{ inventory_hostname }}:2379,{{ patroni_etcd_protocol }}://127.0.0.1:2379"
ETCD_ADVERTISE_CLIENT_URLS="{{ patroni_etcd_protocol }}://{{ inventory_hostname }}:2379"
ETCD_LISTEN_PEER_URLS="{{ patroni_etcd_protocol }}://{{ inventory_hostname }}:2380"
ETCD_INITIAL_ADVERTISE_PEER_URLS="{{ patroni_etcd_protocol }}://{{ inventory_hostname }}:2380"
ETCD_INITIAL_CLUSTER_TOKEN="{{ etcd_cluster_name }}"
ETCD_INITIAL_CLUSTER="{% for host in groups['etcd_cluster'] %}{{ hostvars[host]['ansible_hostname'] }}={% if tls_cert_generate | bool %}https{% else %}http{% endif %}://{{ hostvars[host]['inventory_hostname'] }}:2380{% if not loop.last %},{% endif %}{% endfor %}"
ETCD_INITIAL_CLUSTER="{% for host in groups['etcd_cluster'] %}{{ hostvars[host]['ansible_hostname'] }}={{ patroni_etcd_protocol }}://{{ hostvars[host]['inventory_hostname'] }}:2380{% if not loop.last %},{% endif %}{% endfor %}"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_DATA_DIR="{{ etcd_data_dir }}"
ETCD_ELECTION_TIMEOUT="5000"
Expand Down
4 changes: 2 additions & 2 deletions automation/roles/vip-manager/templates/vip-manager.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ dcs-type: {{ vip_manager_dcs_type | default(dcs_type) }} # etcd, consul or patro
{% if not dcs_exists | bool %}
dcs-endpoints:
{% for host in groups['etcd_cluster'] %}
- {% if tls_cert_generate | bool %}https{% else %}http{% endif %}://{{ hostvars[host]['inventory_hostname'] }}:2379
- {{ patroni_etcd_protocol }}://{{ hostvars[host]['inventory_hostname'] }}:2379
{% endfor %}
{% else %}
dcs-endpoints:
{% for etcd_hosts in patroni_etcd_hosts %}
- {% if tls_cert_generate | bool %}https{% else %}http{% endif %}://{{ etcd_hosts.host }}:{{ etcd_hosts.port }}
- {{ patroni_etcd_protocol }}://{{ etcd_hosts.host }}:{{ etcd_hosts.port }}
{% endfor %}
{% endif %}
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion automation/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ patroni_etcd_hosts: [] # list of servers of an existing etcd cluster
patroni_etcd_namespace: "service" # (optional) etcd namespace (prefix)
patroni_etcd_username: "" # (optional) username for etcd authentication
patroni_etcd_password: "" # (optional) password for etcd authentication
patroni_etcd_protocol: "https" # (optional) http or https, if not specified http is used
patroni_etcd_protocol: "{{ 'https' if tls_cert_generate | bool else 'http' }}"

# more options you can specify in the roles/patroni/templates/patroni.yml.j2
# https://patroni.readthedocs.io/en/latest/yaml_configuration.html#etcd
Expand Down

0 comments on commit 2901a02

Please sign in to comment.