浏览代码

Upgrade to Debian Buster; Removed SSMTP (due to Buster); Upgrade to salt-master 3001; New tree layout

tags/v2.0.0^0
Robin Thoni 4 年前
父节点
当前提交
04d2b072fd
签署人:: Robin THONI <robin@rthoni.com> GPG 密钥 ID: 4E09DEF46B99E61E

+ 30
- 0
data_example/salt/roots/base/file_roots/_modules/utils.py 查看文件

@@ -0,0 +1,30 @@
1
+import ipaddress
2
+
3
+import typing
4
+
5
+
6
+def make_subnet(subnet):
7
+    network = ipaddress.IPv4Network(subnet)
8
+    return {
9
+        "address": str(network.network_address),
10
+        "with_prefix": network.with_prefixlen,
11
+        "prefix": network.prefixlen,
12
+        "with_netmask": network.with_netmask,
13
+        "netmask": str(network.netmask)
14
+    }
15
+
16
+
17
+def polyfill_field(data, field, value):
18
+    if isinstance(data, list):
19
+        for item in data:
20
+            if not field in item:
21
+                item[field] = value
22
+    elif isinstance(data, dict):
23
+        for item_name in data:
24
+            item = data[item_name]
25
+            if not field in item:
26
+                item[field] = value
27
+
28
+
29
+def polyfill_deleted(data):
30
+    polyfill_field(data, "deleted", False)

data_example/salt/roots/states/empty.sls → data_example/salt/roots/base/file_roots/empty.sls 查看文件


data_example/salt/roots/pillar/top.sls → data_example/salt/roots/base/file_roots/top.sls 查看文件


data_example/salt/roots/pillar/empty.sls → data_example/salt/roots/base/pillar_roots/empty.sls 查看文件


data_example/salt/roots/states/top.sls → data_example/salt/roots/base/pillar_roots/top.sls 查看文件


+ 1
- 0
data_example/salt/roots/extmods/modules/utils.py 查看文件

@@ -0,0 +1 @@
1
+../../base/file_roots/_modules/utils.py

+ 0
- 2
docker-compose.yml 查看文件

@@ -15,8 +15,6 @@ services:
15 15
         volumes:
16 16
             - ./data/salt/roots/:/data/salt/
17 17
             - ./data/salt/pki/:/etc/salt/pki/
18
-        env_file:
19
-            - env
20 18
 
21 19
 networks:
22 20
     salt.internal.docker:

+ 0
- 4
env 查看文件

@@ -1,4 +0,0 @@
1
-SSMTP_ROOT=root@rthoni.com
2
-SSMTP_MAILHUB=172.17.0.1:10025
3
-SSMTP_MAILDOMAIN=rthoni.com
4
-

+ 7
- 17
salt/Dockerfile 查看文件

@@ -1,25 +1,15 @@
1
-FROM debian:stretch
1
+FROM debian:buster
2 2
 
3
-ARG CONFIG_DIR=/etc/default/config-files/
3
+ARG SALT_VERSION=3001
4 4
 
5 5
 RUN apt-get update &&\
6 6
     apt-get install -y wget gnupg2 &&\
7
-    wget -O - https://repo.saltstack.com/py3/debian/9/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add - &&\
8
-    echo 'deb http://repo.saltstack.com/py3/debian/9/amd64/latest stretch main' > /etc/apt/sources.list.d/saltstack.list &&\
7
+    wget -O - https://repo.saltstack.com/py3/debian/10/amd64/${SALT_VERSION}/SALTSTACK-GPG-KEY.pub | apt-key add - &&\
8
+    echo "deb http://repo.saltstack.com/py3/debian/10/amd64/${SALT_VERSION} buster main" > /etc/apt/sources.list.d/saltstack.list &&\
9 9
     apt-get update &&\
10
-    apt-get install -y ssmtp salt-master &&\
10
+    apt-get install -y salt-master &&\
11 11
     apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
12 12
 
13
-COPY ./vars-vars /etc/vars-vars
13
+COPY ./config/master /etc/salt/master
14 14
 
15
-COPY ./vars-files /etc/vars-files
16
-
17
-COPY ./common.sh /common.sh
18
-
19
-COPY run.sh /run.sh
20
-
21
-RUN mkdir "${CONFIG_DIR}"
22
-
23
-COPY ./config "${CONFIG_DIR}"
24
-
25
-CMD ["/run.sh"]
15
+CMD ["salt-master"]

+ 0
- 41
salt/common.sh 查看文件

@@ -1,41 +0,0 @@
1
-export CONFIG_DIR="/etc/default/config-files/"
2
-
3
-resolv_host()
4
-{
5
-  hostname="${1}"
6
-  ip=$(getent hosts "${hostname}" | cut -d' ' -f1)
7
-  echo "${ip}"
8
-}
9
-
10
-replace_var()
11
-{
12
-  file="${1}"
13
-  var="${2}"
14
-  sed -e "s?${var}?${!var}?g" -i "${file}"
15
-}
16
-
17
-replace_vars()
18
-{
19
-  file="${1}"
20
-  for var in $(cat /etc/vars-vars)
21
-  do
22
-    replace_var "${file}" "${var}"
23
-  done
24
-}
25
-
26
-replace_files()
27
-{
28
-  cat /etc/vars-files | while read line
29
-  do
30
-    filesrc="${CONFIG_DIR}$(echo "${line}" | awk '{print $1}')"
31
-    filedst=$(echo "${line}" | awk '{print $2}')
32
-    if [ -f "${filesrc}" ]
33
-    then
34
-      echo "Expanding file ${filesrc} to ${filedst}"
35
-      cp "${filesrc}" "${filedst}"
36
-      replace_vars "${filedst}"
37
-    else
38
-      echo "File ${filesrc} does not exist. Skipping."
39
-    fi
40
-  done
41
-}

+ 7
- 7
salt/config/master 查看文件

@@ -61,7 +61,7 @@ interface: 0.0.0.0
61 61
 # each of Salt's module types such as "runners", "output", "wheel", "modules",
62 62
 # "states", "returners", "engines", "utils", etc.
63 63
 #extension_modules: /var/cache/salt/master/extmods
64
-extension_modules: /data/salt/modules
64
+extension_modules: /data/salt/extmods
65 65
 
66 66
 # Directory for custom modules. This directory can contain subdirectories for
67 67
 # each of Salt's module types such as "runners", "output", "wheel", "modules",
@@ -592,8 +592,8 @@ extension_modules: /data/salt/modules
592 592
 #  variable_end_string: '}}'
593 593
 #  comment_start_string: '{#'
594 594
 #  comment_end_string: '#}'
595
-#  line_statement_prefix: 
596
-#  line_comment_prefix: 
595
+#  line_statement_prefix:
596
+#  line_comment_prefix:
597 597
 #  trim_blocks: False
598 598
 #  lstrip_blocks: False
599 599
 #  newline_sequence: '\n'
@@ -607,8 +607,8 @@ extension_modules: /data/salt/modules
607 607
 #  variable_end_string: '}}'
608 608
 #  comment_start_string: '{#'
609 609
 #  comment_end_string: '#}'
610
-#  line_statement_prefix: 
611
-#  line_comment_prefix: 
610
+#  line_statement_prefix:
611
+#  line_comment_prefix:
612 612
 #  trim_blocks: False
613 613
 #  lstrip_blocks: False
614 614
 #  newline_sequence: '\n'
@@ -678,7 +678,7 @@ state_output: changes
678 678
 #
679 679
 file_roots:
680 680
   base:
681
-    - /data/salt/states/
681
+    - /data/salt/base/file_roots/
682 682
 
683 683
 # The master_roots setting configures a master-only copy of the file_roots dictionary,
684 684
 # used by the state compiler.
@@ -854,7 +854,7 @@ file_roots:
854 854
 #  - cmd_yaml: cat /etc/salt/yaml
855 855
 pillar_roots:
856 856
   base:
857
-    - /data/salt/pillar/
857
+    - /data/salt/base/pillar_roots/
858 858
 
859 859
 
860 860
 # A list of paths to be recursively decrypted during pillar compilation.

+ 0
- 19
salt/config/ssmtp.conf 查看文件

@@ -1,19 +0,0 @@
1
-# Configuartion file for sSMTP sendmail
2
-
3
-# The person who gets all mail for userids < 1000
4
-# Make this empty to disable rewriting.
5
-root=SSMTP_ROOT
6
-
7
-# We want to use this with an exim container. Link these
8
-# so that that container will be reachable as 'exim' in
9
-# this container.
10
-mailhub=SSMTP_MAILHUB
11
-
12
-# Where will the mail seem to come from?
13
-rewriteDomain=SSMTP_MAILDOMAIN
14
-
15
-# The full hostname
16
-#hostname=
17
-
18
-# Are users allowed to set their own From: address? (YES/NO)
19
-FromLineOverride=YES

+ 0
- 7
salt/run.sh 查看文件

@@ -1,7 +0,0 @@
1
-#! /usr/bin/env bash
2
-
3
-. /common.sh
4
-
5
-replace_files
6
-
7
-salt-master

+ 0
- 2
salt/vars-files 查看文件

@@ -1,2 +0,0 @@
1
-ssmtp.conf /etc/ssmtp/ssmtp.conf
2
-master /etc/salt/master

+ 0
- 5
salt/vars-vars 查看文件

@@ -1,5 +0,0 @@
1
-SSMTP_ROOT
2
-SSMTP_MAILHUB
3
-SSMTP_MAILDOMAIN
4
-
5
-NUT_ROOT_PASSWD

+ 0
- 7
update_vars.sh 查看文件

@@ -1,7 +0,0 @@
1
-#! /usr/bin/env sh
2
-
3
-vars=$(cat env | cut -d= -f1)
4
-for docker in salt
5
-do
6
-  echo "${vars}" > "./${docker}/vars-vars"
7
-done

正在加载...
取消
保存