Pārlūkot izejas kodu

init

tags/v1.0.0^0
Robin Thoni 6 gadus atpakaļ
revīzija
8a9b9a6677

+ 1
- 0
.gitignore Parādīt failu

@@ -0,0 +1 @@
1
+/data

+ 2
- 0
data_example/salt/roots/pillar/empty.sls Parādīt failu

@@ -0,0 +1,2 @@
1
+empty:
2
+  is_empty: True

+ 3
- 0
data_example/salt/roots/pillar/top.sls Parādīt failu

@@ -0,0 +1,3 @@
1
+base:
2
+  '*':
3
+    - empty

+ 3
- 0
data_example/salt/roots/states/empty.sls Parādīt failu

@@ -0,0 +1,3 @@
1
+empty:
2
+  cmd.run:
3
+    - name: "echo Empty state"

+ 3
- 0
data_example/salt/roots/states/top.sls Parādīt failu

@@ -0,0 +1,3 @@
1
+base:
2
+  '*':
3
+    - empty

+ 22
- 0
docker-compose.yml Parādīt failu

@@ -0,0 +1,22 @@
1
+version: '3.7'
2
+
3
+services:
4
+    salt:
5
+        build: ./salt
6
+        container_name: salt-salt
7
+#        restart: unless-stopped
8
+        networks:
9
+            salt.internal.docker:
10
+                aliases:
11
+                    - salt.salt.internal.docker
12
+        ports:
13
+            - "0.0.0.0:4505:4505"
14
+            - "0.0.0.0:4506:4506"
15
+        volumes:
16
+            - ./data/salt/roots/:/data/salt/
17
+            - ./data/salt/pki/:/etc/salt/pki/
18
+        env_file:
19
+            - env
20
+
21
+networks:
22
+    salt.internal.docker:

+ 4
- 0
env Parādīt failu

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

+ 25
- 0
salt/Dockerfile Parādīt failu

@@ -0,0 +1,25 @@
1
+FROM debian:stretch
2
+
3
+ARG CONFIG_DIR=/etc/default/config-files/
4
+
5
+RUN apt-get update &&\
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 &&\
9
+    apt-get update &&\
10
+    apt-get install -y ssmtp salt-master &&\
11
+    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
12
+
13
+COPY ./vars-vars /etc/vars-vars
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"]

+ 41
- 0
salt/common.sh Parādīt failu

@@ -0,0 +1,41 @@
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
+}

+ 1314
- 0
salt/config/master
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 19
- 0
salt/config/ssmtp.conf Parādīt failu

@@ -0,0 +1,19 @@
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

+ 7
- 0
salt/run.sh Parādīt failu

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

+ 2
- 0
salt/vars-files Parādīt failu

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

+ 5
- 0
salt/vars-vars Parādīt failu

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

+ 7
- 0
update_vars.sh Parādīt failu

@@ -0,0 +1,7 @@
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

Notiek ielāde…
Atcelt
Saglabāt