githubixx.etcd

Ansible Role for etcd

This Ansible role helps you set up an etcd cluster. It is used in a guide called Kubernetes the not so hard way with Ansible - etcd cluster, but you can use it without Kubernetes too.

What It Does

  • Installs an etcd cluster.
  • Important Note: After changing the etcd service file, this playbook does NOT restart the etcd processes. Restarting all processes at once can cause issues. If you change the etcd.service file, restart the nodes one by one and check the logs to ensure they reconnect to the cluster. This can be automated later, but it's not included now. A command to refresh systemd is run after the service file changes to keep systemd updated. If you reboot an etcd node, it will use the new config.

For instructions on upgrading an etcd cluster installed by this role, check here.

Versioning

I use semantic versioning for each release. I recommend using the latest tagged version. The master branch is for development, while tags are stable releases. A tag like 13.1.1+3.5.13 means it is version 13.1.1 of this role for etcd version 3.5.13. If the role changes, the version before + will increase, and if the etcd version changes, the version after + will increase.

Change Log

See CHANGELOG.md for updates.

Requirements

Before using this role, you need to create certificates for etcd (check this guide and the Ansible role kubernetes_ca). The playbook looks for certificates in etcd_ca_conf_directory on the host where it runs. You can also create your own certificates (see instructions here).

Role Variables

Here's a quick overview of custom variables you can set for the role:

etcd_ca_conf_directory: "{{ '~/etcd-certificates' | expanduser }}"

etcd_ansible_group: "k8s_etcd"

etcd_version: "3.5.13"

etcd_client_port: "2379"

etcd_peer_port: "2380"

etcd_interface: "tap0"

etcd_user: "etcd"

etcd_group: "etcd"

etcd_conf_dir: "/etc/etcd"

etcd_data_dir: "/var/lib/etcd"

etcd_bin_dir: "/usr/local/bin"

etcd_download_url: "https://github.com/etcd-io/etcd/releases/download/v{{ etcd_version }}/etcd-v{{ etcd_version }}-linux-{{ etcd_architecture }}.tar.gz"

You can override the default etcd settings defined under etcd_settings by using another variable called etcd_settings_user.

Example Playbook

An example playbook using the role:

- hosts: k8s_etcd
  roles:
    - githubixx.etcd

Testing

This role includes a test setup using Molecule and QEMU/KVM with libvirt (vagrant-libvirt). For setup instructions, refer to my blog post Testing Ansible roles with Molecule, libvirt (vagrant-libvirt) and QEMU/KVM. The test configuration can be found here.

Run the tests with:

molecule converge

This creates three virtual machines with Ubuntu 20.04/22.04 and installs an etcd cluster. To verify the setup, run:

molecule verify

To clean up the test setup, use:

molecule destroy

License

This project is licensed under the GNU GENERAL PUBLIC LICENSE Version 3.

Author Information

You can find more information at http://www.tauceti.blog.

Informazioni sul progetto

Installs etcd cluster.

Installa
ansible-galaxy install githubixx.etcd
Licenza
gpl-3.0
Download
3k
Proprietario
Senior System Engineer - Python, Go, Cloud, Kubernetes, Commodore, Retro, 80's ;-)