Commit 20da1c7a authored by Tharyrok's avatar Tharyrok
Browse files

Merge branch '13-playbook-postgresql-2' into 'main'

Resolve "Playbook Etcd"

Closes #13

See merge request Neutrinet/infra!68
parents e970387b 6351937b
Pipeline #391 passed with stage
in 1 minute and 27 seconds
etcd:
name: neutrinet-patroni
dir: "/var/lib/etcd/neutrinet-patroni"
membres:
- name: "pgsql-01"
ipv6: "2001:913:1000:11::21"
- name: "pgsql-02"
ipv6: "2001:913:1000:11::22"
- name: "pgsql-03"
ipv6: "2001:913:1000:11::23"
......@@ -59,9 +59,9 @@ haproxy-02.patata.louise.neutri.net
ceph-s3-01.patata.louise.neutri.net
ceph-s3-02.patata.louise.neutri.net
ceph-s3-03.patata.louise.neutri.net
psql-01.patata.louise.neutri.net
psql-02.patata.louise.neutri.net
psql-03.patata.louise.neutri.net
pgsql-01.patata.louise.neutri.net
pgsql-02.patata.louise.neutri.net
pgsql-03.patata.louise.neutri.net
nextcloud.patata.louise.neutri.net
web-static.patata.louise.neutri.net
dokuwiki.patata.louise.neutri.net
......@@ -90,9 +90,14 @@ ceph-s3-02.patata.louise.neutri.net
ceph-s3-03.patata.louise.neutri.net
[postgresql]
psql-01.patata.louise.neutri.net
psql-02.patata.louise.neutri.net
psql-03.patata.louise.neutri.net
pgsql-01.patata.louise.neutri.net
pgsql-02.patata.louise.neutri.net
pgsql-03.patata.louise.neutri.net
[etcd]
pgsql-01.patata.louise.neutri.net
pgsql-02.patata.louise.neutri.net
pgsql-03.patata.louise.neutri.net
[hedgedoc]
hedgedoc.patata.louise.neutri.net
......
- hosts: etcd
become: true
pre_tasks:
- name: Update cache
apt:
update_cache: true
cache_valid_time: 3600
roles:
- etcd
......@@ -8,3 +8,4 @@
- import_playbook: apps/dokuwiki.yml
- import_playbook: apps/probe.yml
- import_playbook: apps/prometheus.yml
- import_playbook: apps/etcd.yml
etcd:
name: neutrinet-patroni
dir: "/var/lib/etcd/neutrinet-patroni"
members:
- name: "buster-etcd-molecule"
ipv6: "::1"
---
- name: restart etcd
service:
name: etcd
state: restarted
*********************************
Vagrant driver installation guide
*********************************
Requirements
============
* Vagrant
* Virtualbox
Install
=======
Please refer to the `Virtual environment`_ documentation for installation best
practices. If not using a virtual environment, please consider passing the
widely recommended `'--user' flag`_ when invoking ``pip``.
.. _Virtual environment: https://virtualenv.pypa.io/en/latest/
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
.. code-block:: bash
$ pip install 'molecule_vagrant'
---
- name: Converge
hosts: all
become: true
roles:
- etcd
dependency:
name: galaxy
driver:
name: vagrant
provider:
name: virtualbox
platforms:
- name: buster-etcd-molecule
box: debian/buster64
cpu: 2
memory: 512
provisioner:
name: ansible
config_options:
defaults:
interpreter_python: /usr/bin/python3
ssh_connection:
pipelining: true
verifier:
name: ansible
---
- name: Prepare
hosts: all
become: true
pre_tasks:
- name: Mise à jour du cache APT
apt:
update_cache: true
cache_valid_time: 3600
---
- name: Installation de etcd
apt:
name:
- etcd
- etcd-client
- etcd-server
state: present
- name: Config de etcd
template:
dest: /etc/default/etcd
src: etcd.j2
owner: root
group: root
mode: "u=rw,go=r"
notify: restart etcd
- name: Activation de etcd au démarrage
service:
name: etcd
state: started
enabled: true
- name: Installation des plugins Telegraf
import_role:
name: telegraf_plugin
tags: ['telegraf_config']
{{ ansible_managed | comment }}
# [Member]
ETCD_NAME="{{ ansible_facts['nodename'] }}"
ETCD_DATA_DIR="{{ etcd['dir'] }}"
{% if 'address' in ansible_facts['default_ipv6'] %}
ETCD_LISTEN_PEER_URLS="http://[{{ ansible_facts['default_ipv6']['address'] }}]:2380"
ETCD_LISTEN_CLIENT_URLS="http://[{{ ansible_facts['default_ipv6']['address'] }}]:2379,http://localhost:2379"
{% elif 'address' in ansible_facts['default_ipv4'] %}
ETCD_LISTEN_PEER_URLS="http://[{{ ansible_facts['default_ipv4']['address'] }}]:2380"
ETCD_LISTEN_CLIENT_URLS="http://[{{ ansible_facts['default_ipv4']['address'] }}]:2379,http://localhost:2379"
{% endif %}
# [Cluster]
{% if 'address' in ansible_facts['default_ipv6'] %}
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://[{{ ansible_facts['default_ipv6']['address'] }}]:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://[{{ ansible_facts['default_ipv6']['address'] }}]:2379"
{% elif 'address' in ansible_facts['default_ipv4'] %}
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://{{ ansible_facts['default_ipv4']['address'] }}:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://{{ ansible_facts['default_ipv4']['address'] }}:2379"
{% endif %}
{% if ipv6 in etcd['members'] %}
ETCD_INITIAL_CLUSTER="{% for member in etcd['members'] %}{{ member['name'] }}=http://[{{ member['ipv6'] }}]:2380{% if not loop.last %},{% endif %}{% endfor %}"
{% elif ipv4 in etcd['members'] %}
ETCD_INITIAL_CLUSTER="{% for member in etcd['members'] %}{{ member['name'] }}=http://{{ member['ipv4'] }}:2380{% if not loop.last %},{% endif %}{% endfor %}"
{% endif %}
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="{{ etcd['name'] }}"
{{ ansible_managed | comment }}
[[inputs.prometheus]]
## Scrape metrics directly from Etcd
urls = ["http://localhost:2379/metrics"]
metric_version = 2
telegraf_plugin_template: telegraf/etcd.conf.j2
telegraf_plugin_name: etcd
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment