include:
  - repositories
  - ca-cert
  - cert

etcd:
  group.present:
    - name: etcd
    - system: True
  user.present:
    - name: etcd
    - createhome: False
    - groups:
      - etcd
    - require:
      - group: etcd
  file.directory:
    - name: /var/lib/etcd
    - user: etcd
    - group: etcd
    - dir_mode: 700
    - recurse:
      - user
      - group
      - mode
    - require:
      - user: etcd
      - group: etcd
  pkg.installed:
    - pkgs:
      - iptables
      - etcdctl
      - etcd
    - require:
      - file: /etc/zypp/repos.d/containers.repo
  iptables.append:
    - table: filter
    - family: ipv4
    - chain: INPUT
    - jump: ACCEPT
    - match: state
    - connstate: NEW
    # TODO: add "- source: <local-subnet>"
    - dports:
        - 2380
    - proto: tcp
  service.running:
    - name: etcd
    - enable: True
    - require:
      - sls: ca-cert
      - sls: cert
      - pkg: etcd
      - iptables: etcd
      - file: /var/lib/etcd
    - watch:
      - file: /etc/sysconfig/etcd

# note: this id will be inherited/overwritten by the etcd-proxy
/etc/sysconfig/etcd:
  file.managed:
    - source: salt://etcd/etcd.conf.jinja
    - template: jinja
    - user: etcd
    - group: etcd
    - mode: 644
    - require:
      - pkg: etcd
      - user: etcd
      - group: etcd

include:
  - repositories
  - ca-cert
  - cert

etcd:
  group.present:
    - name: etcd
    - system: True
  user.present:
    - name: etcd
    - createhome: False
    - groups:
      - etcd
    - require:
      - group: etcd
  pkg.installed:
    - pkgs:
      - iptables
      - etcdctl
      - etcd
    - require:
      - file: /etc/zypp/repos.d/containers.repo
  iptables.append:
    - table: filter
    - family: ipv4
    - chain: INPUT
    - jump: ACCEPT
    - match: state
    - connstate: NEW
    # TODO: add "- source: <local-subnet>"
    - dports:
        - 2380
    - proto: tcp
  service.running:
    - name: etcd
    - enable: True
    - require:
      - sls: ca-cert
      - sls: cert
      - pkg: etcd
      - iptables: etcd
      - file: /var/lib/etcd
    - watch:
      - file: /etc/sysconfig/etcd

# note: this id will be inherited/overwritten by the etcd-proxy
/etc/sysconfig/etcd:
  file.managed:
    - source: salt://etcd/etcd.conf.jinja
    - template: jinja
    - user: etcd
    - group: etcd
    - mode: 644
    - require:
      - pkg: etcd
      - user: etcd
      - group: etcd

Stop managing /var/lib/etcd in salt
Stop managing /var/lib/etcd in salt

This dir is created by the etcd rpm, and permissions
are maintained by etcd when it is running

The salt and etcd disagree an what these permissions are
causing extra "changed" entries. As etcd is changing
them to what it needs, and the directory is created
by etcd (and its RPM) we should not try and manage it.

ereslibre/salt,kubic-project/salt,ereslibre/salt,kubic-project/salt,kubic-project/salt,ereslibre/salt