Add tripleo_etcd ansible role

currently used puppet-etcd is not a openstack repo, so the
process of updating etcd configuation is complex and time taking.

This patch will introduce a ansible role 'tripleo_etcd' which
replaces puppet-etcd.
This new role generates the etcd configuration based on latest
etcd V3.4

Change-Id: Ia3cf58512c35cd1c2501c606df6fc0f4e4438120
This commit is contained in:
katarimanoj 2022-07-12 15:30:19 +05:30
parent a895c7ee94
commit 22505820de
11 changed files with 468 additions and 0 deletions

View File

@ -0,0 +1,43 @@
---
# defaults file for tripleo_etcd
tripleo_etcd_name: "{{ lookup('vars', 'fqdn_' ~ etcd_network) }}"
tripleo_etcd_ip: "{{ lookup( 'vars', etcd_network ~ '_ip' ) }}"
tripleo_etcd_wal_dir: ''
tripleo_etcd_snapshot_count: 10000
tripleo_etcd_heartbeat_interval : 100
tripleo_etcd_election_timeout: 1000
tripleo_etcd_quota_backend_bytes: 0
tripleo_etcd_max_snapshots: 5
tripleo_etcd_max_wals: 5
tripleo_etcd_cors: ''
tripleo_etcd_protocol: "{{ 'https' if tripleo_etcd_enable_internal_tls else 'http' }}"
tripleo_etcd_client_port: '2379'
tripleo_etcd_peer_port: '2380'
tripleo_etcd_discovery: ''
tripleo_etcd_discovery_failback: "proxy"
tripleo_etcd_discovery_proxy: ''
tripleo_etcd_discovery_srv: ''
tripleo_etcd_initial_cluster_state: 'new'
tripleo_etcd_strict_reconfig_check: false
tripleo_etcd_enable_pprof: true
tripleo_etcd_proxy: 'off'
tripleo_etcd_proxy_failure_wait: 5000
tripleo_etcd_refresh_interval: 30000
tripleo_etcd_dial_timeout: 1000
tripleo_etcd_write_timeout: 5000
tripleo_etcd_read_timeout: 0
tripleo_etcd_certificate_specs_service_certificate: ''
tripleo_etcd_certificate_specs_service_key: ''
tripleo_etcd_trusted_ca_file:
tripleo_etcd_peer_trusted_ca_file:
tripleo_etcd_auto_tls: false
tripleo_etcd_peer_auto_tls: false
tripleo_etcd_enable_internal_tls: false
tripleo_etcd_debug: false
tripleo_etcd_logger: "zap"
tripleo_etcd_log_outputs: [stderr]
tripleo_etcd_force_new_cluster: false
tripleo_etcd_auto_compaction_mode: "periodic"
tripleo_etcd_auto_compaction_retention: "1"
tripleo_etcd_config_dir: /var/lib/config-data/ansible-generated/etcd
tripleo_etcd_enable_grpc_gateway: true

View File

@ -0,0 +1,45 @@
---
# Copyright 2022 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
galaxy_info:
namespace: openstack
author: OpenStack
description: TripleO OpenStack Role -- tripleo_etcd
company: Red Hat
license: Apache-2.0
min_ansible_version: 2.7
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms:
- name: Fedora
versions:
- 28
- name: CentOS
versions:
- 8
galaxy_tags:
- tripleo
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies: []

View File

@ -0,0 +1,33 @@
---
# Copyright 2022 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Converge
hosts: all
tasks:
- name: Prep host for etcd
include_role:
name: tripleo_etcd
tasks_from: host_prep
- name: create etcd config
include_role:
name: tripleo_etcd
vars:
etcd_network: "network1"
etcd_node_names: [ 'node1', 'node2' ]
fqdn_network1: "node1"
network1_ip: '192.2.0.0'
tripleo_etcd_initial_cluster_token: "xyz"

View File

@ -0,0 +1,28 @@
---
driver:
name: podman
provisioner:
name: ansible
inventory:
hosts:
all:
hosts:
centos:
ansible_python_interpreter: /usr/bin/python3
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
scenario:
test_sequence:
- destroy
- create
- prepare
- converge
- check
- verify
- destroy
verifier:
name: ansible

View File

@ -0,0 +1,21 @@
---
# Copyright 2022 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Prepare
hosts: all
roles:
- role: test_deps

View File

@ -0,0 +1,61 @@
---
# Copyright 2022 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Check etcd.yml parameters
lineinfile:
name: /var/lib/config-data/ansible-generated/etcd/etc/etcd/etcd.yml
regexp: "^\\s+{{ item.var }}"
line: "{{ item.var }}: {{ item.value }}"
loop:
- {var: enable-pprof, value: 'True'}
- {var: enable-grpc-gateway, value: 'True'}
- {var: listen-client-urls, value: '"http://192.2.0.0:2379"'}
- {var: name, value: '"node1"'}
- {var: initial-cluster, value: '"node1=http://node1:2380,node2=http://node2:2380"'}
register: etcd_yaml_result
- name: Check etcd.conf parameters
lineinfile:
name: /var/lib/config-data/ansible-generated/etcd/etc/etcd/etcd.conf
regexp: "^\\s+{{ item.var }}"
line: "{{ item.var }}={{ item.value }}"
loop:
- {var: ETCD_LOGGER, value: '"zap"'}
- {var: ETCD_DISCOVERY_FAILBACK, value: '"proxy"'}
- {var: ETCD_LISTEN_PEER_URLS, value: '"http://192.2.0.0:2380"'}
- {var: ETCD_NAME, value: '"node1"'}
- {var: ETCD_INITIAL_CLUSTER, value: '"node1=http://node1:2380,node2=http://node2:2380"'}
register: etcd_conf_result
- name: Fail if etcd.yml parameters are not correct
debug:
msg: "/var/lib/config-data/ansible-generated/etcd/etc/etcd/etcd.yml settings are not correct."
when:
- etcd_yaml_result.changed
failed_when:
- true
- name: Fail if etcd.conf parameters are not correct
debug:
msg: "/var/lib/config-data/ansible-generated/etcd/etc/etcd/etcd.conf settings are not correct."
when:
- etcd_conf_result.changed
failed_when:
- true

View File

@ -0,0 +1,13 @@
- name: create /var/lib/etcd
file:
path: /var/lib/etcd
state: directory
setype: container_file_t
- name: Ensure "{{ tripleo_etcd_config_dir }}/etc/etcd" exists
file:
path: "{{ tripleo_etcd_config_dir }}/etc/etcd"
state: directory
setype: container_file_t
mode: '755'
recurse: true

View File

@ -0,0 +1,10 @@
---
- name: Create /etc/etcd/etcd.conf
template:
dest: "{{ tripleo_etcd_config_dir }}/etc/etcd/etcd.conf"
src: etc/etcd/etcd.conf.j2
- name: Create /etc/etcd/etcd.yml
template:
dest: "{{ tripleo_etcd_config_dir }}/etc/etcd/etcd.yml"
src: etc/etcd/etcd.yml.j2

View File

@ -0,0 +1,54 @@
#Etcd configuration
ETCD_NAME="{{ tripleo_etcd_name }}"
ETCD_DATA_DIR="/var/lib/etcd/{{ tripleo_etcd_name }}.etcd"
ETCD_WAL_DIR="{{ tripleo_etcd_wal_dir }}"
ETCD_SNAPSHOT_COUNT="{{ tripleo_etcd_snapshot_count }}"
ETCD_HEARTBEAT_INTERVAL="{{ tripleo_etcd_heartbeat_interval }}"
ETCD_ELECTION_TIMEOUT="{{ tripleo_etcd_election_timeout }}"
ETCD_QUOTA_BACKEND_BYTES= "{{ tripleo_etcd_quota_backend_bytes }}"
ETCD_LISTEN_PEER_URLS="{{ tripleo_etcd_protocol }}://{{ tripleo_etcd_ip }}:{{ tripleo_etcd_peer_port}}"
ETCD_LISTEN_CLIENT_URLS="{{ tripleo_etcd_protocol }}://{{ tripleo_etcd_ip }}:{{ tripleo_etcd_client_port}}"
ETCD_MAX_SNAPSHOTS="{{ tripleo_etcd_max_snapshots }}"
ETCD_MAX_WALS="{{ tripleo_etcd_max_wals }}"
ETCD_CORS="{{ tripleo_etcd_cors }}"
ETCD_INITIAL_ADVERTISE_PEER_URLS="{{ tripleo_etcd_protocol }}://{{ tripleo_etcd_ip }}:{{ tripleo_etcd_peer_port}}"
ETCD_ADVERTISE_CLIENT_URLS="{{ tripleo_etcd_protocol }}://{{ tripleo_etcd_ip }}:{{ tripleo_etcd_client_port}}"
ETCD_DISCOVERY="{{ tripleo_etcd_discovery }}"
ETCD_DISCOVERY_FAILBACK="{{ tripleo_etcd_discovery_failback }}"
ETCD_DISCOVERY_PROXY="{{ tripleo_etcd_discovery_proxy }}"
ETCD_DISCOVERY_SRV="{{ tripleo_etcd_discovery_srv }}"
{% set tripleo_etcd_initial_cluster = [] %}
{% for node in etcd_node_names %}
{{ tripleo_etcd_initial_cluster.append(node+'='+tripleo_etcd_protocol+'://'+node+":"+tripleo_etcd_peer_port) }}
{% endfor %}
ETCD_INITIAL_CLUSTER="{{ tripleo_etcd_initial_cluster | join(',') }}"
ETCD_INITIAL_CLUSTER_TOKEN="{{ tripleo_etcd_initial_cluster_token }}"
ETCD_INITIAL_CLUSTER_STATE="{{ tripleo_etcd_initial_cluster_state }}"
ETCD_STRICT_RECONFIG_CHECK={{ tripleo_etcd_strict_reconfig_check }}
ETCD_ENABLE_PPROF={{ tripleo_etcd_enable_pprof }}
ETCD_PROXY="{{ tripleo_etcd_proxy }}"
ETCD_PROXY_FAILURE_WAIT={{ tripleo_etcd_proxy_failure_wait }}
ETCD_REFRESH_INTERVAL={{ tripleo_etcd_refresh_interval }}
ETCD_DIAL_TIMEOUT={{ tripleo_etcd_dial_timeout }}
ETCD_WRITE_TIMEOUT={{ tripleo_etcd_write_timeout }}
ETCD_READ_TIMEOUT={{ tripleo_etcd_read_timeout }}
ETCD_CERT_FILE="{{ tripleo_etcd_certificate_specs_service_certificate }}"
ETCD_KEY_FILE="{{ tripleo_etcd_certificate_specs_service_key }}"
ETCD_CLIENT_CERT_AUTH="{{ tripleo_etcd_enable_internal_tls }}"
ETCD_PEER_CERT_FILE="{{ tripleo_etcd_certificate_specs_service_certificate }}"
ETCD_PEER_KEY_FILE="{{ tripleo_etcd_certificate_specs_service_key }}"
ETCD_PEER_CLIENT_CERT_AUTH="{{ tripleo_etcd_enable_internal_tls }}"
ETCD_TRUSTED_CA_FILE="{{ tripleo_etcd_trusted_ca_file }}"
ETCD_AUTO_TLS={{ tripleo_etcd_auto_tls }}
ETCD_PEER_TRUSTED_CA_FILE="{{ tripleo_etcd_trusted_ca_file }}"
ETCD_PEER_AUTO_TLS={{ tripleo_etcd_peer_auto_tls }}
ETCD_DEBUG={{ tripleo_etcd_debug }}
ETCD_LOGGER="{{ tripleo_etcd_logger }}"
ETCD_LOG_OUTPUTS={{ tripleo_etcd_log_outputs }}
ETCD_FORCE_NEW_CLSUTER={{ tripleo_etcd_force_new_cluster }}
ETCD_AUTO_COMPACTION_NODE="{{ tripleo_etcd_auto_compaction_mode }}"
ETCD_AUTO_COMPACTION_RETENTION="{{ tripleo_etcd_auto_compaction_retention }}"
ETCD_ENABLE_GRPC_GATEWAY={{ tripleo_etcd_enable_grpc_gateway }}

View File

