diff --git a/etcd/README.md b/etcd/README.md new file mode 100644 index 00000000..7dacc49e --- /dev/null +++ b/etcd/README.md @@ -0,0 +1,3 @@ +# Etcd + +Installation and basic configuration of etcd for integrate in a Patroni and PostgreSQL cluster. diff --git a/etcd/defaults/main.yml b/etcd/defaults/main.yml new file mode 100644 index 00000000..890012d1 --- /dev/null +++ b/etcd/defaults/main.yml @@ -0,0 +1,11 @@ +--- + +# Define variable for etcd +etcd_listen_ip: [] +etcd_cluster_ips: [] +etcd_client_port: "2379" +etcd_peer_port: "2380" +etcd_local_name : "" +etcd_cluster_token : "" +etcd_datadir : "/var/lib/etcd/{{ etcd_cluster_token }}" +etcd_initial_cluster: "" diff --git a/etcd/tasks/config.yml b/etcd/tasks/config.yml new file mode 100644 index 00000000..9beec617 --- /dev/null +++ b/etcd/tasks/config.yml @@ -0,0 +1,10 @@ +--- + +- name: Create etcd config file + ansible.builtin.template: + src: etcd.j2 + dest: /etc/default/etcd + owner: root + group: root + mode: "0644" + diff --git a/etcd/tasks/packages.yml b/etcd/tasks/packages.yml new file mode 100644 index 00000000..e6552ac9 --- /dev/null +++ b/etcd/tasks/packages.yml @@ -0,0 +1,15 @@ +--- + +- name: Install etcd client / server package + ansible.builtin.apt: + name: + - etcd-client + - etcd-server + update_cache: yes + +- name: Install python dependencies for Patroni + ansible.builtin.apt: + name: + - python3-etcd + - python3-psycopg2 + when: patroni_install_dependencies | bool diff --git a/etcd/templates/etcd.j2 b/etcd/templates/etcd.j2 new file mode 100644 index 00000000..0e9ac1ba --- /dev/null +++ b/etcd/templates/etcd.j2 @@ -0,0 +1,10 @@ +ETCD_NAME="{{ etcd_local_name }}" +ETCD_DATA_DIR="{{ etcd_datadir }}" +ETCD_LOG_OUTPUTS="stdout" +ETCD_LISTEN_PEER_URLS="http://{{ etcd_peer_hosts }}:{{ etcd_peer_port }}" +ETCD_LISTEN_CLIENT_URLS="http://localhost:{{ etcd_client_port }},http://{{ etcd_listen_ip }}:{{ etcd_client_port }}" +ETCD_INITIAL_ADVERTISE_PEER_URLS="http://{{ etcd_listen_ip }}:{{ etcd_peer_port }}" +ETCD_INITIAL_CLUSTER="{{ etcd_local_name }}=http://{{ etcd_cluster_ips }}:{{ etcd_peer_port }}," +ETCD_ADVERTISE_CLIENT_URLS="http://{{ etcd_listen_ip }}:{{ etcd_client_port }}" +ETCD_INITIAL_CLUSTER_TOKEN="{{ etcd_cluster_token }}" +ETCD_INITIAL_CLUSTER_STATE="new"