This commit is contained in:
parent
369bb998f9
commit
934da68bb5
13
states/etcd/config.sls
Normal file
13
states/etcd/config.sls
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
{%- from "etcd/map.jinja" import etcd with context %}
|
||||||
|
etcd-config-dir:
|
||||||
|
file.directory:
|
||||||
|
- name: /etc/etcd
|
||||||
|
|
||||||
|
etcd-config:
|
||||||
|
file.managed:
|
||||||
|
- name: /etc/etcd/etcd.yml
|
||||||
|
- source: salt://etcd/templates/etcd.yml.j2
|
||||||
|
- template: jinja
|
||||||
|
- watch_in:
|
||||||
|
- service: etcd-service
|
20
states/etcd/defaults.yaml
Normal file
20
states/etcd/defaults.yaml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
etcd:
|
||||||
|
enabled: true
|
||||||
|
install_dir: /usr/local/apps
|
||||||
|
release_dir: /usr/local/apps/releases
|
||||||
|
mirror: https://github.com/etcd-io/etcd/releases/download
|
||||||
|
version: 3.5.9
|
||||||
|
os: linux
|
||||||
|
arch: amd64
|
||||||
|
runuser: etcd
|
||||||
|
user: user
|
||||||
|
password: password
|
||||||
|
verify: false
|
||||||
|
config:
|
||||||
|
name: etcd
|
||||||
|
data-dir: /var/lib/etcd
|
||||||
|
initial-advertise-peer-urls: http://sys99.paulbsd.com:2380
|
||||||
|
advertise-client-urls: http://sys99.paulbsd.com:2379
|
||||||
|
listen-peer-urls: http://[::]:2380
|
||||||
|
listen-client-urls: http://[::]:2379
|
5
states/etcd/init.sls
Normal file
5
states/etcd/init.sls
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
include:
|
||||||
|
- .install
|
||||||
|
- .config
|
||||||
|
- .service
|
41
states/etcd/install.sls
Normal file
41
states/etcd/install.sls
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
{%- from "etcd/map.jinja" import etcd with context %}
|
||||||
|
etcd-user:
|
||||||
|
user.present:
|
||||||
|
- name: {{ etcd.runuser }}
|
||||||
|
- shell: /bin/nologin
|
||||||
|
|
||||||
|
etcd-archive-extract:
|
||||||
|
archive.extracted:
|
||||||
|
- name: {{ etcd.release_dir }}/etcd-{{ etcd.version }}
|
||||||
|
- source: {{ etcd.mirror }}/v{{ etcd.version }}/etcd-v{{ etcd.version }}-{{ etcd.os }}-{{ etcd.arch }}.tar.gz
|
||||||
|
- user: {{ etcd.runuser }}
|
||||||
|
- enforce_toplevel: false
|
||||||
|
- skip_verify: true
|
||||||
|
- archive_format: tar
|
||||||
|
- options: --strip 1
|
||||||
|
- if_missing: {{ etcd.release_dir }}/etcd-{{ etcd.version }}
|
||||||
|
- watch_in:
|
||||||
|
- service: etcd-service
|
||||||
|
|
||||||
|
etcd-bin-symlink:
|
||||||
|
file.symlink:
|
||||||
|
- name: {{ etcd.install_dir }}/etcd
|
||||||
|
- target: {{ etcd.release_dir }}/etcd-{{ etcd.version }}
|
||||||
|
- user: {{ etcd.runuser }}
|
||||||
|
- force: true
|
||||||
|
- watch_in:
|
||||||
|
- service: etcd-service
|
||||||
|
|
||||||
|
etcd-data-dir:
|
||||||
|
file.directory:
|
||||||
|
- name: {{ etcd.config.get('data-dir') }}
|
||||||
|
- user: {{ etcd.runuser }}
|
||||||
|
- watch_in:
|
||||||
|
- service: etcd-service
|
||||||
|
|
||||||
|
etcd-cleanup:
|
||||||
|
software.cleanup:
|
||||||
|
- name: etcd
|
||||||
|
- path: {{ etcd.release_dir }}
|
||||||
|
- version: "{{ etcd.version }}"
|
3
states/etcd/kernelmap.yaml
Normal file
3
states/etcd/kernelmap.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
Linux:
|
||||||
|
os: "linux"
|
14
states/etcd/map.jinja
Normal file
14
states/etcd/map.jinja
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{%- import_yaml "etcd/defaults.yaml" as default_settings -%}
|
||||||
|
|
||||||
|
{%- import_yaml "etcd/kernelmap.yaml" as kernelmap %}
|
||||||
|
{%- import_yaml "etcd/osarchmap.yaml" as osarchmap %}
|
||||||
|
|
||||||
|
{%- set defaults = salt['grains.filter_by'](default_settings,
|
||||||
|
default='etcd',
|
||||||
|
merge=salt['grains.filter_by'](osarchmap, grain='osarch',
|
||||||
|
merge=salt['grains.filter_by'](kernelmap, grain='kernel')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
-%}
|
||||||
|
|
||||||
|
{%- set etcd = salt['pillar.get']('etcd', default=defaults, merge=True) -%}
|
21
states/etcd/osarchmap.yaml
Normal file
21
states/etcd/osarchmap.yaml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
amd64:
|
||||||
|
arch: "amd64"
|
||||||
|
|
||||||
|
x86_64:
|
||||||
|
arch: "amd64"
|
||||||
|
|
||||||
|
386:
|
||||||
|
arch: "386"
|
||||||
|
|
||||||
|
arm64:
|
||||||
|
arch: "arm64"
|
||||||
|
|
||||||
|
aarch64:
|
||||||
|
arch: "arm64"
|
||||||
|
|
||||||
|
armv7l:
|
||||||
|
arch: "armv7"
|
||||||
|
|
||||||
|
armhf:
|
||||||
|
arch: "armv7"
|
16
states/etcd/service.sls
Normal file
16
states/etcd/service.sls
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
{%- from "etcd/map.jinja" import etcd with context %}
|
||||||
|
etcd-service-file:
|
||||||
|
file.managed:
|
||||||
|
- name: /etc/systemd/system/etcd.service
|
||||||
|
- source: salt://etcd/templates/etcd.service.j2
|
||||||
|
- user: root
|
||||||
|
- group: root
|
||||||
|
- template: jinja
|
||||||
|
- watch_in:
|
||||||
|
- service: etcd-service
|
||||||
|
|
||||||
|
etcd-service:
|
||||||
|
service.running:
|
||||||
|
- name: etcd
|
||||||
|
- enable: true
|
17
states/etcd/templates/etcd.service.j2
Normal file
17
states/etcd/templates/etcd.service.j2
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{%- from "etcd/map.jinja" import etcd with context -%}
|
||||||
|
## {{ salt['pillar.get']('salt_managed', default='Salt Managed') }}
|
||||||
|
[Unit]
|
||||||
|
Description=Distributed reliable key-value store for the most critical data of a distributed system
|
||||||
|
Documentation=https://etcd.io/
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart={{ etcd.install_dir }}/etcd/etcd --config-file /etc/etcd/etcd.yml
|
||||||
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
|
KillMode=control-group
|
||||||
|
Restart=on-failure
|
||||||
|
RestartForceExitStatus=SIGPIPE
|
||||||
|
WorkingDirectory=/var/lib/etcd
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
4
states/etcd/templates/etcd.yml.j2
Normal file
4
states/etcd/templates/etcd.yml.j2
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
## {{ salt['pillar.get']('salt_managed', default='Salt Managed') }}
|
||||||
|
---
|
||||||
|
{%- from "etcd/map.jinja" import etcd with context %}
|
||||||
|
{{ etcd.config|yaml(False) }}
|
Loading…
Reference in New Issue
Block a user