@ -0,0 +1,150 @@
# Source URL: https://raw.githubusercontent.com/coreos/etcd/master/etcd.conf.yml.sample
# This is the configuration file for the etcd server.
# Human-readable name for this member.
name: "{{ tripleo_etcd_name }}"
# Path to the data directory.
data-dir: "/var/lib/etcd/{{ tripleo_etcd_name }}.etcd"
# Path to the dedicated wal directory.
wal-dir: "{{ tripleo_etcd_wal_dir }}"
# Number of committed transactions to trigger a snapshot to disk
snapshot-count: {{ tripleo_etcd_snapshot_count }}
# Time (in milliseconds) of a heartbeat interval.
heartbeat-interval: {{ tripleo_etcd_heartbeat_interval }}
# Time (in milliseconds) for an election to timeout.
election-timeout: {{ tripleo_etcd_election_timeout }}
# Raise alarms when backend size exceeds the given quota. 0 means use the
# default quota.
quota-backend-bytes: {{ tripleo_etcd_quota_backend_bytes }}
# List of comma separated URLs to listen on for peer traffic.
listen-peer-urls: "{{ tripleo_etcd_protocol }}://{{ tripleo_etcd_ip }}:{{ tripleo_etcd_peer_port}}"
# List of comma separated URLs to listen on for client traffic.
listen-client-urls: "{{ tripleo_etcd_protocol }}://{{ tripleo_etcd_ip }}:{{ tripleo_etcd_client_port}}"
# Maximum number of snapshot files to retain (0 is unlimited)
max-snapshots: {{ tripleo_etcd_max_snapshots }}
# Maximum number of wal files to retain (0 is unlimited).
max-wals: {{ tripleo_etcd_max_wals }}
# Comma-separated white list of origins for CORS (cross-origin resource sharing).
cors: "{{ tripleo_etcd_cors }}"
# List of this member's peer URLs to advertise to the rest of the cluster.
# The URLs needed to be a comma-separated list.
initial-advertise-peer-urls: "{{ tripleo_etcd_protocol }}://{{ tripleo_etcd_ip }}:{{ tripleo_etcd_peer_port}}"
# List of this member's client URLs to advertise to the public.
# The URLs needed to be a comma-separated list.
advertise-client-urls: "{{ tripleo_etcd_protocol }}://{{ tripleo_etcd_ip }}:{{ tripleo_etcd_client_port}}"
# Discovery URL used to bootstrap the cluster.
discovery: "{{ tripleo_etcd_discovery }}"
# Valid values include 'exit', 'proxy'
discovery-fallback: "{{ tripleo_etcd_discovery_failback }}"
# HTTP proxy to use for traffic to discovery service.
discovery-proxy: "{{ tripleo_etcd_discovery_proxy }}"
# DNS domain used to bootstrap initial cluster.
discovery-srv: "{{ tripleo_etcd_discovery_srv }}"
{% set tripleo_etcd_initial_cluster = [] %}
{% for node in etcd_node_names %}
{{ tripleo_etcd_initial_cluster.append(node+'='+tripleo_etcd_protocol+'://'+node+':'+tripleo_etcd_peer_port) }}
{% endfor %}
# Initial cluster configuration for bootstrapping.
initial-cluster: "{{ tripleo_etcd_initial_cluster | join(',') }}"
# Initial cluster token for the etcd cluster during bootstrap.
initial-cluster-token: "{{ tripleo_etcd_initial_cluster_token }}"
# Initial cluster state ('new' or 'existing').
initial-cluster-state: "{{ tripleo_etcd_initial_cluster_state }}"
# Reject reconfiguration requests that would cause quorum loss.
strict-reconfig-check: {{ tripleo_etcd_strict_reconfig_check }}
# Enable runtime profiling data via HTTP server
enable-pprof: {{ tripleo_etcd_enable_pprof }}
# proxy
proxy: "{{ tripleo_etcd_proxy }}"
# Time (in milliseconds) an endpoint will be held in a failed state.
proxy-failure-wait: {{ tripleo_etcd_proxy_failure_wait }}
# Time (in milliseconds) of the endpoints refresh interval.
proxy-refresh-interval: {{ tripleo_etcd_refresh_interval }}
# Time (in milliseconds) for a dial to timeout.
proxy-dial-timeout: {{ tripleo_etcd_dial_timeout }}
# Time (in milliseconds) for a write to timeout.
proxy-write-timeout: {{ tripleo_etcd_write_timeout }}
# Time (in milliseconds) for a read to timeout.
proxy-read-timeout: {{ tripleo_etcd_read_timeout }}
client-transport-security:
# Path to the client server TLS cert file.
cert-file: "{{ tripleo_etcd_certificate_specs_service_certificate }}"
# Path to the client server TLS key file.
key-file: "{{ tripleo_etcd_certificate_specs_service_key }}"
# Enable client cert authentication.
client-cert-auth: {{ tripleo_etcd_enable_internal_tls }}
# Path to the client server TLS trusted CA key file.
trusted-ca-file: "{{ tripleo_etcd_trusted_ca_file }}"
# Client TLS using generated certificates
auto-tls: {{ tripleo_etcd_auto_tls }}
peer-transport-security:
# Path to the peer server TLS cert file.
cert-file: "{{ tripleo_etcd_certificate_specs_service_certificate }}"
# Path to the peer server TLS key file.
key-file: "{{ tripleo_etcd_certificate_specs_service_key }}"
# Enable peer client cert authentication.
client-cert-auth: {{ tripleo_etcd_enable_internal_tls }}
# Path to the peer server TLS trusted CA key file.
trusted-ca-file: "{{ tripleo_etcd_peer_trusted_ca_file }}"
# Peer TLS using generated certificates.
auto-tls: {{ tripleo_etcd_peer_auto_tls }}
# Enable debug-level logging for etcd.
debug: {{ tripleo_etcd_debug }}
# logger logs server-side operation
logger: "{{ tripleo_etcd_logger }}"
# Specify 'stdout' or 'stderr' to skip journald logging even when running under systemd.
log-outputs: {{ tripleo_etcd_log_outputs }}
# Force to create a new one member cluster.
force-new-cluster: {{ tripleo_etcd_force_new_cluster }}
# Compaction mode , can be periodic|revison
auto-compaction-mode: "{{ tripleo_etcd_auto_compaction_mode }}"
# Duration based compaction retention, defaulting to hours if no time unit is provided
auto-compaction-retention: "{{ tripleo_etcd_auto_compaction_retention }}"
# Enable etcd's grpc gateway for tooz etcd3gw driver
enable-grpc-gateway: {{ tripleo_etcd_enable_grpc_gateway }}

View File

@ -30,6 +30,7 @@
- tripleo-ansible-centos-stream-molecule-tripleo_container_stop
- tripleo-ansible-centos-stream-molecule-tripleo_container_tag
- tripleo-ansible-centos-stream-molecule-tripleo_create_admin
- tripleo-ansible-centos-stream-molecule-tripleo_etcd
- tripleo-ansible-centos-stream-molecule-tripleo_firewall
- tripleo-ansible-centos-stream-molecule-tripleo_ha_wrapper
- tripleo-ansible-centos-stream-molecule-tripleo_hieradata
@ -103,6 +104,7 @@
- tripleo-ansible-centos-stream-molecule-tripleo_container_stop
- tripleo-ansible-centos-stream-molecule-tripleo_container_tag
- tripleo-ansible-centos-stream-molecule-tripleo_create_admin
- tripleo-ansible-centos-stream-molecule-tripleo_etcd
- tripleo-ansible-centos-stream-molecule-tripleo_firewall
- tripleo-ansible-centos-stream-molecule-tripleo_ha_wrapper
- tripleo-ansible-centos-stream-molecule-tripleo_hieradata
@ -176,6 +178,7 @@
- tripleo-ansible-centos-stream-molecule-tripleo_container_stop
- tripleo-ansible-centos-stream-molecule-tripleo_container_tag
- tripleo-ansible-centos-stream-molecule-tripleo_create_admin
- tripleo-ansible-centos-stream-molecule-tripleo_etcd
- tripleo-ansible-centos-stream-molecule-tripleo_firewall
- tripleo-ansible-centos-stream-molecule-tripleo_ha_wrapper
- tripleo-ansible-centos-stream-molecule-tripleo_hieradata
@ -427,6 +430,13 @@
parent: tripleo-ansible-centos-stream-base
vars:
tripleo_role_name: tripleo_create_admin
- job:
files:
- ^tripleo_ansible/roles/tripleo_etcd/(?!meta).*
name: tripleo-ansible-centos-stream-molecule-tripleo_etcd
parent: tripleo-ansible-centos-stream-base
vars:
tripleo_role_name: tripleo_etcd
- job:
files:
- ^tripleo_ansible/roles/tripleo_firewall/(?!meta).*